summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-03 19:41:11 +0000
committerreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-03 19:41:11 +0000
commit2885cb33aef2ac47f2678eb065cfe46ea8f75554 (patch)
treed8e4f741b7d13763283c2b670d892ae4fa8c5bf4 /ui
parenta8c2ee0104ef7e4201b0babcd00bcb01c838095b (diff)
downloadchromium_src-2885cb33aef2ac47f2678eb065cfe46ea8f75554.zip
chromium_src-2885cb33aef2ac47f2678eb065cfe46ea8f75554.tar.gz
chromium_src-2885cb33aef2ac47f2678eb065cfe46ea8f75554.tar.bz2
Extend gfx::canvas to allow DrawBitmapInt(..., alpha). This allows callers to
specify an alpha directly, rather than forcing them to bracket the call with SaveLayerAlpha(alpha) DrawBitmapInt() Restore() Should be 2x faster or better. Review URL: https://codereview.chromium.org/11046020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159948 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/gfx/canvas.cc6
-rw-r--r--ui/gfx/canvas.h4
2 files changed, 10 insertions, 0 deletions
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
index 1a87c73..c4f98d6 100644
--- a/ui/gfx/canvas.cc
+++ b/ui/gfx/canvas.cc
@@ -287,6 +287,12 @@ void Canvas::DrawImageInt(const gfx::ImageSkia& image, int x, int y) {
DrawImageInt(image, x, y, paint);
}
+void Canvas::DrawImageInt(const gfx::ImageSkia& image, int x, int y, uint8 a) {
+ SkPaint paint;
+ paint.setAlpha(a);
+ DrawImageInt(image, x, y, paint);
+}
+
void Canvas::DrawImageInt(const gfx::ImageSkia& image,
int x, int y,
const SkPaint& paint) {
diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h
index 700d7d2..8b039fe 100644
--- a/ui/gfx/canvas.h
+++ b/ui/gfx/canvas.h
@@ -262,6 +262,10 @@ class UI_EXPORT Canvas {
// Thus, x is 2 pixels if canvas scale = 2 & |x| = 1.
void DrawImageInt(const gfx::ImageSkia&, int x, int y);
+ // Helper for DrawImageInt(..., paint) that constructs a temporary paint and
+ // calls paint.setAlpha(alpha).
+ void DrawImageInt(const gfx::ImageSkia&, int x, int y, uint8 alpha);
+
// Draws an image with the origin at the specified location, using the
// specified paint. The upper left corner of the bitmap is rendered at the
// specified location.