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

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

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

Powered by Google App Engine
This is Rietveld 408576698