aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image/SkImage_Raster.cpp
diff options
context:
space:
mode:
authorGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-02 17:29:28 +0000
committerGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-02 17:29:28 +0000
commit1bed687f6b8fc67336f0f5d6fb5a5b38dd0fdff9 (patch)
tree0f89292bb40a1b048ac03f541d9dbc62ebbddab4 /src/image/SkImage_Raster.cpp
parent261c66668269588a26757a0bfe28a3a3eac07665 (diff)
Add a release procedure to SkMallocPixelRef; remove SkDataPixelRef
This works in a way that is similar to SkData. SkMallocPixelRef::NewWithProc Motivation: Chrome has a ETC1PixelRef which calls delete[] on the pixles on destruction. There is no reason for them to almost duplicate our class, when we can provide them a more flexible class. Example use: static void delete_uint8_proc(void* ptr, void*) { delete[] static_cast<uint8_t>(ptr); } SkPixelRef* new_delete_pixref(const SkImageInfo& info, SkColorTable* ctable) { size_t rb = info.minRowBytes(); return SkMallocPixelRef::NewWithProc( info, rb, ctable, new uint8_t[info.getSafeSize(rb)], delete_uint8_proc, NULL); } SkMallocPixelRef::NewWithData Motivation: This allows up to eliminate SkDataPixelRef. We modified SkImage_Raster to use MallocPixelRef rather than SkDataPixlRef. Also: Unit tests in tests/MallocPixelRefTest. BUG= R=reed@google.com Review URL: https://codereview.chromium.org/106883006 git-svn-id: http://skia.googlecode.com/svn/trunk@12861 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/image/SkImage_Raster.cpp')
-rw-r--r--src/image/SkImage_Raster.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 807c19e79d..819c08f051 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -10,7 +10,7 @@
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkData.h"
-#include "SkDataPixelRef.h"
+#include "SkMallocPixelRef.h"
class SkImage_Raster : public SkImage_Base {
public:
@@ -85,7 +85,9 @@ SkImage* SkImage_Raster::NewEmpty() {
SkImage_Raster::SkImage_Raster(const Info& info, SkData* data, size_t rowBytes)
: INHERITED(info.fWidth, info.fHeight) {
fBitmap.setConfig(info, rowBytes);
- fBitmap.setPixelRef(SkNEW_ARGS(SkDataPixelRef, (info, data)))->unref();
+ SkAutoTUnref<SkPixelRef> ref(
+ SkMallocPixelRef::NewWithData(info, rowBytes, NULL, data, 0));
+ fBitmap.setPixelRef(ref, 0);
fBitmap.setImmutable();
}