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

Side by Side Diff: gm/pixelxorxfermode.cpp

Issue 1633773002: Fix memory leak in pixelxorxfermode GM (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "Resources.h" 9 #include "Resources.h"
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 void onDraw(SkCanvas* canvas) override { 43 void onDraw(SkCanvas* canvas) override {
44 canvas->drawBitmap(fBM, 0, 0); 44 canvas->drawBitmap(fBM, 0, 0);
45 45
46 SkRect r = SkRect::MakeIWH(256, 256); 46 SkRect r = SkRect::MakeIWH(256, 256);
47 47
48 // Negate the red channel of the dst (via the ancillary color) but leave 48 // Negate the red channel of the dst (via the ancillary color) but leave
49 // the green & blue channels alone 49 // the green & blue channels alone
50 SkPaint p1; 50 SkPaint p1;
51 p1.setColor(SK_ColorBLACK); // noop 51 p1.setColor(SK_ColorBLACK); // noop
52 p1.setXfermode(SkPixelXorXfermode::Create(SK_ColorRED)); 52 p1.setXfermode(SkPixelXorXfermode::Create(SK_ColorRED))->unref();
53 53
54 canvas->drawRect(r, p1); 54 canvas->drawRect(r, p1);
55 55
56 r.offsetTo(256.0f, 0.0f); 56 r.offsetTo(256.0f, 0.0f);
57 57
58 // Negate the dst color via the src color 58 // Negate the dst color via the src color
59 SkPaint p2; 59 SkPaint p2;
60 p2.setColor(SK_ColorWHITE); 60 p2.setColor(SK_ColorWHITE);
61 p2.setXfermode(SkPixelXorXfermode::Create(SK_ColorBLACK)); // noop 61 p2.setXfermode(SkPixelXorXfermode::Create(SK_ColorBLACK))->unref(); // n oop
62 62
63 canvas->drawRect(r, p2); 63 canvas->drawRect(r, p2);
64 64
65 r.offsetTo(0.0f, 256.0f); 65 r.offsetTo(0.0f, 256.0f);
66 66
67 // Just return the original color 67 // Just return the original color
68 SkPaint p3; 68 SkPaint p3;
69 p3.setColor(SK_ColorBLACK); // noop 69 p3.setColor(SK_ColorBLACK); // noop
70 p3.setXfermode(SkPixelXorXfermode::Create(SK_ColorBLACK)); // noop 70 p3.setXfermode(SkPixelXorXfermode::Create(SK_ColorBLACK))->unref(); // n oop
71 71
72 canvas->drawRect(r, p3); 72 canvas->drawRect(r, p3);
73 73
74 r.offsetTo(256.0f, 256.0f); 74 r.offsetTo(256.0f, 256.0f);
75 75
76 // Negate the red & green channels (via the ancillary color) but leave 76 // Negate the red & green channels (via the ancillary color) but leave
77 // the blue channel alone 77 // the blue channel alone
78 SkPaint p4; 78 SkPaint p4;
79 p4.setColor(SK_ColorBLACK); // noop 79 p4.setColor(SK_ColorBLACK); // noop
80 p4.setXfermode(SkPixelXorXfermode::Create(SK_ColorYELLOW)); 80 p4.setXfermode(SkPixelXorXfermode::Create(SK_ColorYELLOW))->unref();
81 81
82 canvas->drawRect(r, p4); 82 canvas->drawRect(r, p4);
83 } 83 }
84 84
85 private: 85 private:
86 SkBitmap fBM; 86 SkBitmap fBM;
87 87
88 typedef GM INHERITED; 88 typedef GM INHERITED;
89 }; 89 };
90 90
91 ////////////////////////////////////////////////////////////////////////////// 91 //////////////////////////////////////////////////////////////////////////////
92 92
93 DEF_GM(return new PixelXorXfermodeGM;) 93 DEF_GM(return new PixelXorXfermodeGM;)
OLDNEW
« 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