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

Unified Diff: cc/resources/ui_resource_bitmap.cc

Issue 22870016: Update the nine patch layer to use UI resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated comments to reflect changes Created 7 years, 3 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 1510607d8d045c97cab55ef325372714afd7948f..baaed0ee18a6af5463268738ade78d0216afd7f7 100644
--- a/cc/resources/ui_resource_bitmap.cc
+++ b/cc/resources/ui_resource_bitmap.cc
@@ -4,25 +4,41 @@
#include "cc/resources/ui_resource_bitmap.h"
+#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "third_party/skia/include/core/SkBitmap.h"
namespace cc {
-scoped_refptr<UIResourceBitmap>
-UIResourceBitmap::Create(uint8_t* pixels,
- UIResourceFormat format,
- UIResourceWrapMode wrap_mode,
- gfx::Size size) {
- scoped_refptr<UIResourceBitmap> ret = new UIResourceBitmap();
- ret->pixels_ = scoped_ptr<uint8_t[]>(pixels);
- ret->format_ = format;
- ret->wrap_mode_ = wrap_mode;
- ret->size_ = size;
-
- return ret;
+uint8_t* UIResourceBitmap::GetPixels() const {
+ if (!pixel_ref_)
+ return NULL;
+ return static_cast<uint8_t*>(pixel_ref_->pixels());
+}
+
+void UIResourceBitmap::Create(const skia::RefPtr<SkPixelRef>& pixel_ref,
+ UIResourceFormat format,
+ UIResourceWrapMode wrap_mode,
+ gfx::Size size) {
+ DCHECK(size.width() && size.height());
+ DCHECK(pixel_ref && pixel_ref->isImmutable());
aelias_OOO_until_Jul13 2013/09/09 23:11:11 Please separate these into 4 DCHECKs. In general,
powei 2013/09/10 00:42:44 Done.
+ format_ = format;
+ wrap_mode_ = wrap_mode;
+ size_ = size;
+ pixel_ref_ = pixel_ref;
+}
+
+UIResourceBitmap::UIResourceBitmap(const SkBitmap& skbitmap,
+ UIResourceWrapMode wrap_mode) {
+ DCHECK_EQ(skbitmap.config(), SkBitmap::kARGB_8888_Config);
aelias_OOO_until_Jul13 2013/09/09 23:11:11 Please also DCHECK(skbitmap.width(), skbitmap.rowB
powei 2013/09/10 00:42:44 Yes. This was a problem. I will try to be more c
+ DCHECK(skbitmap.isImmutable());
+ skia::RefPtr<SkPixelRef> pixel_ref = skia::SharePtr(skbitmap.pixelRef());
+ Create(pixel_ref,
+ UIResourceBitmap::RGBA8,
+ wrap_mode,
+ gfx::Size(skbitmap.width(), skbitmap.height()));
}
-UIResourceBitmap::UIResourceBitmap() {}
UIResourceBitmap::~UIResourceBitmap() {}
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698