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

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: Update InvariantOutput validate 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
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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 , fDisplacementAccess(displacement) 465 , fDisplacementAccess(displacement)
466 , fColorTransform(kLocal_GrCoordSet, color) 466 , fColorTransform(kLocal_GrCoordSet, color)
467 , fColorAccess(color) 467 , fColorAccess(color)
468 , fXChannelSelector(xChannelSelector) 468 , fXChannelSelector(xChannelSelector)
469 , fYChannelSelector(yChannelSelector) 469 , fYChannelSelector(yChannelSelector)
470 , fScale(scale) { 470 , fScale(scale) {
471 this->addCoordTransform(&fDisplacementTransform); 471 this->addCoordTransform(&fDisplacementTransform);
472 this->addTextureAccess(&fDisplacementAccess); 472 this->addTextureAccess(&fDisplacementAccess);
473 this->addCoordTransform(&fColorTransform); 473 this->addCoordTransform(&fColorTransform);
474 this->addTextureAccess(&fColorAccess); 474 this->addTextureAccess(&fColorAccess);
475 this->setWillNotUseInputColor();
476 } 475 }
477 476
478 GrDisplacementMapEffect::~GrDisplacementMapEffect() { 477 GrDisplacementMapEffect::~GrDisplacementMapEffect() {
479 } 478 }
480 479
481 bool GrDisplacementMapEffect::onIsEqual(const GrProcessor& sBase) const { 480 bool GrDisplacementMapEffect::onIsEqual(const GrProcessor& sBase) const {
482 const GrDisplacementMapEffect& s = sBase.cast<GrDisplacementMapEffect>(); 481 const GrDisplacementMapEffect& s = sBase.cast<GrDisplacementMapEffect>();
483 return fDisplacementAccess.getTexture() == s.fDisplacementAccess.getTexture( ) && 482 return fDisplacementAccess.getTexture() == s.fDisplacementAccess.getTexture( ) &&
484 fColorAccess.getTexture() == s.fColorAccess.getTexture() && 483 fColorAccess.getTexture() == s.fColorAccess.getTexture() &&
485 fXChannelSelector == s.fXChannelSelector && 484 fXChannelSelector == s.fXChannelSelector &&
486 fYChannelSelector == s.fYChannelSelector && 485 fYChannelSelector == s.fYChannelSelector &&
487 fScale == s.fScale; 486 fScale == s.fScale;
488 } 487 }
489 488
490 const GrBackendFragmentProcessorFactory& GrDisplacementMapEffect::getFactory() c onst { 489 const GrBackendFragmentProcessorFactory& GrDisplacementMapEffect::getFactory() c onst {
491 return GrTBackendFragmentProcessorFactory<GrDisplacementMapEffect>::getInsta nce(); 490 return GrTBackendFragmentProcessorFactory<GrDisplacementMapEffect>::getInsta nce();
492 } 491 }
493 492
494 void GrDisplacementMapEffect::onComputeInvariantOutput(InvariantOutput* inout) c onst { 493 void GrDisplacementMapEffect::onComputeInvariantOutput(InvariantOutput* inout) c onst {
495 // Any displacement offset bringing a pixel out of bounds will output a colo r of (0,0,0,0), 494 // Any displacement offset bringing a pixel out of bounds will output a colo r of (0,0,0,0),
496 // so the only way we'd get a constant alpha is if the input color image has a constant alpha 495 // so the only way we'd get a constant alpha is if the input color image has a constant alpha
497 // and no displacement offset push any texture coordinates out of bounds OR if the constant 496 // and no displacement offset push any texture coordinates out of bounds OR if the constant
498 // alpha is 0. Since this isn't trivial to compute at this point, let's assu me the output is 497 // alpha is 0. Since this isn't trivial to compute at this point, let's assu me the output is
499 // not of constant color when a displacement effect is applied. 498 // not of constant color when a displacement effect is applied.
500 inout->setToUnknown(); 499 inout->setToUnknown();
500 inout->setWillNotUseInputColor();
501 } 501 }
502 502
503 /////////////////////////////////////////////////////////////////////////////// 503 ///////////////////////////////////////////////////////////////////////////////
504 504
505 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect); 505 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect);
506 506
507 GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(SkRandom* random, 507 GrFragmentProcessor* GrDisplacementMapEffect::TestCreate(SkRandom* random,
508 GrContext*, 508 GrContext*,
509 const GrDrawTargetCaps&, 509 const GrDrawTargetCaps&,
510 GrTexture* textures[]) { 510 GrTexture* textures[]) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc, 631 void GrGLDisplacementMapEffect::GenKey(const GrProcessor& proc,
632 const GrGLCaps&, GrProcessorKeyBuilder* b ) { 632 const GrGLCaps&, GrProcessorKeyBuilder* b ) {
633 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>(); 633 const GrDisplacementMapEffect& displacementMap = proc.cast<GrDisplacementMap Effect>();
634 634
635 uint32_t xKey = displacementMap.xChannelSelector(); 635 uint32_t xKey = displacementMap.xChannelSelector();
636 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s; 636 uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBit s;
637 637
638 b->add32(xKey | yKey); 638 b->add32(xKey | yKey);
639 } 639 }
640 #endif 640 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698