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

Unified Diff: src/core/SkBitmap.cpp

Issue 143073008: add installPixels (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: sample impl Created 6 years, 11 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
« include/core/SkBitmap.h ('K') | « include/core/SkBitmap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmap.cpp
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 2464d5d5967409f77d87ce7cbf26cc5e4b82ab4d..75845b15d610babe5f5f665cbe1df58dcd030aeb 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -495,6 +495,33 @@ bool SkBitmap::allocPixels(Allocator* allocator, SkColorTable* ctable) {
return allocator->allocPixelRef(this, ctable);
}
+bool SkBitmap::allocPixels(const SkImageInfo& info, SkColorTable* ctable) {
+ if (!this->setConfig(info) && !this->allocPixels(ctable)) {
+ this->reset();
+ return false;
+ }
+ return true;
+}
+
+bool SkBitmap::installPixels(const SkImageInfo& info, void* pixels, size_t rb,
+ void (*releaseProc)(void* addr, void* context),
+ void* context) {
+ if (!this->setConfig(info)) {
+ this->reset();
+ return false;
+ }
+
+ SkPixelRef* pr = SkMallocPixelRef::NewWithProc(info, rb, NULL, pixels,
+ releaseProc, context);
+ if (!pr) {
+ this->reset();
+ return false;
+ }
+
+ this->setPixelRef(pr)->unref();
+ return true;
+}
+
void SkBitmap::freePixels() {
// if we're gonna free the pixels, we certainly need to free the mipmap
this->freeMipMap();
« include/core/SkBitmap.h ('K') | « include/core/SkBitmap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698