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

Unified Diff: gm/colorcube.cpp

Issue 1827433002: Reland of [2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « gm/color4f.cpp ('k') | gm/coloremoji.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/colorcube.cpp
diff --git a/gm/colorcube.cpp b/gm/colorcube.cpp
index 01aaf156107968e1220681f6331317ae5ae95a04..54e0688c6ab279f0d55fc856e0bc5de25804bb91 100644
--- a/gm/colorcube.cpp
+++ b/gm/colorcube.cpp
@@ -25,27 +25,12 @@
class ColorCubeGM : public GM {
public:
- ColorCubeGM()
- : fInitialized(false)
- , f3DLut4(nullptr)
- , f3DLut8(nullptr)
- , f3DLut16(nullptr)
- , f3DLut32(nullptr)
- , f3DLut64(nullptr)
- {
+ ColorCubeGM() : fInitialized(false) {
this->setBGColor(0xFF000000);
}
- ~ColorCubeGM() {
- SkSafeUnref(f3DLut4);
- SkSafeUnref(f3DLut8);
- SkSafeUnref(f3DLut16);
- SkSafeUnref(f3DLut32);
- SkSafeUnref(f3DLut64);
- }
-
protected:
- virtual SkString onShortName() {
+ SkString onShortName() override {
return SkString("colorcube");
}
@@ -67,8 +52,8 @@
canvas.drawRect(SkRect::MakeWH(80, 80), paint);
}
- void make_3Dlut(SkData** data, int size, bool invR, bool invG, bool invB) {
- *data = SkData::NewUninitialized(sizeof(SkColor) * size * size * size);
+ void make_3Dlut(sk_sp<SkData>* data, int size, bool invR, bool invG, bool invB) {
+ *data = SkData::MakeUninitialized(sizeof(SkColor) * size * size * size);
SkColor* pixels = (SkColor*)((*data)->writable_data());
SkAutoTMalloc<uint8_t> lutMemory(size);
SkAutoTMalloc<uint8_t> invLutMemory(size);
@@ -92,11 +77,11 @@
}
}
- virtual SkISize onISize() {
+ SkISize onISize() override {
return SkISize::Make(500, 100);
}
- virtual void onDraw(SkCanvas* canvas) {
+ void onDraw(SkCanvas* canvas) override {
if (!fInitialized) {
this->make_bitmap();
this->make_3Dluts();
@@ -104,19 +89,19 @@
}
canvas->clear(0x00000000);
SkPaint paint;
- paint.setColorFilter(SkColorCubeFilter::Create(f3DLut4, 4))->unref();
+ paint.setColorFilter(SkColorCubeFilter::Make(f3DLut4, 4));
canvas->drawBitmap(fBitmap, 10, 10, &paint);
- paint.setColorFilter(SkColorCubeFilter::Create(f3DLut8, 8))->unref();
+ paint.setColorFilter(SkColorCubeFilter::Make(f3DLut8, 8));
canvas->drawBitmap(fBitmap, 110, 10, &paint);
- paint.setColorFilter(SkColorCubeFilter::Create(f3DLut16, 16))->unref();
+ paint.setColorFilter(SkColorCubeFilter::Make(f3DLut16, 16));
canvas->drawBitmap(fBitmap, 210, 10, &paint);
- paint.setColorFilter(SkColorCubeFilter::Create(f3DLut32, 32))->unref();
+ paint.setColorFilter(SkColorCubeFilter::Make(f3DLut32, 32));
canvas->drawBitmap(fBitmap, 310, 10, &paint);
- paint.setColorFilter(SkColorCubeFilter::Create(f3DLut64, 64))->unref();
+ paint.setColorFilter(SkColorCubeFilter::Make(f3DLut64, 64));
canvas->drawBitmap(fBitmap, 410, 10, &paint);
}
@@ -124,11 +109,11 @@
typedef GM INHERITED;
bool fInitialized;
SkBitmap fBitmap;
- SkData* f3DLut4;
- SkData* f3DLut8;
- SkData* f3DLut16;
- SkData* f3DLut32;
- SkData* f3DLut64;
+ sk_sp<SkData> f3DLut4;
+ sk_sp<SkData> f3DLut8;
+ sk_sp<SkData> f3DLut16;
+ sk_sp<SkData> f3DLut32;
+ sk_sp<SkData> f3DLut64;
};
//////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « gm/color4f.cpp ('k') | gm/coloremoji.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698