diff options
Diffstat (limited to 'chromium/cc/resources/ui_resource_bitmap.cc')
-rw-r--r-- | chromium/cc/resources/ui_resource_bitmap.cc | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/chromium/cc/resources/ui_resource_bitmap.cc b/chromium/cc/resources/ui_resource_bitmap.cc index b813d973537..58df9d96272 100644 --- a/chromium/cc/resources/ui_resource_bitmap.cc +++ b/chromium/cc/resources/ui_resource_bitmap.cc @@ -6,15 +6,15 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "cc/resources/etc1_pixel_ref.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "third_party/skia/include/core/SkMallocPixelRef.h" #include "third_party/skia/include/core/SkPixelRef.h" namespace cc { void UIResourceBitmap::Create(const skia::RefPtr<SkPixelRef>& pixel_ref, - UIResourceFormat format, - gfx::Size size) { + const gfx::Size& size, + UIResourceFormat format) { DCHECK(size.width()); DCHECK(size.height()); DCHECK(pixel_ref); @@ -29,22 +29,32 @@ 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()); skia::RefPtr<SkPixelRef> pixel_ref = skia::SharePtr(skbitmap.pixelRef()); - Create(pixel_ref, - UIResourceBitmap::RGBA8, - gfx::Size(skbitmap.width(), skbitmap.height())); + const SkImageInfo& info = pixel_ref->info(); + Create( + pixel_ref, gfx::Size(info.fWidth, info.fHeight), UIResourceBitmap::RGBA8); SetOpaque(skbitmap.isOpaque()); } -UIResourceBitmap::UIResourceBitmap( - const skia::RefPtr<ETC1PixelRef>& etc1_pixel_ref, - gfx::Size size) { - Create(etc1_pixel_ref, ETC1, size); +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, + const gfx::Size& size) { + Create(pixel_ref, size, UIResourceBitmap::ETC1); } UIResourceBitmap::~UIResourceBitmap() {} |