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

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: Minor format change and changed initial value for fill_center_ in nine patch layer Created 7 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 8bbfb37deee70a1ebaede084bea89fcc1361064d..9905110dd359ec411de61fbe564acfb0e2f6e4e5 100644
--- a/cc/resources/ui_resource_bitmap.cc
+++ b/cc/resources/ui_resource_bitmap.cc
@@ -4,7 +4,10 @@
#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"
+#include "ui/gfx/android/java_bitmap.h"
namespace cc {
@@ -21,6 +24,28 @@ UIResourceBitmap::Create(uint8_t* pixels,
}
UIResourceBitmap::UIResourceBitmap() {}
+
UIResourceBitmap::~UIResourceBitmap() {}
+scoped_refptr<UIResourceBitmap> CreateUIResourceBitmapFromSkBitmap(
+ const SkBitmap& skbitmap) {
+ DCHECK_EQ(skbitmap.config(), SkBitmap::kARGB_8888_Config);
+
+ gfx::Size size(skbitmap.width(), skbitmap.height());
+ uint8_t* dst_pixels = new uint8_t[size.GetArea() * 4];
+ uint8_t* src_pixels = static_cast<uint8_t*>(skbitmap.getPixels());
+ memcpy(dst_pixels, src_pixels, size.GetArea() * 4);
+ return UIResourceBitmap::Create(dst_pixels, UIResourceBitmap::RGBA8, size);
+}
+
+scoped_refptr<UIResourceBitmap> CreateUIResourceBitmapFromJavaBitmap(
+ gfx::JavaBitmap& bitmap) {
+ void* src_pixels = bitmap.pixels();
+ gfx::Size size = bitmap.size();
+ uint8_t* dst_pixels = new uint8_t[size.GetArea() * 4];
+ memcpy(dst_pixels, src_pixels, size.GetArea() * 4);
+ return cc::UIResourceBitmap::Create(
+ dst_pixels, cc::UIResourceBitmap::RGBA8, size);
+}
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698