summaryrefslogtreecommitdiffstats
path: root/cc/test/skia_common.cc
diff options
context:
space:
mode:
authorreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-25 22:00:51 +0000
committerreed@google.com <reed@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-25 22:00:51 +0000
commit0046982c81ef5cf5cca021ec4bb1bfc83d0c3973 (patch)
treea601b47203a8a032442be78df0df496d42c7f37b /cc/test/skia_common.cc
parentc14865ce46b841b4b2f86f8016e42939b8387022 (diff)
downloadchromium_src-0046982c81ef5cf5cca021ec4bb1bfc83d0c3973.zip
chromium_src-0046982c81ef5cf5cca021ec4bb1bfc83d0c3973.tar.gz
chromium_src-0046982c81ef5cf5cca021ec4bb1bfc83d0c3973.tar.bz2
SkColorType instead of (deprecated) SkBitmap::Config
Part of this refactoring was the recognition of a common pattern: - setConfig + alloc + setImmutable + pass_to_UIResourceBitmap This CL introduces a direct way on UIResourceBitmap to create such a bitmap, by just specifying its dimensions. This encapsulates internal requirements (e.g. colortype and immutability). Review URL: https://codereview.chromium.org/197883017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259349 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/test/skia_common.cc')
-rw-r--r--cc/test/skia_common.cc17
1 files changed, 5 insertions, 12 deletions
diff --git a/cc/test/skia_common.cc b/cc/test/skia_common.cc
index 277a124..7d1c3b8 100644
--- a/cc/test/skia_common.cc
+++ b/cc/test/skia_common.cc
@@ -15,26 +15,19 @@ namespace cc {
void DrawPicture(unsigned char* buffer,
const gfx::Rect& layer_rect,
scoped_refptr<Picture> picture) {
+ SkImageInfo info =
+ SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height());
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config,
- layer_rect.width(),
- layer_rect.height());
- bitmap.setPixels(buffer);
+ bitmap.installPixels(info, buffer, info.minRowBytes());
SkCanvas canvas(bitmap);
canvas.clipRect(gfx::RectToSkRect(layer_rect));
picture->Raster(&canvas, NULL, layer_rect, 1.0f);
}
void CreateBitmap(const gfx::Size& size, const char* uri, SkBitmap* bitmap) {
- SkImageInfo info = {
- size.width(),
- size.height(),
- kPMColor_SkColorType,
- kPremul_SkAlphaType
- };
+ SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height());
- bitmap->setConfig(info);
- bitmap->allocPixels();
+ bitmap->allocPixels(info);
bitmap->pixelRef()->setImmutable();
bitmap->pixelRef()->setURI(uri);
}