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

Side by Side Diff: gm/recordopts.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 unified diff | Download patch
« no previous file with comments | « gm/multipicturedraw.cpp ('k') | gm/skbug1719.cpp » ('j') | 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 2014 Google Inc. 2 * Copyright 2014 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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
11 #include "SkPictureRecorder.h" 11 #include "SkPictureRecorder.h"
12 #include "SkTableColorFilter.h" 12 #include "SkTableColorFilter.h"
13 #include "SkColorFilterImageFilter.h" 13 #include "SkColorFilterImageFilter.h"
14 #include "SkPictureImageFilter.h" 14 #include "SkPictureImageFilter.h"
15 15
16 static const int kTestRectSize = 50; 16 static const int kTestRectSize = 50;
17 static const int kDetectorGreenValue = 50; 17 static const int kDetectorGreenValue = 50;
18 18
19 // Below are few functions to install "detector" color filters. The filter is th ere to assert that 19 // Below are few functions to install "detector" color filters. The filter is th ere to assert that
20 // the color value it sees is the expected. It will trigger only with kDetectorG reenValue, and 20 // the color value it sees is the expected. It will trigger only with kDetectorG reenValue, and
21 // turn that value into full green. The idea is that if an optimization incorrec tly changes 21 // turn that value into full green. The idea is that if an optimization incorrec tly changes
22 // kDetectorGreenValue and then the incorrect value is observable by some part o f the drawing 22 // kDetectorGreenValue and then the incorrect value is observable by some part o f the drawing
23 // pipeline, that pixel will remain empty. 23 // pipeline, that pixel will remain empty.
24 24
25 static SkColorFilter* make_detector_color_filter() { 25 static sk_sp<SkColorFilter> make_detector_color_filter() {
26 uint8_t tableA[256] = { 0, }; 26 uint8_t tableA[256] = { 0, };
27 uint8_t tableR[256] = { 0, }; 27 uint8_t tableR[256] = { 0, };
28 uint8_t tableG[256] = { 0, }; 28 uint8_t tableG[256] = { 0, };
29 uint8_t tableB[256] = { 0, }; 29 uint8_t tableB[256] = { 0, };
30 tableA[255] = 255; 30 tableA[255] = 255;
31 tableG[kDetectorGreenValue] = 255; 31 tableG[kDetectorGreenValue] = 255;
32 return SkTableColorFilter::CreateARGB(tableA, tableR, tableG, tableB); 32 return SkTableColorFilter::MakeARGB(tableA, tableR, tableG, tableB);
33 } 33 }
34 34
35 // This detector detects that color filter phase of the pixel pipeline receives the correct value. 35 // This detector detects that color filter phase of the pixel pipeline receives the correct value.
36 static void install_detector_color_filter(SkPaint* drawPaint) { 36 static void install_detector_color_filter(SkPaint* drawPaint) {
37 drawPaint->setColorFilter(make_detector_color_filter())->unref(); 37 drawPaint->setColorFilter(make_detector_color_filter());
38 } 38 }
39 39
40 // This detector detects that image filter phase of the pixel pipeline receives the correct value. 40 // This detector detects that image filter phase of the pixel pipeline receives the correct value.
41 static void install_detector_image_filter(SkPaint* drawPaint) { 41 static void install_detector_image_filter(SkPaint* drawPaint) {
42 SkAutoTUnref<SkColorFilter> colorFilter(make_detector_color_filter()); 42 auto colorFilter(make_detector_color_filter());
43 SkImageFilter* imageFilter = 43 SkImageFilter* imageFilter =
44 SkColorFilterImageFilter::Create(colorFilter, drawPaint->getImageFil ter()); 44 SkColorFilterImageFilter::Create(colorFilter.get(), drawPaint->getIm ageFilter());
45 drawPaint->setImageFilter(imageFilter)->unref(); 45 drawPaint->setImageFilter(imageFilter)->unref();
46 } 46 }
47 47
48 static void no_detector_install(SkPaint*) { 48 static void no_detector_install(SkPaint*) {
49 } 49 }
50 50
51 typedef void(*InstallDetectorFunc)(SkPaint*); 51 typedef void(*InstallDetectorFunc)(SkPaint*);
52 52
53 53
54 // Draws an pattern that can be optimized by alpha folding outer savelayer alpha value to 54 // Draws an pattern that can be optimized by alpha folding outer savelayer alpha value to
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 207 }
208 208
209 canvas->restore(); 209 canvas->restore();
210 canvas->translate(SkIntToScalar(0), SkIntToScalar(kTestRectSize) + SkIntToScalar(1)); 210 canvas->translate(SkIntToScalar(0), SkIntToScalar(kTestRectSize) + SkIntToScalar(1));
211 } 211 }
212 212
213 } 213 }
214 } 214 }
215 } 215 }
216 216
OLDNEW
« no previous file with comments | « gm/multipicturedraw.cpp ('k') | gm/skbug1719.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698