diff options
author | bsalomon <bsalomon@google.com> | 2015-09-22 09:06:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-22 09:06:13 -0700 |
commit | bf87730c7da80616f6ea17765290dbd2c147a669 (patch) | |
tree | c7394bcd13ee1530447317d7f59a344104a4eb78 | |
parent | 3905c379e8da7c413f6f47398e6f605de84dc8a4 (diff) |
Move GrFragmentProcessor implementation to its own cpp file
TBR=joshualitt@google.com
Review URL: https://codereview.chromium.org/1350523004
-rw-r--r-- | gyp/gpu.gypi | 1 | ||||
-rw-r--r-- | src/gpu/GrFragmentProcessor.cpp | 129 | ||||
-rw-r--r-- | src/gpu/GrProcessor.cpp | 122 |
3 files changed, 130 insertions, 122 deletions
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi index 7840abcf19..6038023142 100644 --- a/gyp/gpu.gypi +++ b/gyp/gpu.gypi @@ -91,6 +91,7 @@ '<(skia_src_path)/gpu/GrDrawTarget.h', '<(skia_src_path)/gpu/GrFontScaler.cpp', '<(skia_src_path)/gpu/GrFontScaler.h', + '<(skia_src_path)/gpu/GrFragmentProcessor.cpp', '<(skia_src_path)/gpu/GrGeometryBuffer.h', '<(skia_src_path)/gpu/GrGeometryProcessor.h', '<(skia_src_path)/gpu/GrGlyph.h', diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp new file mode 100644 index 0000000000..fcc9c74fa4 --- /dev/null +++ b/src/gpu/GrFragmentProcessor.cpp @@ -0,0 +1,129 @@ + +/* +* Copyright 2015 Google Inc. +* +* Use of this source code is governed by a BSD-style license that can be +* found in the LICENSE file. +*/ + +#include "GrFragmentProcessor.h" +#include "GrCoordTransform.h" +#include "gl/GrGLFragmentProcessor.h" +#include "effects/GrXfermodeFragmentProcessor.h" + +GrFragmentProcessor::~GrFragmentProcessor() { + // If we got here then our ref count must have reached zero, so we will have converted refs + // to pending executions for all children. + for (int i = 0; i < fChildProcessors.count(); ++i) { + fChildProcessors[i]->completedExecution(); + } +} + +bool GrFragmentProcessor::isEqual(const GrFragmentProcessor& that, + bool ignoreCoordTransforms) const { + if (this->classID() != that.classID() || + !this->hasSameTextureAccesses(that)) { + return false; + } + if (ignoreCoordTransforms) { + if (this->numTransforms() != that.numTransforms()) { + return false; + } + } else if (!this->hasSameTransforms(that)) { + return false; + } + if (!this->onIsEqual(that)) { + return false; + } + if (this->numChildProcessors() != that.numChildProcessors()) { + return false; + } + for (int i = 0; i < this->numChildProcessors(); ++i) { + if (!this->childProcessor(i).isEqual(that.childProcessor(i), ignoreCoordTransforms)) { + return false; + } + } + return true; +} + +GrGLFragmentProcessor* GrFragmentProcessor::createGLInstance() const { + GrGLFragmentProcessor* glFragProc = this->onCreateGLInstance(); + glFragProc->fChildProcessors.push_back_n(fChildProcessors.count()); + for (int i = 0; i < fChildProcessors.count(); ++i) { + glFragProc->fChildProcessors[i] = fChildProcessors[i]->createGLInstance(); + } + return glFragProc; +} + +void GrFragmentProcessor::addTextureAccess(const GrTextureAccess* textureAccess) { + // Can't add texture accesses after registering any children since their texture accesses have + // already been bubbled up into our fTextureAccesses array + SkASSERT(fChildProcessors.empty()); + + INHERITED::addTextureAccess(textureAccess); + fNumTexturesExclChildren++; +} + +void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) { + // Can't add transforms after registering any children since their transforms have already been + // bubbled up into our fCoordTransforms array + SkASSERT(fChildProcessors.empty()); + + fCoordTransforms.push_back(transform); + fUsesLocalCoords = fUsesLocalCoords || transform->sourceCoords() == kLocal_GrCoordSet; + SkDEBUGCODE(transform->setInProcessor();) + fNumTransformsExclChildren++; +} + +int GrFragmentProcessor::registerChildProcessor(const GrFragmentProcessor* child) { + // Append the child's transforms to our transforms array and the child's textures array to our + // textures array + if (!child->fCoordTransforms.empty()) { + fCoordTransforms.push_back_n(child->fCoordTransforms.count(), + child->fCoordTransforms.begin()); + } + if (!child->fTextureAccesses.empty()) { + fTextureAccesses.push_back_n(child->fTextureAccesses.count(), + child->fTextureAccesses.begin()); + } + + int index = fChildProcessors.count(); + fChildProcessors.push_back(SkRef(child)); + + if (child->willReadFragmentPosition()) { + this->setWillReadFragmentPosition(); + } + + if (child->usesLocalCoords()) { + fUsesLocalCoords = true; + } + + return index; +} + +void GrFragmentProcessor::notifyRefCntIsZero() const { + // See comment above GrProgramElement for a detailed explanation of why we do this. + for (int i = 0; i < fChildProcessors.count(); ++i) { + fChildProcessors[i]->addPendingExecution(); + fChildProcessors[i]->unref(); + } +} + +bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) const { + if (this->numTransforms() != that.numTransforms()) { + return false; + } + int count = this->numTransforms(); + for (int i = 0; i < count; ++i) { + if (this->coordTransform(i) != that.coordTransform(i)) { + return false; + } + } + return true; +} + +const GrFragmentProcessor* GrFragmentProcessor::MulOuputByInputAlpha( + const GrFragmentProcessor* fp) { + return GrXfermodeFragmentProcessor::CreateFromDstProcessor(fp, SkXfermode::kDstIn_Mode); +} + diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp index e6be1da33a..1db9d76fda 100644 --- a/src/gpu/GrProcessor.cpp +++ b/src/gpu/GrProcessor.cpp @@ -7,13 +7,11 @@ #include "GrProcessor.h" #include "GrContext.h" -#include "GrCoordTransform.h" #include "GrGeometryProcessor.h" #include "GrInvariantOutput.h" #include "GrMemoryPool.h" #include "GrXferProcessor.h" #include "SkSpinlock.h" -#include "gl/GrGLFragmentProcessor.h" #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS @@ -130,126 +128,6 @@ bool GrProcessor::hasSameTextureAccesses(const GrProcessor& that) const { /////////////////////////////////////////////////////////////////////////////////////////////////// -GrFragmentProcessor::~GrFragmentProcessor() { - // If we got here then our ref count must have reached zero, so we will have converted refs - // to pending executions for all children. - for (int i = 0; i < fChildProcessors.count(); ++i) { - fChildProcessors[i]->completedExecution(); - } -} - -bool GrFragmentProcessor::isEqual(const GrFragmentProcessor& that, - bool ignoreCoordTransforms) const { - if (this->classID() != that.classID() || - !this->hasSameTextureAccesses(that)) { - return false; - } - if (ignoreCoordTransforms) { - if (this->numTransforms() != that.numTransforms()) { - return false; - } - } else if (!this->hasSameTransforms(that)) { - return false; - } - if (!this->onIsEqual(that)) { - return false; - } - if (this->numChildProcessors() != that.numChildProcessors()) { - return false; - } - for (int i = 0; i < this->numChildProcessors(); ++i) { - if (!this->childProcessor(i).isEqual(that.childProcessor(i), ignoreCoordTransforms)) { - return false; - } - } - return true; -} - -GrGLFragmentProcessor* GrFragmentProcessor::createGLInstance() const { - GrGLFragmentProcessor* glFragProc = this->onCreateGLInstance(); - glFragProc->fChildProcessors.push_back_n(fChildProcessors.count()); - for (int i = 0; i < fChildProcessors.count(); ++i) { - glFragProc->fChildProcessors[i] = fChildProcessors[i]->createGLInstance(); - } - return glFragProc; -} - -void GrFragmentProcessor::addTextureAccess(const GrTextureAccess* textureAccess) { - // Can't add texture accesses after registering any children since their texture accesses have - // already been bubbled up into our fTextureAccesses array - SkASSERT(fChildProcessors.empty()); - - INHERITED::addTextureAccess(textureAccess); - fNumTexturesExclChildren++; -} - -void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) { - // Can't add transforms after registering any children since their transforms have already been - // bubbled up into our fCoordTransforms array - SkASSERT(fChildProcessors.empty()); - - fCoordTransforms.push_back(transform); - fUsesLocalCoords = fUsesLocalCoords || transform->sourceCoords() == kLocal_GrCoordSet; - SkDEBUGCODE(transform->setInProcessor();) - fNumTransformsExclChildren++; -} - -int GrFragmentProcessor::registerChildProcessor(const GrFragmentProcessor* child) { - // Append the child's transforms to our transforms array and the child's textures array to our - // textures array - if (!child->fCoordTransforms.empty()) { - fCoordTransforms.push_back_n(child->fCoordTransforms.count(), - child->fCoordTransforms.begin()); - } - if (!child->fTextureAccesses.empty()) { - fTextureAccesses.push_back_n(child->fTextureAccesses.count(), - child->fTextureAccesses.begin()); - } - - int index = fChildProcessors.count(); - fChildProcessors.push_back(SkRef(child)); - - if (child->willReadFragmentPosition()) { - this->setWillReadFragmentPosition(); - } - - if (child->usesLocalCoords()) { - fUsesLocalCoords = true; - } - - return index; -} - -void GrFragmentProcessor::notifyRefCntIsZero() const { - // See comment above GrProgramElement for a detailed explanation of why we do this. - for (int i = 0; i < fChildProcessors.count(); ++i) { - fChildProcessors[i]->addPendingExecution(); - fChildProcessors[i]->unref(); - } -} - -bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) const { - if (this->numTransforms() != that.numTransforms()) { - return false; - } - int count = this->numTransforms(); - for (int i = 0; i < count; ++i) { - if (this->coordTransform(i) != that.coordTransform(i)) { - return false; - } - } - return true; -} - -#include "effects/GrXfermodeFragmentProcessor.h" - -const GrFragmentProcessor* GrFragmentProcessor::MulOuputByInputAlpha( - const GrFragmentProcessor* fp) { - return GrXfermodeFragmentProcessor::CreateFromDstProcessor(fp, SkXfermode::kDstIn_Mode); -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// - // Initial static variable from GrXPFactory int32_t GrXPFactory::gCurrXPFClassID = GrXPFactory::kIllegalXPFClassID; |