Permalink
Browse files

Default initialize CanvasPaintT<T> bitmaps to 0, 0, 0, 0.

PlatformCanvas objects are constructed uninitialized.  (Since change http://src.chromium.org/viewvc/chrome?view=rev&revision=127196).  This change had propagated uninitialized semantics to CanvasPaint<..>, and CanvasPaintSkia, which introduced the regressions mentioned in the bug below.

This change re-introduces the initilized memory behaviour, but at the CanvasPaint<T> level.  This preserves the performance boost from rev 127196, and prevents regressions in displayed UI elements.

Change also removes a now-unnecessary clear in browser_action_button.mm introduced by http://codereview.chromium.org/9839012.

BUG=118755
TEST=None
Review URL: https://chromiumcodereview.appspot.com/9837043

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128574 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information...
1 parent 67d8865 commit dff46c1ff17cb55fe7a343de4157d33f3520944e twiz@chromium.org committed Mar 23, 2012
@@ -318,7 +318,6 @@ @implementation BrowserActionCell
- (void)drawBadgeWithinFrame:(NSRect)frame {
gfx::CanvasSkiaPaint canvas(frame, false);
- canvas.sk_canvas()->clear(SkColorSetARGB(0, 0, 0, 0));
canvas.set_composite_alpha(true);
gfx::Rect boundingRect(NSRectToCGRect(frame));
extensionAction_->PaintBadge(&canvas, boundingRect, tabId_);
@@ -18,6 +18,7 @@ namespace skia {
// A class designed to translate skia painting into a region in a GdkWindow.
// On construction, it will set up a context for painting into, and on
// destruction, it will commit it to the GdkWindow.
+// Note: The created context is always inialized to (0, 0, 0, 0).
template <class T>
class CanvasPaintT : public T {
public:
@@ -89,6 +90,8 @@ class CanvasPaintT : public T {
// Cause a deliberate crash;
CHECK(false);
}
+ // No need to clear the canvas, because cairo automatically performs the
+ // clear.
// Need to translate so that the dirty region appears at the origin of the
// surface.
@@ -17,6 +17,7 @@ namespace skia {
// A class designed to translate skia painting into a region to the current
// graphics context. On construction, it will set up a context for painting
// into, and on destruction, it will commit it to the current context.
+// Note: The created context is always inialized to (0, 0, 0, 0).
template <class T>
class CanvasPaintT : public T {
public:
@@ -89,6 +90,7 @@ class CanvasPaintT : public T {
// Cause a deliberate crash;
*(volatile char*) 0 = 0;
}
+ canvas->clear(SkColorSetARGB(0, 0, 0, 0));
// Need to translate so that the dirty region appears at the origin of the
// surface.
@@ -15,6 +15,7 @@ namespace skia {
// A class designed to translate skia painting into a region in a Wayland window
// surface. On construction, it will set up a context for painting into, and on
// destruction, it will commit it to the Wayland window surface.
+// Note: The created context is always inialized to (0, 0, 0, 0).
template <class T>
class CanvasPaintT : public T {
public:
@@ -86,6 +87,8 @@ class CanvasPaintT : public T {
// Cause a deliberate crash;
CHECK(false);
}
+ // No need to clear the canvas, because cairo automatically performs the
+ // clear.
// Need to translate so that the dirty region appears at the origin of the
// surface.
@@ -29,6 +29,7 @@ namespace skia {
// }
// return 0;
// }
+// Note: The created context is always inialized to (0, 0, 0, 0).
template <class T>
class CanvasPaintT : public T {
public:
@@ -113,6 +114,7 @@ class CanvasPaintT : public T {
// Cause a deliberate crash;
*(char*) 0 = 0;
}
+ canvas->clear(SkColorSetARGB(0, 0, 0, 0));
// This will bring the canvas into the screen coordinate system for the
// dirty rect
@@ -17,6 +17,7 @@ namespace skia {
// A class designed to translate skia painting into a region in a Wayland window
// surface. On construction, it will set up a context for painting into, and on
// destruction, it will commit it to the Wayland window surface.
+// Note: The created context is always inialized to (0, 0, 0, 0).
template <class T>
class CanvasPaintT : public T {
public:
@@ -88,6 +89,8 @@ class CanvasPaintT : public T {
// Cause a deliberate crash;
CHECK(false);
}
+ // No need to clear the canvas, because cairo automatically performs the
+ // clear.
// Need to translate so that the dirty region appears at the origin of the
// surface.

0 comments on commit dff46c1

Please sign in to comment.