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

Unified Diff: cc/resources/ui_resource_bitmap.cc

Issue 463663002: Support an ALPHA_8 UIResourceBitmap format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 6 years, 4 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
Index: cc/resources/ui_resource_bitmap.cc
diff --git a/cc/resources/ui_resource_bitmap.cc b/cc/resources/ui_resource_bitmap.cc
index a7e732c30ca290110b1e631f1566036ff4e5c944..e254cf71614e8fdf73f2d576594c7fbcd5572644 100644
--- a/cc/resources/ui_resource_bitmap.cc
+++ b/cc/resources/ui_resource_bitmap.cc
@@ -11,6 +11,26 @@
#include "third_party/skia/include/core/SkPixelRef.h"
namespace cc {
+namespace {
+
+UIResourceBitmap::UIResourceFormat SkColorTypeToUIResourceFormat(
+ SkColorType sk_type) {
+ UIResourceBitmap::UIResourceFormat format = UIResourceBitmap::RGBA8;
+ switch (sk_type) {
+ case kN32_SkColorType:
+ format = UIResourceBitmap::RGBA8;
+ break;
+ case kAlpha_8_SkColorType:
+ format = UIResourceBitmap::ALPHA_8;
+ break;
+ default:
+ NOTREACHED() << "Invalid SkColorType for UIResourceBitmap: " << sk_type;
+ break;
+ }
+ return format;
+}
+
+} // namespace
void UIResourceBitmap::Create(const skia::RefPtr<SkPixelRef>& pixel_ref,
const gfx::Size& size,
@@ -29,14 +49,14 @@ void UIResourceBitmap::Create(const skia::RefPtr<SkPixelRef>& pixel_ref,
}
UIResourceBitmap::UIResourceBitmap(const SkBitmap& skbitmap) {
- DCHECK_EQ(skbitmap.colorType(), kN32_SkColorType);
DCHECK_EQ(skbitmap.width(), skbitmap.rowBytesAsPixels());
DCHECK(skbitmap.isImmutable());
skia::RefPtr<SkPixelRef> pixel_ref = skia::SharePtr(skbitmap.pixelRef());
const SkImageInfo& info = pixel_ref->info();
- Create(
- pixel_ref, gfx::Size(info.fWidth, info.fHeight), UIResourceBitmap::RGBA8);
+ Create(pixel_ref,
+ gfx::Size(info.fWidth, info.fHeight),
+ SkColorTypeToUIResourceFormat(skbitmap.colorType()));
SetOpaque(skbitmap.isOpaque());
}

Powered by Google App Engine
This is Rietveld 408576698