summaryrefslogtreecommitdiffstats
path: root/ui/gfx/canvas.h
diff options
context:
space:
mode:
authoracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-23 20:55:08 +0000
committeracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-23 20:55:08 +0000
commit57047da61489644b8b3604dffd915a1ebcf78f91 (patch)
treee15a0fae2a4eee1fe1e96b4d9df6d623175cbeaf /ui/gfx/canvas.h
parenta2a5801c6c7eeb9b5d7a7068a6ff50a2dd51ebd8 (diff)
downloadchromium_src-57047da61489644b8b3604dffd915a1ebcf78f91.zip
chromium_src-57047da61489644b8b3604dffd915a1ebcf78f91.tar.gz
chromium_src-57047da61489644b8b3604dffd915a1ebcf78f91.tar.bz2
Revert 147915 - Cleanup gfx::Canvas now that 10562027 has landed
Reverting because composite_unittests were failing on Linux (aura) and Linux ChromeOS Tests bots. Bug=None Test=Compiles on Mac and CrOS R=oshima,sky TBR=sadrul,sail Review URL: https://chromiumcodereview.appspot.com/10701063 TBR=pkotwicz@chromium.org Review URL: https://chromiumcodereview.appspot.com/10790128 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147936 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/canvas.h')
-rw-r--r--ui/gfx/canvas.h43
1 files changed, 31 insertions, 12 deletions
diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h
index 700d7d2..8256412 100644
--- a/ui/gfx/canvas.h
+++ b/ui/gfx/canvas.h
@@ -99,6 +99,12 @@ class UI_EXPORT Canvas {
// Creates an empty canvas with scale factor of 1x.
Canvas();
+ // Creates canvas with provided DIP |size| and a scale factor of 1x.
+ // If this canvas is not opaque, it's explicitly cleared to transparent before
+ // being returned.
+ // TODO(pkotwicz): Remove this constructor.
+ Canvas(const gfx::Size& size, bool is_opaque);
+
// Creates canvas with provided DIP |size| and |scale_factor|.
// If this canvas is not opaque, it's explicitly cleared to transparent before
// being returned.
@@ -110,13 +116,13 @@ class UI_EXPORT Canvas {
// provided |image_rep|, and draws the |image_rep| into it.
Canvas(const gfx::ImageSkiaRep& image_rep, bool is_opaque);
- virtual ~Canvas();
+ // Sets scale factor to |scale_factor|.
+ // Only scales canvas if |scale_canvas| is true.
+ Canvas(SkCanvas* canvas,
+ ui::ScaleFactor scale_factor,
+ bool scale_canvas);
- // Creates a gfx::Canvas backed by an |sk_canvas| with |scale_factor|.
- // |sk_canvas| is assumed to be already scaled based on |scale_factor|
- // so no additional scaling is applied.
- static Canvas* CreateCanvasWithoutScaling(SkCanvas* sk_canvas,
- ui::ScaleFactor scale_factor);
+ virtual ~Canvas();
// Recreates the backing platform canvas with DIP |size| and |scale_factor|.
// If the canvas is not opaque, it is explicitly cleared.
@@ -166,8 +172,13 @@ class UI_EXPORT Canvas {
int x, int y, int w, int h,
int flags);
+ // Extracts a bitmap from the contents of this canvas.
+ // TODO(pkotwicz): Remove ExtractBitmap once all callers use
+ // ExtractImageSkiaRep instead.
+ SkBitmap ExtractBitmap() const;
+
// Extracts an ImageSkiaRep from the contents of this canvas.
- gfx::ImageSkiaRep ExtractImageRep() const;
+ gfx::ImageSkiaRep ExtractImageSkiaRep() const;
// Draws a dashed rectangle of the specified color.
void DrawDashedRect(const gfx::Rect& rect, SkColor color);
@@ -377,12 +388,16 @@ class UI_EXPORT Canvas {
ui::ScaleFactor scale_factor() const { return scale_factor_; }
private:
- Canvas(SkCanvas* canvas, ui::ScaleFactor scale_factor);
-
// Test whether the provided rectangle intersects the current clip rect.
bool IntersectsClipRectInt(int x, int y, int w, int h);
bool IntersectsClipRect(const gfx::Rect& rect);
+ // Sets the canvas' scale factor to |scale_factor|. This affects
+ // the scale factor at which drawing bitmaps occurs and the scale factor of
+ // the image rep returned by Canvas::ExtractImageSkiaRep().
+ // If |scale_canvas| is true, scales the canvas by |scale_factor|.
+ void ApplyScaleFactor(ui::ScaleFactor scale_factor, bool scale_canvas);
+
// Returns the image rep which best matches the canvas |scale_factor_|.
// Returns a null image rep if |image| contains no image reps.
// Builds mip map for returned image rep if necessary.
@@ -395,14 +410,18 @@ class UI_EXPORT Canvas {
float user_defined_scale_factor_x,
float user_defined_scale_factor_y) const;
+ scoped_ptr<skia::PlatformCanvas> owned_canvas_;
+ SkCanvas* canvas_;
+
+ // True if the scale factor scales the canvas and the inverse
+ // canvas scale should be applied when the destructor is called.
+ bool scale_factor_scales_canvas_;
+
// The device scale factor at which drawing on this canvas occurs.
// An additional scale can be applied via Canvas::Scale(). However,
// Canvas::Scale() does not affect |scale_factor_|.
ui::ScaleFactor scale_factor_;
- scoped_ptr<skia::PlatformCanvas> owned_canvas_;
- SkCanvas* canvas_;
-
DISALLOW_COPY_AND_ASSIGN(Canvas);
};