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

Side by Side Diff: gm/lighting.cpp

Issue 1057693002: Revert of Implement approx-match support in image filter saveLayer() offscreen. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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 | src/core/SkCanvas.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 2012 Google Inc. 2 * Copyright 2012 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 "SkLightingImageFilter.h" 9 #include "SkLightingImageFilter.h"
10 #include "SkOffsetImageFilter.h"
11 10
12 #define WIDTH 330 11 #define WIDTH 330
13 #define HEIGHT 660 12 #define HEIGHT 440
14 13
15 namespace skiagm { 14 namespace skiagm {
16 15
17 class ImageLightingGM : public GM { 16 class ImageLightingGM : public GM {
18 public: 17 public:
19 ImageLightingGM() : fInitialized(false) { 18 ImageLightingGM() : fInitialized(false) {
20 this->setBGColor(0xFF000000); 19 this->setBGColor(0xFF000000);
21 } 20 }
22 21
23 protected: 22 protected:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 SkScalar spotExponent = SK_Scalar1; 79 SkScalar spotExponent = SK_Scalar1;
81 SkScalar cutoffAngle = SkIntToScalar(15); 80 SkScalar cutoffAngle = SkIntToScalar(15);
82 SkScalar kd = SkIntToScalar(2); 81 SkScalar kd = SkIntToScalar(2);
83 SkScalar ks = SkIntToScalar(1); 82 SkScalar ks = SkIntToScalar(1);
84 SkScalar shininess = SkIntToScalar(8); 83 SkScalar shininess = SkIntToScalar(8);
85 SkScalar surfaceScale = SkIntToScalar(1); 84 SkScalar surfaceScale = SkIntToScalar(1);
86 SkColor white(0xFFFFFFFF); 85 SkColor white(0xFFFFFFFF);
87 SkPaint paint; 86 SkPaint paint;
88 87
89 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65)); 88 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 10, 60, 65));
90 SkImageFilter::CropRect fullSizeCropRect(SkRect::MakeXYWH(0, 0, 100, 100 ));
91 SkAutoTUnref<SkImageFilter> noopCropped(SkOffsetImageFilter::Create(0, 0 , NULL, &cropRect));
92 89
93 int y = 0; 90 int y = 0;
94 for (int i = 0; i < 3; i++) { 91 for (int i = 0; i < 2; i++) {
95 const SkImageFilter::CropRect* cr = (i == 1) ? &cropRect : (i == 2) ? &fullSizeCropRect : NULL; 92 const SkImageFilter::CropRect* cr = (i == 0) ? NULL : &cropRect;
96 SkImageFilter* input = (i == 2) ? noopCropped.get() : NULL; 93 paint.setImageFilter(SkLightingImageFilter::CreatePointLitDiffuse(po intLocation, white, surfaceScale, kd, NULL, cr))->unref();
97 paint.setImageFilter(SkLightingImageFilter::CreatePointLitDiffuse(po intLocation,
98 wh ite,
99 su rfaceScale,
100 kd ,
101 in put,
102 cr ))->unref();
103 drawClippedBitmap(canvas, paint, 0, y); 94 drawClippedBitmap(canvas, paint, 0, y);
104 95
105 paint.setImageFilter(SkLightingImageFilter::CreateDistantLitDiffuse( distantDirection, 96 paint.setImageFilter(SkLightingImageFilter::CreateDistantLitDiffuse( distantDirection, white, surfaceScale, kd, NULL, cr))->unref();
106 white,
107 surfaceScale,
108 kd,
109 input,
110 cr))->unref();
111 drawClippedBitmap(canvas, paint, 110, y); 97 drawClippedBitmap(canvas, paint, 110, y);
112 98
113 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitDiffuse(spo tLocation, 99 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitDiffuse(spo tLocation, spotTarget, spotExponent, cutoffAngle, white, surfaceScale, kd, NULL, cr))->unref();
114 spo tTarget,
115 spo tExponent,
116 cut offAngle,
117 whi te,
118 sur faceScale,
119 kd,
120 inp ut,
121 cr) )->unref();
122 drawClippedBitmap(canvas, paint, 220, y); 100 drawClippedBitmap(canvas, paint, 220, y);
123 101
124 y += 110; 102 y += 110;
125 103
126 paint.setImageFilter(SkLightingImageFilter::CreatePointLitSpecular(p ointLocation, 104 paint.setImageFilter(SkLightingImageFilter::CreatePointLitSpecular(p ointLocation, white, surfaceScale, ks, shininess, NULL, cr))->unref();
127 w hite,
128 s urfaceScale,
129 k s,
130 s hininess,
131 i nput,
132 c r))->unref();
133 drawClippedBitmap(canvas, paint, 0, y); 105 drawClippedBitmap(canvas, paint, 0, y);
134 106
135 paint.setImageFilter(SkLightingImageFilter::CreateDistantLitSpecular (distantDirection, 107 paint.setImageFilter(SkLightingImageFilter::CreateDistantLitSpecular (distantDirection, white, surfaceScale, ks, shininess, NULL, cr))->unref();
136 white,
137 surfaceScale,
138 ks,
139 shininess,
140 input,
141 cr))->unref();
142 drawClippedBitmap(canvas, paint, 110, y); 108 drawClippedBitmap(canvas, paint, 110, y);
143 109
144 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular(sp otLocation, 110 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular(sp otLocation, spotTarget, spotExponent, cutoffAngle, white, surfaceScale, ks, shin iness, NULL, cr))->unref();
145 sp otTarget,
146 sp otExponent,
147 cu toffAngle,
148 wh ite,
149 su rfaceScale,
150 ks ,
151 sh ininess,
152 in put,
153 cr ))->unref();
154 drawClippedBitmap(canvas, paint, 220, y); 111 drawClippedBitmap(canvas, paint, 220, y);
155 112
156 y += 110; 113 y += 110;
157 } 114 }
158 } 115 }
159 116
160 private: 117 private:
161 typedef GM INHERITED; 118 typedef GM INHERITED;
162 SkBitmap fBitmap; 119 SkBitmap fBitmap;
163 bool fInitialized; 120 bool fInitialized;
164 }; 121 };
165 122
166 ////////////////////////////////////////////////////////////////////////////// 123 //////////////////////////////////////////////////////////////////////////////
167 124
168 static GM* MyFactory(void*) { return new ImageLightingGM; } 125 static GM* MyFactory(void*) { return new ImageLightingGM; }
169 static GMRegistry reg(MyFactory); 126 static GMRegistry reg(MyFactory);
170 127
171 } 128 }
OLDNEW
« no previous file with comments | « no previous file | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698