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

Side by Side Diff: src/gpu/effects/GrConfigConversionEffect.cpp

Issue 956083002: Revert of Pass clip to context (Closed) Base URL: https://skia.googlesource.com/skia.git@pass_down_rendertarget
Patch Set: Created 5 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 | « src/gpu/SkGr.cpp ('k') | tests/ClipCacheTest.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 "GrConfigConversionEffect.h" 8 #include "GrConfigConversionEffect.h"
9 #include "GrContext.h" 9 #include "GrContext.h"
10 #include "GrInvariantOutput.h" 10 #include "GrInvariantOutput.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 SkAutoTUnref<GrTexture> dataTex(context->createTexture(desc, true, data, 0)) ; 198 SkAutoTUnref<GrTexture> dataTex(context->createTexture(desc, true, data, 0)) ;
199 if (!dataTex.get()) { 199 if (!dataTex.get()) {
200 return; 200 return;
201 } 201 }
202 202
203 static const PMConversion kConversionRules[][2] = { 203 static const PMConversion kConversionRules[][2] = {
204 {kDivByAlpha_RoundDown_PMConversion, kMulByAlpha_RoundUp_PMConversion}, 204 {kDivByAlpha_RoundDown_PMConversion, kMulByAlpha_RoundUp_PMConversion},
205 {kDivByAlpha_RoundUp_PMConversion, kMulByAlpha_RoundDown_PMConversion}, 205 {kDivByAlpha_RoundUp_PMConversion, kMulByAlpha_RoundDown_PMConversion},
206 }; 206 };
207 207
208 GrContext::AutoWideOpenIdentityDraw awoid(context);
209
208 bool failed = true; 210 bool failed = true;
209 211
210 for (size_t i = 0; i < SK_ARRAY_COUNT(kConversionRules) && failed; ++i) { 212 for (size_t i = 0; i < SK_ARRAY_COUNT(kConversionRules) && failed; ++i) {
211 *pmToUPMRule = kConversionRules[i][0]; 213 *pmToUPMRule = kConversionRules[i][0];
212 *upmToPMRule = kConversionRules[i][1]; 214 *upmToPMRule = kConversionRules[i][1];
213 215
214 static const SkRect kDstRect = SkRect::MakeWH(SkIntToScalar(256), SkIntT oScalar(256)); 216 static const SkRect kDstRect = SkRect::MakeWH(SkIntToScalar(256), SkIntT oScalar(256));
215 static const SkRect kSrcRect = SkRect::MakeWH(SK_Scalar1, SK_Scalar1); 217 static const SkRect kSrcRect = SkRect::MakeWH(SK_Scalar1, SK_Scalar1);
216 // We do a PM->UPM draw from dataTex to readTex and read the data. Then we do a UPM->PM draw 218 // We do a PM->UPM draw from dataTex to readTex and read the data. Then we do a UPM->PM draw
217 // from readTex to tempTex followed by a PM->UPM draw to readTex and fin ally read the data. 219 // from readTex to tempTex followed by a PM->UPM draw to readTex and fin ally read the data.
218 // We then verify that two reads produced the same values. 220 // We then verify that two reads produced the same values.
219 221
220 SkAutoTUnref<GrFragmentProcessor> pmToUPM1( 222 SkAutoTUnref<GrFragmentProcessor> pmToUPM1(
221 SkNEW_ARGS(GrConfigConversionEffect, 223 SkNEW_ARGS(GrConfigConversionEffect,
222 (dataTex, false, *pmToUPMRule, SkMatrix::I()))); 224 (dataTex, false, *pmToUPMRule, SkMatrix::I())));
223 SkAutoTUnref<GrFragmentProcessor> upmToPM( 225 SkAutoTUnref<GrFragmentProcessor> upmToPM(
224 SkNEW_ARGS(GrConfigConversionEffect, 226 SkNEW_ARGS(GrConfigConversionEffect,
225 (readTex, false, *upmToPMRule, SkMatrix::I()))); 227 (readTex, false, *upmToPMRule, SkMatrix::I())));
226 SkAutoTUnref<GrFragmentProcessor> pmToUPM2( 228 SkAutoTUnref<GrFragmentProcessor> pmToUPM2(
227 SkNEW_ARGS(GrConfigConversionEffect, 229 SkNEW_ARGS(GrConfigConversionEffect,
228 (tempTex, false, *pmToUPMRule, SkMatrix::I()))); 230 (tempTex, false, *pmToUPMRule, SkMatrix::I())));
229 231
230 GrPaint paint1; 232 GrPaint paint1;
231 paint1.addColorProcessor(pmToUPM1); 233 paint1.addColorProcessor(pmToUPM1);
232 context->drawNonAARectToRect(readTex->asRenderTarget(), 234 context->drawNonAARectToRect(readTex->asRenderTarget(), paint1, SkMatrix ::I(), kDstRect,
233 GrClip::WideOpen(),
234 paint1,
235 SkMatrix::I(),
236 kDstRect,
237 kSrcRect); 235 kSrcRect);
238 236
239 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead) ; 237 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead) ;
240 238
241 GrPaint paint2; 239 GrPaint paint2;
242 paint2.addColorProcessor(upmToPM); 240 paint2.addColorProcessor(upmToPM);
243 context->drawNonAARectToRect(tempTex->asRenderTarget(), 241 context->drawNonAARectToRect(tempTex->asRenderTarget(), paint2, SkMatrix ::I(), kDstRect,
244 GrClip::WideOpen(),
245 paint2,
246 SkMatrix::I(),
247 kDstRect,
248 kSrcRect); 242 kSrcRect);
249 243
250 GrPaint paint3; 244 GrPaint paint3;
251 paint3.addColorProcessor(pmToUPM2); 245 paint3.addColorProcessor(pmToUPM2);
252 context->drawNonAARectToRect(readTex->asRenderTarget(), 246 context->drawNonAARectToRect(readTex->asRenderTarget(), paint3, SkMatrix ::I(), kDstRect,
253 GrClip::WideOpen(),
254 paint3,
255 SkMatrix::I(),
256 kDstRect,
257 kSrcRect); 247 kSrcRect);
258 248
259 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead ); 249 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead );
260 250
261 failed = false; 251 failed = false;
262 for (int y = 0; y < 256 && !failed; ++y) { 252 for (int y = 0; y < 256 && !failed; ++y) {
263 for (int x = 0; x <= y; ++x) { 253 for (int x = 0; x <= y; ++x) {
264 if (firstRead[256 * y + x] != secondRead[256 * y + x]) { 254 if (firstRead[256 * y + x] != secondRead[256 * y + x]) {
265 failed = true; 255 failed = true;
266 break; 256 break;
(...skipping 22 matching lines...) Expand all
289 kNone_PMConversion != pmConversion) { 279 kNone_PMConversion != pmConversion) {
290 // The PM conversions assume colors are 0..255 280 // The PM conversions assume colors are 0..255
291 return NULL; 281 return NULL;
292 } 282 }
293 return SkNEW_ARGS(GrConfigConversionEffect, (texture, 283 return SkNEW_ARGS(GrConfigConversionEffect, (texture,
294 swapRedAndBlue, 284 swapRedAndBlue,
295 pmConversion, 285 pmConversion,
296 matrix)); 286 matrix));
297 } 287 }
298 } 288 }
OLDNEW
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | tests/ClipCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698