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

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

Issue 2215323003: Start using RenderTargetProxy (omnibus) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 4 years, 1 month 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/effects/GrConfigConversionEffect.h ('k') | src/gpu/effects/GrConvolutionEffect.h » ('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 "GrRenderTargetContext.h" 10 #include "GrRenderTargetContext.h"
11 #include "GrInvariantOutput.h" 11 #include "GrInvariantOutput.h"
12 #include "GrSimpleTextureEffect.h" 12 #include "GrSimpleTextureEffect.h"
13 #include "GrTextureProxy.h"
13 #include "SkMatrix.h" 14 #include "SkMatrix.h"
14 #include "glsl/GrGLSLFragmentProcessor.h" 15 #include "glsl/GrGLSLFragmentProcessor.h"
15 #include "glsl/GrGLSLFragmentShaderBuilder.h" 16 #include "glsl/GrGLSLFragmentShaderBuilder.h"
16 17
17 class GrGLConfigConversionEffect : public GrGLSLFragmentProcessor { 18 class GrGLConfigConversionEffect : public GrGLSLFragmentProcessor {
18 public: 19 public:
19 void emitCode(EmitArgs& args) override { 20 void emitCode(EmitArgs& args) override {
20 const GrConfigConversionEffect& cce = args.fFp.cast<GrConfigConversionEf fect>(); 21 const GrConfigConversionEffect& cce = args.fFp.cast<GrConfigConversionEf fect>();
21 const GrSwizzle& swizzle = cce.swizzle(); 22 const GrSwizzle& swizzle = cce.swizzle();
22 GrConfigConversionEffect::PMConversion pmConversion = cce.pmConversion() ; 23 GrConfigConversionEffect::PMConversion pmConversion = cce.pmConversion() ;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // We do a PM->UPM draw from dataTex to readTex and read the data. Then we do a UPM->PM draw 220 // We do a PM->UPM draw from dataTex to readTex and read the data. Then we do a UPM->PM draw
220 // from readTex to tempTex followed by a PM->UPM draw to readTex and fin ally read the data. 221 // from readTex to tempTex followed by a PM->UPM draw to readTex and fin ally read the data.
221 // We then verify that two reads produced the same values. 222 // We then verify that two reads produced the same values.
222 223
223 GrPaint paint1; 224 GrPaint paint1;
224 GrPaint paint2; 225 GrPaint paint2;
225 GrPaint paint3; 226 GrPaint paint3;
226 sk_sp<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect( 227 sk_sp<GrFragmentProcessor> pmToUPM1(new GrConfigConversionEffect(
227 dataTex.get(), GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I())); 228 dataTex.get(), GrSwizzle::RGBA(), *pmToUPMRule, SkMatrix::I()));
228 sk_sp<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect( 229 sk_sp<GrFragmentProcessor> upmToPM(new GrConfigConversionEffect(
229 readRTC->asTexture().get(), GrSwizzle::RGBA(), *upmToPMRule, SkM atrix::I())); 230 readRTC->asDeferredTexture(), GrSwizzle::RGBA(), *upmToPMRule, S kMatrix::I()));
230 sk_sp<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect( 231 sk_sp<GrFragmentProcessor> pmToUPM2(new GrConfigConversionEffect(
231 tempRTC->asTexture().get(), GrSwizzle::RGBA(), *pmToUPMRule, SkM atrix::I())); 232 tempRTC->asDeferredTexture(), GrSwizzle::RGBA(), *pmToUPMRule, S kMatrix::I()));
232 233
233 paint1.addColorFragmentProcessor(std::move(pmToUPM1)); 234 paint1.addColorFragmentProcessor(std::move(pmToUPM1));
234 paint1.setPorterDuffXPFactory(SkBlendMode::kSrc); 235 paint1.setPorterDuffXPFactory(SkBlendMode::kSrc);
235 236
236 readRTC->fillRectToRect(GrNoClip(), paint1, SkMatrix::I(), kDstRect, kSr cRect); 237 readRTC->fillRectToRect(GrNoClip(), paint1, SkMatrix::I(), kDstRect, kSr cRect);
237 238
238 readRTC->asTexture()->readPixels(0, 0, kSize, kSize, kConfig, firstRead) ; 239 readRTC->asDeferredTexture()->readPixels(0, 0, kSize, kSize, kConfig, fi rstRead);
239 240
240 paint2.addColorFragmentProcessor(std::move(upmToPM)); 241 paint2.addColorFragmentProcessor(std::move(upmToPM));
241 paint2.setPorterDuffXPFactory(SkBlendMode::kSrc); 242 paint2.setPorterDuffXPFactory(SkBlendMode::kSrc);
242 243
243 tempRTC->fillRectToRect(GrNoClip(), paint2, SkMatrix::I(), kDstRect, kSr cRect); 244 tempRTC->fillRectToRect(GrNoClip(), paint2, SkMatrix::I(), kDstRect, kSr cRect);
244 245
245 paint3.addColorFragmentProcessor(std::move(pmToUPM2)); 246 paint3.addColorFragmentProcessor(std::move(pmToUPM2));
246 paint3.setPorterDuffXPFactory(SkBlendMode::kSrc); 247 paint3.setPorterDuffXPFactory(SkBlendMode::kSrc);
247 248
248 readRTC->fillRectToRect(GrNoClip(), paint3, SkMatrix::I(), kDstRect, kSr cRect); 249 readRTC->fillRectToRect(GrNoClip(), paint3, SkMatrix::I(), kDstRect, kSr cRect);
249 250
250 readRTC->asTexture()->readPixels(0, 0, kSize, kSize, kConfig, secondRead ); 251 readRTC->asDeferredTexture()->readPixels(0, 0, kSize, kSize, kConfig, se condRead);
251 252
252 failed = false; 253 failed = false;
253 for (int y = 0; y < kSize && !failed; ++y) { 254 for (int y = 0; y < kSize && !failed; ++y) {
254 for (int x = 0; x <= y; ++x) { 255 for (int x = 0; x <= y; ++x) {
255 if (firstRead[kSize * y + x] != secondRead[kSize * y + x]) { 256 if (firstRead[kSize * y + x] != secondRead[kSize * y + x]) {
256 failed = true; 257 failed = true;
257 break; 258 break;
258 } 259 }
259 } 260 }
260 } 261 }
(...skipping 17 matching lines...) Expand all
278 if (kRGBA_8888_GrPixelConfig != texture->config() && 279 if (kRGBA_8888_GrPixelConfig != texture->config() &&
279 kBGRA_8888_GrPixelConfig != texture->config() && 280 kBGRA_8888_GrPixelConfig != texture->config() &&
280 kNone_PMConversion != pmConversion) { 281 kNone_PMConversion != pmConversion) {
281 // The PM conversions assume colors are 0..255 282 // The PM conversions assume colors are 0..255
282 return nullptr; 283 return nullptr;
283 } 284 }
284 return sk_sp<GrFragmentProcessor>( 285 return sk_sp<GrFragmentProcessor>(
285 new GrConfigConversionEffect(texture, swizzle, pmConversion, matrix) ); 286 new GrConfigConversionEffect(texture, swizzle, pmConversion, matrix) );
286 } 287 }
287 } 288 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConfigConversionEffect.h ('k') | src/gpu/effects/GrConvolutionEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698