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

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

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 5 years, 5 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 "GrDrawContext.h" 10 #include "GrDrawContext.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 return; 201 return;
202 } 202 }
203 203
204 static const PMConversion kConversionRules[][2] = { 204 static const PMConversion kConversionRules[][2] = {
205 {kDivByAlpha_RoundDown_PMConversion, kMulByAlpha_RoundUp_PMConversion}, 205 {kDivByAlpha_RoundDown_PMConversion, kMulByAlpha_RoundUp_PMConversion},
206 {kDivByAlpha_RoundUp_PMConversion, kMulByAlpha_RoundDown_PMConversion}, 206 {kDivByAlpha_RoundUp_PMConversion, kMulByAlpha_RoundDown_PMConversion},
207 }; 207 };
208 208
209 bool failed = true; 209 bool failed = true;
210 210
211 GrDrawContext* drawContext = context->drawContext();
212 if (!drawContext) {
213 return;
214 }
215
216 for (size_t i = 0; i < SK_ARRAY_COUNT(kConversionRules) && failed; ++i) { 211 for (size_t i = 0; i < SK_ARRAY_COUNT(kConversionRules) && failed; ++i) {
217 *pmToUPMRule = kConversionRules[i][0]; 212 *pmToUPMRule = kConversionRules[i][0];
218 *upmToPMRule = kConversionRules[i][1]; 213 *upmToPMRule = kConversionRules[i][1];
219 214
220 static const SkRect kDstRect = SkRect::MakeWH(SkIntToScalar(256), SkIntT oScalar(256)); 215 static const SkRect kDstRect = SkRect::MakeWH(SkIntToScalar(256), SkIntT oScalar(256));
221 static const SkRect kSrcRect = SkRect::MakeWH(SK_Scalar1, SK_Scalar1); 216 static const SkRect kSrcRect = SkRect::MakeWH(SK_Scalar1, SK_Scalar1);
222 // We do a PM->UPM draw from dataTex to readTex and read the data. Then we do a UPM->PM draw 217 // We do a PM->UPM draw from dataTex to readTex and read the data. Then we do a UPM->PM draw
223 // from readTex to tempTex followed by a PM->UPM draw to readTex and fin ally read the data. 218 // from readTex to tempTex followed by a PM->UPM draw to readTex and fin ally read the data.
224 // We then verify that two reads produced the same values. 219 // We then verify that two reads produced the same values.
225 220
226 SkAutoTUnref<GrFragmentProcessor> pmToUPM1( 221 SkAutoTUnref<GrFragmentProcessor> pmToUPM1(
227 SkNEW_ARGS(GrConfigConversionEffect, 222 SkNEW_ARGS(GrConfigConversionEffect,
228 (dataTex, false, *pmToUPMRule, SkMatrix::I()))); 223 (dataTex, false, *pmToUPMRule, SkMatrix::I())));
229 SkAutoTUnref<GrFragmentProcessor> upmToPM( 224 SkAutoTUnref<GrFragmentProcessor> upmToPM(
230 SkNEW_ARGS(GrConfigConversionEffect, 225 SkNEW_ARGS(GrConfigConversionEffect,
231 (readTex, false, *upmToPMRule, SkMatrix::I()))); 226 (readTex, false, *upmToPMRule, SkMatrix::I())));
232 SkAutoTUnref<GrFragmentProcessor> pmToUPM2( 227 SkAutoTUnref<GrFragmentProcessor> pmToUPM2(
233 SkNEW_ARGS(GrConfigConversionEffect, 228 SkNEW_ARGS(GrConfigConversionEffect,
234 (tempTex, false, *pmToUPMRule, SkMatrix::I()))); 229 (tempTex, false, *pmToUPMRule, SkMatrix::I())));
235 230
236 GrPaint paint1; 231 GrPaint paint1;
237 paint1.addColorProcessor(pmToUPM1); 232 paint1.addColorProcessor(pmToUPM1);
238 drawContext->drawNonAARectToRect(readTex->asRenderTarget(), 233
239 GrClip::WideOpen(), 234
240 paint1, 235 GrDrawContext* readDrawContext = context->drawContext(readTex->asRenderT arget());
241 SkMatrix::I(), 236 if (!readDrawContext) {
242 kDstRect, 237 failed = true;
243 kSrcRect); 238 break;
239 }
240 readDrawContext->uses(dataTex);
241
242 readDrawContext->drawNonAARectToRect(readTex->asRenderTarget(),
243 GrClip::WideOpen(),
244 paint1,
245 SkMatrix::I(),
246 kDstRect,
247 kSrcRect);
244 248
245 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead) ; 249 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead) ;
246 250
247 GrPaint paint2; 251 GrPaint paint2;
248 paint2.addColorProcessor(upmToPM); 252 paint2.addColorProcessor(upmToPM);
249 drawContext->drawNonAARectToRect(tempTex->asRenderTarget(), 253
250 GrClip::WideOpen(), 254 GrDrawContext* tempDrawContext = context->drawContext(tempTex->asRenderT arget());
251 paint2, 255 if (!tempDrawContext) {
252 SkMatrix::I(), 256 failed = true;
253 kDstRect, 257 break;
254 kSrcRect); 258 }
259 tempDrawContext->uses(readDrawContext);
260
261 tempDrawContext->drawNonAARectToRect(tempTex->asRenderTarget(),
262 GrClip::WideOpen(),
263 paint2,
264 SkMatrix::I(),
265 kDstRect,
266 kSrcRect);
255 267
256 GrPaint paint3; 268 GrPaint paint3;
257 paint3.addColorProcessor(pmToUPM2); 269 paint3.addColorProcessor(pmToUPM2);
258 drawContext->drawNonAARectToRect(readTex->asRenderTarget(), 270
259 GrClip::WideOpen(), 271 readDrawContext = context->drawContext(readTex->asRenderTarget());
260 paint3, 272 if (!readDrawContext) {
261 SkMatrix::I(), 273 failed = true;
262 kDstRect, 274 break;
263 kSrcRect); 275 }
276 readDrawContext->uses(tempDrawContext);
277
278 readDrawContext->drawNonAARectToRect(readTex->asRenderTarget(),
279 GrClip::WideOpen(),
280 paint3,
281 SkMatrix::I(),
282 kDstRect,
283 kSrcRect);
264 284
265 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead ); 285 readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead );
266 286
267 failed = false; 287 failed = false;
268 for (int y = 0; y < 256 && !failed; ++y) { 288 for (int y = 0; y < 256 && !failed; ++y) {
269 for (int x = 0; x <= y; ++x) { 289 for (int x = 0; x <= y; ++x) {
270 if (firstRead[256 * y + x] != secondRead[256 * y + x]) { 290 if (firstRead[256 * y + x] != secondRead[256 * y + x]) {
271 failed = true; 291 failed = true;
272 break; 292 break;
273 } 293 }
(...skipping 21 matching lines...) Expand all
295 kNone_PMConversion != pmConversion) { 315 kNone_PMConversion != pmConversion) {
296 // The PM conversions assume colors are 0..255 316 // The PM conversions assume colors are 0..255
297 return NULL; 317 return NULL;
298 } 318 }
299 return SkNEW_ARGS(GrConfigConversionEffect, (texture, 319 return SkNEW_ARGS(GrConfigConversionEffect, (texture,
300 swapRedAndBlue, 320 swapRedAndBlue,
301 pmConversion, 321 pmConversion,
302 matrix)); 322 matrix));
303 } 323 }
304 } 324 }
OLDNEW
« include/gpu/GrDrawContext.h ('K') | « src/gpu/SkGr.cpp ('k') | src/image/SkImage_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698