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

Side by Side Diff: src/gpu/GrDrawState.cpp

Issue 787233003: Add XP to handle the cases where we disable color write. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 6 years 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/GrDrawState.h ('k') | src/gpu/GrOptDrawState.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 "GrDrawState.h" 8 #include "GrDrawState.h"
9 9
10 #include "GrBlend.h" 10 #include "GrBlend.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if (caps.dualSourceBlendingSupport()) { 177 if (caps.dualSourceBlendingSupport()) {
178 return true; 178 return true;
179 } 179 }
180 180
181 this->calcColorInvariantOutput(color); 181 this->calcColorInvariantOutput(color);
182 182
183 // The coverage isn't actually white, its unknown, but this will produce the same effect 183 // The coverage isn't actually white, its unknown, but this will produce the same effect
184 // TODO we want to cache the result of this call, but we can probably clean up the interface 184 // TODO we want to cache the result of this call, but we can probably clean up the interface
185 // so we don't have to pass in a seemingly known coverage 185 // so we don't have to pass in a seemingly known coverage
186 this->calcCoverageInvariantOutput(GrColor_WHITE); 186 this->calcCoverageInvariantOutput(GrColor_WHITE);
187 return fXPFactory->canApplyCoverage(fColorProcInfo, fCoverageProcInfo, 187 return fXPFactory->canApplyCoverage(fColorProcInfo, fCoverageProcInfo);
188 this->isColorWriteDisabled());
189 } 188 }
190 189
191 //////////////////////////////////////////////////////////////////////////////s 190 //////////////////////////////////////////////////////////////////////////////s
192 191
193 bool GrDrawState::willEffectReadDstColor(const GrPrimitiveProcessor* pp) const { 192 bool GrDrawState::willEffectReadDstColor(const GrPrimitiveProcessor* pp) const {
194 this->calcColorInvariantOutput(pp); 193 this->calcColorInvariantOutput(pp);
195 this->calcCoverageInvariantOutput(pp); 194 this->calcCoverageInvariantOutput(pp);
196 // TODO: Remove need to create the XP here.
197 // Also once all custom blends are turned into XPs we can remove the n eed
198 // to check other stages since only xp's will be able to read dst
199 SkAutoTUnref<GrXferProcessor> xferProcessor(fXPFactory->createXferProcessor( fColorProcInfo,
200 fCoverageProcInfo));
201 if (xferProcessor && xferProcessor->willReadDstColor()) {
202 return true;
203 }
204 195
205 if (!this->isColorWriteDisabled()) { 196 return fXPFactory->willReadDst(fColorProcInfo, fCoverageProcInfo);
206 if (fColorProcInfo.readsDst()) {
207 return true;
208 }
209 }
210 return fCoverageProcInfo.readsDst();
211 } 197 }
212 198
213 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) { 199 void GrDrawState::AutoRestoreEffects::set(GrDrawState* ds) {
214 if (fDrawState) { 200 if (fDrawState) {
215 int m = fDrawState->numColorStages() - fColorEffectCnt; 201 int m = fDrawState->numColorStages() - fColorEffectCnt;
216 SkASSERT(m >= 0); 202 SkASSERT(m >= 0);
217 fDrawState->fColorStages.pop_back_n(m); 203 fDrawState->fColorStages.pop_back_n(m);
218 204
219 int n = fDrawState->numCoverageStages() - fCoverageEffectCnt; 205 int n = fDrawState->numCoverageStages() - fCoverageEffectCnt;
220 SkASSERT(n >= 0); 206 SkASSERT(n >= 0);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 SkASSERT(0 == fBlockEffectRemovalCnt); 320 SkASSERT(0 == fBlockEffectRemovalCnt);
335 } 321 }
336 322
337 //////////////////////////////////////////////////////////////////////////////// 323 ////////////////////////////////////////////////////////////////////////////////
338 324
339 bool GrDrawState::willBlendWithDst(const GrPrimitiveProcessor* pp) const { 325 bool GrDrawState::willBlendWithDst(const GrPrimitiveProcessor* pp) const {
340 this->calcColorInvariantOutput(pp); 326 this->calcColorInvariantOutput(pp);
341 this->calcCoverageInvariantOutput(pp); 327 this->calcCoverageInvariantOutput(pp);
342 328
343 GrXPFactory::InvariantOutput output; 329 GrXPFactory::InvariantOutput output;
344 fXPFactory->getInvariantOutput(fColorProcInfo, fCoverageProcInfo, this->isCo lorWriteDisabled(), 330 fXPFactory->getInvariantOutput(fColorProcInfo, fCoverageProcInfo, &output);
345 &output);
346 return output.fWillBlendWithDst; 331 return output.fWillBlendWithDst;
347 } 332 }
348 333
349 void GrDrawState::calcColorInvariantOutput(const GrPrimitiveProcessor* pp) const { 334 void GrDrawState::calcColorInvariantOutput(const GrPrimitiveProcessor* pp) const {
350 if (!fColorProcInfoValid || fColorPrimProc != pp) { 335 if (!fColorProcInfoValid || fColorPrimProc != pp) {
351 fColorProcInfo.calcColorWithPrimProc(pp, fColorStages.begin(), this->num ColorStages()); 336 fColorProcInfo.calcColorWithPrimProc(pp, fColorStages.begin(), this->num ColorStages());
352 fColorProcInfoValid = true; 337 fColorProcInfoValid = true;
353 fColorPrimProc = pp; 338 fColorPrimProc = pp;
354 } 339 }
355 } 340 }
(...skipping 20 matching lines...) Expand all
376 void GrDrawState::calcCoverageInvariantOutput(GrColor coverage) const { 361 void GrDrawState::calcCoverageInvariantOutput(GrColor coverage) const {
377 if (!fCoverageProcInfoValid || coverage != fCoverageCache) { 362 if (!fCoverageProcInfoValid || coverage != fCoverageCache) {
378 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags; 363 GrColorComponentFlags flags = kRGBA_GrColorComponentFlags;
379 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(), 364 fCoverageProcInfo.calcWithInitialValues(fCoverageStages.begin(),
380 this->numCoverageStages(), cover age, flags, 365 this->numCoverageStages(), cover age, flags,
381 true); 366 true);
382 fCoverageProcInfoValid = true; 367 fCoverageProcInfoValid = true;
383 fCoverageCache = coverage; 368 fCoverageCache = coverage;
384 } 369 }
385 } 370 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrOptDrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698