summaryrefslogtreecommitdiffstats
path: root/ui/gfx/canvas.cc
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-24 02:26:15 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-24 02:26:15 +0000
commit8add298787128f991142763a876df63ae0344e10 (patch)
tree9f7537cc4290e7a0ebf0df79ae1afdabbce34ecf /ui/gfx/canvas.cc
parent50ed7c91f85b18b3bf63756f5e03809705d38e8d (diff)
downloadchromium_src-8add298787128f991142763a876df63ae0344e10.zip
chromium_src-8add298787128f991142763a876df63ae0344e10.tar.gz
chromium_src-8add298787128f991142763a876df63ae0344e10.tar.bz2
On the Mac, we populate NSImage from bitmaps in resource bundles. Introduce ImageSkia which contains vector of SkBitmaps. Previously this functionality was within ImageRepSkia. ImageSkia exposes this.
Move gfx::Image::GetSkBitmapAtIndex and gfx::Image::GetNumSkBitmaps to ImageSkia BUG=122992 TEST=None Review URL: http://codereview.chromium.org/10086023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133607 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/canvas.cc')
-rw-r--r--ui/gfx/canvas.cc28
1 files changed, 20 insertions, 8 deletions
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
index 883a7ce..288d192 100644
--- a/ui/gfx/canvas.cc
+++ b/ui/gfx/canvas.cc
@@ -278,6 +278,18 @@ void Canvas::DrawBitmapInt(const SkBitmap& bitmap,
int dest_x, int dest_y, int dest_w, int dest_h,
bool filter,
const SkPaint& paint) {
+ DrawBitmapFloat(bitmap, static_cast<float>(src_x), static_cast<float>(src_y),
+ static_cast<float>(src_w), static_cast<float>(src_h),
+ static_cast<float>(dest_x), static_cast<float>(dest_y),
+ static_cast<float>(dest_w), static_cast<float>(dest_h),
+ filter, paint);
+}
+
+void Canvas::DrawBitmapFloat(const SkBitmap& bitmap,
+ float src_x, float src_y, float src_w, float src_h,
+ float dest_x, float dest_y, float dest_w, float dest_h,
+ bool filter,
+ const SkPaint& paint) {
DLOG_ASSERT(src_x + src_w < std::numeric_limits<int16_t>::max() &&
src_y + src_h < std::numeric_limits<int16_t>::max());
if (src_w <= 0 || src_h <= 0) {
@@ -288,10 +300,10 @@ void Canvas::DrawBitmapInt(const SkBitmap& bitmap,
if (!IntersectsClipRectInt(dest_x, dest_y, dest_w, dest_h))
return;
- SkRect dest_rect = { SkIntToScalar(dest_x),
- SkIntToScalar(dest_y),
- SkIntToScalar(dest_x + dest_w),
- SkIntToScalar(dest_y + dest_h) };
+ SkRect dest_rect = { SkFloatToScalar(dest_x),
+ SkFloatToScalar(dest_y),
+ SkFloatToScalar(dest_x + dest_w),
+ SkFloatToScalar(dest_y + dest_h) };
if (src_w == dest_w && src_h == dest_h) {
// Workaround for apparent bug in Skia that causes image to occasionally
@@ -309,10 +321,10 @@ void Canvas::DrawBitmapInt(const SkBitmap& bitmap,
SkShader::kRepeat_TileMode,
SkShader::kRepeat_TileMode);
SkMatrix shader_scale;
- shader_scale.setScale(SkFloatToScalar(static_cast<float>(dest_w) / src_w),
- SkFloatToScalar(static_cast<float>(dest_h) / src_h));
- shader_scale.preTranslate(SkIntToScalar(-src_x), SkIntToScalar(-src_y));
- shader_scale.postTranslate(SkIntToScalar(dest_x), SkIntToScalar(dest_y));
+ shader_scale.setScale(SkFloatToScalar(dest_w / src_w),
+ SkFloatToScalar(dest_h / src_h));
+ shader_scale.preTranslate(SkFloatToScalar(-src_x), SkFloatToScalar(-src_y));
+ shader_scale.postTranslate(SkFloatToScalar(dest_x), SkFloatToScalar(dest_y));
shader->setLocalMatrix(shader_scale);
// Set up our paint to use the shader & release our reference (now just owned