diff options
author | tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-04-20 18:35:38 +0000 |
---|---|---|
committer | tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-04-20 18:35:38 +0000 |
commit | 07eecdca3e331eb4066c53a29305aeea6d692961 (patch) | |
tree | d511d99cc07f13525d8a87292c8d48d075b2d8ea /include/gpu | |
parent | 5a2e879ef8a3720ac3f06fbc13dcdaeb179f30c3 (diff) |
Hooks up the GrCustomStage/GrGLProgramStageFactory/GrGLProgramStage
classes from r3726 so they can be used. Does not implement any actual
effect stages.
Has one large known bug: if custom stages are provided, GrSamplerState
comparisons will break; this should preserve correct drawing, but decrease
performance - among other things, we'll break draw batching. To fix this
we'll need a RTTI system for GrCustomState objects, and we'll need to change
the GrSamplerState comparison from a memcmp to something that also does a
deep type-sensitive compare of any GrCustomState objects present.
http://codereview.appspot.com/6074043/
git-svn-id: http://skia.googlecode.com/svn/trunk@3742 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/gpu')
-rw-r--r-- | include/gpu/GrCustomStage.h | 36 | ||||
-rw-r--r-- | include/gpu/GrSamplerState.h | 22 |
2 files changed, 56 insertions, 2 deletions
diff --git a/include/gpu/GrCustomStage.h b/include/gpu/GrCustomStage.h new file mode 100644 index 0000000000..25ab005472 --- /dev/null +++ b/include/gpu/GrCustomStage.h @@ -0,0 +1,36 @@ +/* + * Copyright 2012 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrCustomStage_DEFINED +#define GrCustomStage_DEFINED + +#include "GrRefCnt.h" + +class GrContext; +class GrGLProgramStageFactory; + +/** Provides custom vertex shader, fragment shader, uniform data for a + particular stage of the Ganesh shading pipeline. + TODO: may want to refcount these? */ +class GrCustomStage : public GrRefCnt { + +public: + + GrCustomStage(); + virtual ~GrCustomStage(); + + /** If given an input texture that is/is not opaque, is this + stage guaranteed to produce an opaque output? */ + virtual bool isOpaque(bool inputTextureIsOpaque) const; + + virtual GrGLProgramStageFactory* getGLFactory() = 0; + +protected: + +}; + +#endif diff --git a/include/gpu/GrSamplerState.h b/include/gpu/GrSamplerState.h index 50a6cc9ec7..d9957bd578 100644 --- a/include/gpu/GrSamplerState.h +++ b/include/gpu/GrSamplerState.h @@ -11,8 +11,9 @@ #ifndef GrSamplerState_DEFINED #define GrSamplerState_DEFINED -#include "GrTypes.h" +#include "GrCustomStage.h" #include "GrMatrix.h" +#include "GrTypes.h" #define MAX_KERNEL_WIDTH 25 @@ -110,12 +111,17 @@ public: * unfiltered, and use identity matrix. */ GrSamplerState() - : fRadial2CenterX1() + : fCustomStage (NULL) + , fRadial2CenterX1() , fRadial2Radius0() , fRadial2PosRoot() { this->reset(); } + ~GrSamplerState() { + GrSafeUnref(fCustomStage); + } + WrapMode getWrapX() const { return fWrapX; } WrapMode getWrapY() const { return fWrapY; } FilterDirection getFilterDirection() const { return fFilterDirection; } @@ -188,6 +194,7 @@ public: fMatrix = matrix; fTextureDomain.setEmpty(); fSwapRAndB = false; + GrSafeSetNull(fCustomStage); } void reset(WrapMode wrapXAndY, Filter filter, const GrMatrix& matrix) { this->reset(wrapXAndY, filter, kDefault_FilterDirection, matrix); @@ -236,6 +243,11 @@ public: fKernelWidth = radius; } + void setCustomStage(GrCustomStage* stage) { + GrSafeAssign(fCustomStage, stage); + } + GrCustomStage* getCustomStage() const { return fCustomStage; } + private: WrapMode fWrapX : 8; WrapMode fWrapY : 8; @@ -246,6 +258,12 @@ private: bool fSwapRAndB; GrRect fTextureDomain; + /// BUG! Ganesh only works correctly so long as fCustomStage is + /// NULL; we need to have a complex ID system here so that we can + /// have an equality-like comparison to determine whether two + /// fCustomStages are equal. + GrCustomStage* fCustomStage; + // these are undefined unless fSampleMode == kRadial2_SampleMode GrScalar fRadial2CenterX1; GrScalar fRadial2Radius0; |