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

Unified Diff: gm/downsamplebitmap.cpp

Issue 935943007: GM: showmiplevels handles bitmap memory in a nicer way. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/downsamplebitmap.cpp
diff --git a/gm/downsamplebitmap.cpp b/gm/downsamplebitmap.cpp
index d7be6378f28ea5292ff0b3adef6bf50d79bf413b..15280f23e326ac9f473918e1db16e0cdb1e5c051 100644
--- a/gm/downsamplebitmap.cpp
+++ b/gm/downsamplebitmap.cpp
@@ -192,6 +192,11 @@ class DownsampleBitmapImageGM: public DownsampleBitmapGM {
};
#include "SkMipMap.h"
+
+static void release_mipmap(void*, void* context) {
+ ((SkMipMap*)context)->unref();
+}
+
class ShowMipLevels : public skiagm::GM {
public:
SkBitmap fBM;
@@ -224,7 +229,9 @@ protected:
while (mm->extractLevel(scale, &level)) {
SkImageInfo info = SkImageInfo::MakeN32Premul(level.fWidth, level.fHeight);
SkBitmap bm;
- bm.installPixels(info, level.fPixels, level.fRowBytes);
+ bm.installPixels(info, level.fPixels, level.fRowBytes, NULL,
+ &release_mipmap, (void*)(SkRef(mm.get())));
+ bm.setImmutable();
canvas->drawBitmap(bm, x, y, NULL);
y += bm.height() + 4;
scale /= 2;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698