Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1303)

Unified Diff: cc/resources/ui_resource_bitmap.cc

Issue 197883017: SkColorType instead of (deprecated) SkBitmap::Config (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments from #5 Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/ui_resource_bitmap.h ('k') | cc/test/fake_scoped_ui_resource.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/ui_resource_bitmap.cc
diff --git a/cc/resources/ui_resource_bitmap.cc b/cc/resources/ui_resource_bitmap.cc
index 562e13a234ce09070aefac08791d994959e5d6b8..58df9d962726156853008a10778160d383bf183f 100644
--- a/cc/resources/ui_resource_bitmap.cc
+++ b/cc/resources/ui_resource_bitmap.cc
@@ -13,7 +13,7 @@
namespace cc {
void UIResourceBitmap::Create(const skia::RefPtr<SkPixelRef>& pixel_ref,
- gfx::Size size,
+ const gfx::Size& size,
UIResourceFormat format) {
DCHECK(size.width());
DCHECK(size.height());
@@ -29,7 +29,7 @@ void UIResourceBitmap::Create(const skia::RefPtr<SkPixelRef>& pixel_ref,
}
UIResourceBitmap::UIResourceBitmap(const SkBitmap& skbitmap) {
- DCHECK_EQ(skbitmap.config(), SkBitmap::kARGB_8888_Config);
+ DCHECK_EQ(skbitmap.colorType(), kPMColor_SkColorType);
DCHECK_EQ(skbitmap.width(), skbitmap.rowBytesAsPixels());
DCHECK(skbitmap.isImmutable());
@@ -41,8 +41,19 @@ UIResourceBitmap::UIResourceBitmap(const SkBitmap& skbitmap) {
SetOpaque(skbitmap.isOpaque());
}
+UIResourceBitmap::UIResourceBitmap(const gfx::Size& size, bool is_opaque) {
+ SkAlphaType alphaType = is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
+ SkImageInfo info =
+ SkImageInfo::MakeN32(size.width(), size.height(), alphaType);
+ skia::RefPtr<SkPixelRef> pixel_ref = skia::AdoptRef(
+ SkMallocPixelRef::NewAllocate(info, info.minRowBytes(), NULL));
+ pixel_ref->setImmutable();
+ Create(pixel_ref, size, UIResourceBitmap::RGBA8);
+ SetOpaque(is_opaque);
+}
+
UIResourceBitmap::UIResourceBitmap(const skia::RefPtr<SkPixelRef>& pixel_ref,
- gfx::Size size) {
+ const gfx::Size& size) {
Create(pixel_ref, size, UIResourceBitmap::ETC1);
}
« no previous file with comments | « cc/resources/ui_resource_bitmap.h ('k') | cc/test/fake_scoped_ui_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698