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

Side by Side Diff: src/effects/SkDisplacementMapEffect.cpp

Issue 656503002: Move willUseInputColor check to computeInvariantOutput (Closed) Base URL: https://skia.googlesource.com/skia.git@addMultFlag
Patch Set: Rebase2 Created 6 years, 2 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/effects/SkColorMatrixFilter.cpp ('k') | src/effects/SkLumaColorFilter.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 2013 Google Inc. 2 * Copyright 2013 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 "SkDisplacementMapEffect.h" 8 #include "SkDisplacementMapEffect.h"
9 #include "SkReadBuffer.h" 9 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h" 10 #include "SkWriteBuffer.h"
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 , fDisplacementAccess(displacement) 466 , fDisplacementAccess(displacement)
467 , fColorTransform(kLocal_GrCoordSet, color) 467 , fColorTransform(kLocal_GrCoordSet, color)
468 , fColorAccess(color) 468 , fColorAccess(color)
469 , fXChannelSelector(xChannelSelector) 469 , fXChannelSelector(xChannelSelector)
470 , fYChannelSelector(yChannelSelector) 470 , fYChannelSelector(yChannelSelector)
471 , fScale(scale) { 471 , fScale(scale) {
472 this->addCoordTransform(&fDisplacementTransform); 472 this->addCoordTransform(&fDisplacementTransform);
473 this->addTextureAccess(&fDisplacementAccess); 473 this->addTextureAccess(&fDisplacementAccess);
474 this->addCoordTransform(&fColorTransform); 474 this->addCoordTransform(&fColorTransform);
475 this->addTextureAccess(&fColorAccess); 475 this->addTextureAccess(&fColorAccess);
476 this->setWillNotUseInputColor();
477 } 476 }
478 477
479 GrDisplacementMapEffect::~GrDisplacementMapEffect() { 478 GrDisplacementMapEffect::~GrDisplacementMapEffect() {
480 } 479 }
481 480
482 bool GrDisplacementMapEffect::onIsEqual(const GrFragmentProcessor& sBase) const { 481 bool GrDisplacementMapEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
483 const GrDisplacementMapEffect& s = sBase.cast<GrDisplacementMapEffect>(); 482 const GrDisplacementMapEffect& s = sBase.cast<GrDisplacementMapEffect>();
484 return fDisplacementAccess.getTexture() == s.fDisplacementAccess.getTexture( ) && 483 return fDisplacementAccess.getTexture() == s.fDisplacementAccess.getTexture( ) &&
485 fColorAccess.getTexture() == s.fColorAccess.getTexture() && 484 fColorAccess.getTexture() == s.fColorAccess.getTexture() &&
486 fXChannelSelector == s.fXChannelSelector && 485 fXChannelSelector == s.fXChannelSelector &&
487 fYChannelSelector == s.fYChannelSelector && 486 fYChannelSelector == s.fYChannelSelector &&
488 fScale == s.fScale; 487 fScale == s.fScale;
489 } 488 }
490 489
491 const GrBackendFragmentProcessorFactory& GrDisplacementMapEffect::getFactory() c onst { 490 const GrBackendFragmentProcessorFactory& GrDisplacementMapEffect::getFactory() c onst {
492 return GrTBackendFragmentProcessorFactory<GrDisplacementMapEffect>::getInsta nce(); 491 return GrTBackendFragmentProcessorFactory<GrDisplacementMapEffect>::getInsta nce();
493 } 492 }
494 493
495 void GrDisplacementMapEffect::onComputeInvariantOutput(InvariantOutput* inout) c onst { 494 void GrDisplacementMapEffect::onComputeInvariantOutput(InvariantOutput* inout) c onst {
496 // Any displacement offset bringing a pixel out of bounds will output a colo r of (0,0,0,0), 495 // Any displacement offset bringing a pixel out of bounds will output a colo r of (0,0,0,0),
497 // so the only way we'd get a constant alpha is if the input color image has a constant alpha 496 // so the only way we'd get a constant alpha is if the input color image has a constant alpha
498 // and no displacement offset push any texture coordinates out of bounds OR if the constant 497 // and no displacement offset push any texture coordinates out of bounds OR if the constant
499 // alpha is 0. Since this isn't trivial to compute at this point, let's assu me the output is 498 // alpha is 0. Since this isn't trivial to compute at this point, let's assu me the output is
500 // not of constant color when a displacement effect is applied. 499 // not of constant color when a displacement effect is applied.
501 inout->setToUnknown(); 500 inout->setToUnknown(InvariantOutput::kWillNot_ReadInput);
502 } 501 }
503 502
504 /////////////////////////////////////////////////////////////////////////////// 503 ///////////////////////////////////////////////////////////////////////////////
505 504
506 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect); 505 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect);
507 506
508 GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(SkRandom* random, 507 GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(SkRandom* random,
509 GrContext*, 508 GrContext*,
510 const GrDrawTargetCaps&, 509 const GrDrawTargetCaps&,
511 GrTexture* textures[]) { 510 GrTexture* textures[]) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, 631 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc,
633 const GrGLCaps&, GrProcessorKeyBuilder* b ) { 632 const GrGLCaps&, GrProcessorKeyBuilder* b ) {
634 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); 633 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>();
635 634
636 uint32_t xKey = displacementMap.xChannelSelector(); 635 uint32_t xKey = displacementMap.xChannelSelector();
637 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; 636 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s;
638 637
639 b->add32(xKey | yKey); 638 b->add32(xKey | yKey);
640 } 639 }
641 #endif 640 #endif
OLDNEW
« no previous file with comments | « src/effects/SkColorMatrixFilter.cpp ('k') | src/effects/SkLumaColorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698