scoped_canvas.h 905 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_GFX_SCOPED_CANVAS_H_
  5. #define UI_GFX_SCOPED_CANVAS_H_
  6. #include "base/memory/raw_ptr.h"
  7. #include "ui/gfx/canvas.h"
  8. #include "ui/gfx/gfx_export.h"
  9. namespace gfx {
  10. // Saves the drawing state, and restores the state when going out of scope.
  11. class GFX_EXPORT ScopedCanvas {
  12. public:
  13. explicit ScopedCanvas(gfx::Canvas* canvas);
  14. ScopedCanvas(const ScopedCanvas&) = delete;
  15. ScopedCanvas& operator=(const ScopedCanvas&) = delete;
  16. virtual ~ScopedCanvas();
  17. // If the UI is in RTL layout, applies a transform such that anything drawn
  18. // inside the supplied width will be flipped horizontally.
  19. void FlipIfRTL(int width);
  20. private:
  21. raw_ptr<gfx::Canvas> canvas_;
  22. };
  23. } // namespace gfx
  24. #endif // UI_GFX_SCOPED_CANVAS_H_