GrCustomStage Renaming Part 2
GrSamplerState member rename GrCustomStageUnitTest rename some comment updates Review URL: https://codereview.appspot.com/6771043 git-svn-id: http://skia.googlecode.com/svn/trunk@6078 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
a469c28c3c
commit
6f261bed02
@ -113,8 +113,8 @@ protected:
|
||||
GrMatrix tm;
|
||||
tm = vm;
|
||||
tm.postIDiv(2*S, 2*S);
|
||||
paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect,
|
||||
(texture)), tm)->unref();
|
||||
paint.colorSampler(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect,
|
||||
(texture)), tm)->unref();
|
||||
|
||||
ctx->drawRect(paint, GrRect::MakeWH(2*S, 2*S));
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
'<(skia_include_path)/gpu/GrConfig.h',
|
||||
'<(skia_include_path)/gpu/GrContext.h',
|
||||
'<(skia_include_path)/gpu/GrContextFactory.h',
|
||||
'<(skia_include_path)/gpu/GrCustomStageUnitTest.h',
|
||||
'<(skia_include_path)/gpu/GrEffect.h',
|
||||
'<(skia_include_path)/gpu/GrEffectUnitTest.h',
|
||||
'<(skia_include_path)/gpu/GrFontScaler.h',
|
||||
'<(skia_include_path)/gpu/GrGlyph.h',
|
||||
'<(skia_include_path)/gpu/GrInstanceCounter.h',
|
||||
|
@ -676,10 +676,10 @@ public:
|
||||
* Save/restore the view-matrix in the context. It can optionally adjust a paint to account
|
||||
* for a coordinate system change. Here is an example of how the paint param can be used:
|
||||
*
|
||||
* A GrPaint is setup with custom stages. The stages will have access to the pre-matrix source
|
||||
* A GrPaint is setup with GrEffects. The stages will have access to the pre-matrix source
|
||||
* geometry positions when the draw is executed. Later on a decision is made to transform the
|
||||
* geometry to device space on the CPU. The custom stages now need to know that the space in
|
||||
* which the geometry will be specified has changed.
|
||||
* geometry to device space on the CPU. The effects now need to know that the space in which
|
||||
* the geometry will be specified has changed.
|
||||
*
|
||||
* Note that when restore is called (or in the destructor) the context's matrix will be
|
||||
* restored. However, the paint will not be restored. The caller must make a copy of the
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "GrRefCnt.h"
|
||||
#include "GrNoncopyable.h"
|
||||
#include "GrProgramStageFactory.h"
|
||||
#include "GrCustomStageUnitTest.h"
|
||||
#include "GrEffectUnitTest.h"
|
||||
#include "GrTextureAccess.h"
|
||||
|
||||
class GrContext;
|
||||
@ -61,7 +61,7 @@ public:
|
||||
*/
|
||||
virtual const GrProgramStageFactory& getFactory() const = 0;
|
||||
|
||||
/** Returns true if the other custom stage will generate identical output.
|
||||
/** Returns true if the other effect will generate identical output.
|
||||
Must only be called if the two are already known to be of the
|
||||
same type (i.e. they return the same value from getFactory()).
|
||||
|
||||
|
@ -5,14 +5,14 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrCustomStageUnitTest_DEFINED
|
||||
#define GrCustomStageUnitTest_DEFINED
|
||||
#ifndef GrEffectUnitTest_DEFINED
|
||||
#define GrEffectUnitTest_DEFINED
|
||||
|
||||
#include "SkRandom.h"
|
||||
#include "GrNoncopyable.h"
|
||||
#include "SkTArray.h"
|
||||
|
||||
namespace GrCustomStageUnitTest {
|
||||
namespace GrEffectUnitTest {
|
||||
// Used to access the dummy textures in TestCreate procs.
|
||||
enum {
|
||||
kSkiaPMTextureIdx = 0,
|
@ -127,7 +127,7 @@ public:
|
||||
|
||||
bool isColorStageEnabled(int i) const {
|
||||
GrAssert((unsigned)i < kMaxColorStages);
|
||||
return (NULL != fColorSamplers[i].getCustomStage());
|
||||
return (NULL != fColorSamplers[i].getEffect());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,7 +146,7 @@ public:
|
||||
|
||||
bool isCoverageStageEnabled(int i) const {
|
||||
GrAssert((unsigned)i < kMaxCoverageStages);
|
||||
return (NULL != fCoverageSamplers[i].getCustomStage());
|
||||
return (NULL != fCoverageSamplers[i].getEffect());
|
||||
}
|
||||
|
||||
bool hasCoverageStage() const {
|
||||
|
@ -21,28 +21,28 @@ class GrSamplerState {
|
||||
public:
|
||||
|
||||
GrSamplerState()
|
||||
: fCustomStage (NULL) {
|
||||
: fEffect (NULL) {
|
||||
GR_DEBUGCODE(fSavedCoordChangeCnt = 0;)
|
||||
}
|
||||
|
||||
~GrSamplerState() {
|
||||
GrSafeUnref(fCustomStage);
|
||||
GrSafeUnref(fEffect);
|
||||
GrAssert(0 == fSavedCoordChangeCnt);
|
||||
}
|
||||
|
||||
bool operator ==(const GrSamplerState& other) const {
|
||||
// first handle cases where one or the other has no custom stage
|
||||
if (NULL == fCustomStage) {
|
||||
return NULL == other.fCustomStage;
|
||||
} else if (NULL == other.fCustomStage) {
|
||||
// first handle cases where one or the other has no effect
|
||||
if (NULL == fEffect) {
|
||||
return NULL == other.fEffect;
|
||||
} else if (NULL == other.fEffect) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fCustomStage->getFactory() != other.fCustomStage->getFactory()) {
|
||||
if (fEffect->getFactory() != other.fEffect->getFactory()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!fCustomStage->isEqual(*other.fCustomStage)) {
|
||||
if (!fEffect->isEqual(*other.fEffect)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -52,8 +52,8 @@ public:
|
||||
bool operator !=(const GrSamplerState& s) const { return !(*this == s); }
|
||||
|
||||
GrSamplerState& operator =(const GrSamplerState& other) {
|
||||
GrSafeAssign(fCustomStage, other.fCustomStage);
|
||||
if (NULL != fCustomStage) {
|
||||
GrSafeAssign(fEffect, other.fEffect);
|
||||
if (NULL != fEffect) {
|
||||
fMatrix = other.fMatrix;
|
||||
fCoordChangeMatrix = other.fCoordChangeMatrix;
|
||||
}
|
||||
@ -70,22 +70,22 @@ public:
|
||||
class SavedCoordChange {
|
||||
private:
|
||||
GrMatrix fCoordChangeMatrix;
|
||||
GR_DEBUGCODE(mutable SkAutoTUnref<GrEffect> fCustomStage;)
|
||||
GR_DEBUGCODE(mutable SkAutoTUnref<GrEffect> fEffect;)
|
||||
|
||||
friend class GrSamplerState;
|
||||
};
|
||||
|
||||
/**
|
||||
* This gets the current coordinate system change. It is the accumulation of
|
||||
* preConcatCoordChange calls since the custom stage was installed. It is used when then caller
|
||||
* preConcatCoordChange calls since the effect was installed. It is used when then caller
|
||||
* wants to temporarily change the source geometry coord system, draw something, and then
|
||||
* restore the previous coord system (e.g. temporarily draw in device coords).s
|
||||
*/
|
||||
void saveCoordChange(SavedCoordChange* savedCoordChange) const {
|
||||
savedCoordChange->fCoordChangeMatrix = fCoordChangeMatrix;
|
||||
GrAssert(NULL == savedCoordChange->fCustomStage.get());
|
||||
GR_DEBUGCODE(GrSafeRef(fCustomStage);)
|
||||
GR_DEBUGCODE(savedCoordChange->fCustomStage.reset(fCustomStage);)
|
||||
GrAssert(NULL == savedCoordChange->fEffect.get());
|
||||
GR_DEBUGCODE(GrSafeRef(fEffect);)
|
||||
GR_DEBUGCODE(savedCoordChange->fEffect.reset(fEffect);)
|
||||
GR_DEBUGCODE(++fSavedCoordChangeCnt);
|
||||
}
|
||||
|
||||
@ -94,9 +94,9 @@ public:
|
||||
*/
|
||||
void restoreCoordChange(const SavedCoordChange& savedCoordChange) {
|
||||
fCoordChangeMatrix = savedCoordChange.fCoordChangeMatrix;
|
||||
GrAssert(savedCoordChange.fCustomStage.get() == fCustomStage);
|
||||
GrAssert(savedCoordChange.fEffect.get() == fEffect);
|
||||
GR_DEBUGCODE(--fSavedCoordChangeCnt);
|
||||
GR_DEBUGCODE(savedCoordChange.fCustomStage.reset(NULL);)
|
||||
GR_DEBUGCODE(savedCoordChange.fEffect.reset(NULL);)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,31 +114,31 @@ public:
|
||||
}
|
||||
|
||||
void reset() {
|
||||
GrSafeSetNull(fCustomStage);
|
||||
GrSafeSetNull(fEffect);
|
||||
}
|
||||
|
||||
GrEffect* setCustomStage(GrEffect* stage) {
|
||||
GrEffect* setEffect(GrEffect* effect) {
|
||||
GrAssert(0 == fSavedCoordChangeCnt);
|
||||
GrSafeAssign(fCustomStage, stage);
|
||||
GrSafeAssign(fEffect, effect);
|
||||
fMatrix.reset();
|
||||
fCoordChangeMatrix.reset();
|
||||
return stage;
|
||||
return effect;
|
||||
}
|
||||
|
||||
GrEffect* setCustomStage(GrEffect* stage, const GrMatrix& matrix) {
|
||||
GrEffect* setEffect(GrEffect* effect, const GrMatrix& matrix) {
|
||||
GrAssert(0 == fSavedCoordChangeCnt);
|
||||
GrSafeAssign(fCustomStage, stage);
|
||||
GrSafeAssign(fEffect, effect);
|
||||
fMatrix = matrix;
|
||||
fCoordChangeMatrix.reset();
|
||||
return stage;
|
||||
return effect;
|
||||
}
|
||||
|
||||
const GrEffect* getCustomStage() const { return fCustomStage; }
|
||||
const GrEffect* getEffect() const { return fEffect; }
|
||||
|
||||
private:
|
||||
GrMatrix fCoordChangeMatrix;
|
||||
GrMatrix fMatrix; // TODO: remove this, store in GrEffect
|
||||
GrEffect* fCustomStage;
|
||||
GrEffect* fEffect;
|
||||
|
||||
GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;)
|
||||
};
|
||||
|
@ -207,9 +207,9 @@ GrTexture* SkBlendImageFilter::onFilterImageGPU(Proxy* proxy, GrTexture* src, co
|
||||
backgroundTexMatrix.setIDiv(background->width(), background->height());
|
||||
foregroundTexMatrix.setIDiv(foreground->width(), foreground->height());
|
||||
GrPaint paint;
|
||||
paint.colorSampler(0)->setCustomStage(
|
||||
paint.colorSampler(0)->setEffect(
|
||||
SkNEW_ARGS(GrSingleTextureEffect, (background.get())), backgroundTexMatrix)->unref();
|
||||
paint.colorSampler(1)->setCustomStage(
|
||||
paint.colorSampler(1)->setEffect(
|
||||
SkNEW_ARGS(GrBlendEffect, (fMode, foreground.get())), foregroundTexMatrix)->unref();
|
||||
context->drawRect(paint, rect);
|
||||
return dst;
|
||||
|
@ -1046,7 +1046,7 @@ GrEffect* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
|
||||
SkScalar surfaceScale = random->nextSScalar1();
|
||||
SkScalar kd = random->nextUScalar1();
|
||||
SkAutoTUnref<SkLight> light(create_random_light(random));
|
||||
return SkNEW_ARGS(GrDiffuseLightingEffect, (textures[GrCustomStageUnitTest::kAlphaTextureIdx],
|
||||
return SkNEW_ARGS(GrDiffuseLightingEffect, (textures[GrEffectUnitTest::kAlphaTextureIdx],
|
||||
light, surfaceScale, kd));
|
||||
}
|
||||
|
||||
@ -1253,7 +1253,7 @@ GrEffect* GrSpecularLightingEffect::TestCreate(SkRandom* random,
|
||||
SkScalar ks = random->nextUScalar1();
|
||||
SkScalar shininess = random->nextUScalar1();
|
||||
SkAutoTUnref<SkLight> light(create_random_light(random));
|
||||
return SkNEW_ARGS(GrSpecularLightingEffect, (textures[GrCustomStageUnitTest::kAlphaTextureIdx],
|
||||
return SkNEW_ARGS(GrSpecularLightingEffect, (textures[GrEffectUnitTest::kAlphaTextureIdx],
|
||||
light, surfaceScale, ks, shininess));
|
||||
}
|
||||
|
||||
|
@ -495,8 +495,8 @@ GR_DEFINE_CUSTOM_STAGE_TEST(GrMatrixConvolutionEffect);
|
||||
GrEffect* GrMatrixConvolutionEffect::TestCreate(SkRandom* random,
|
||||
GrContext* context,
|
||||
GrTexture* textures[]) {
|
||||
int texIdx = random->nextBool() ? GrCustomStageUnitTest::kSkiaPMTextureIdx :
|
||||
GrCustomStageUnitTest::kAlphaTextureIdx;
|
||||
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
|
||||
GrEffectUnitTest::kAlphaTextureIdx;
|
||||
int width = random->nextRangeU(1, MAX_KERNEL_SIZE);
|
||||
int height = random->nextRangeU(1, MAX_KERNEL_SIZE / width);
|
||||
SkISize kernelSize = SkISize::Make(width, height);
|
||||
|
@ -403,8 +403,8 @@ GR_DEFINE_CUSTOM_STAGE_TEST(GrMorphologyEffect);
|
||||
GrEffect* GrMorphologyEffect::TestCreate(SkRandom* random,
|
||||
GrContext* context,
|
||||
GrTexture* textures[]) {
|
||||
int texIdx = random->nextBool() ? GrCustomStageUnitTest::kSkiaPMTextureIdx :
|
||||
GrCustomStageUnitTest::kAlphaTextureIdx;
|
||||
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
|
||||
GrEffectUnitTest::kAlphaTextureIdx;
|
||||
Direction dir = random->nextBool() ? kX_Direction : kY_Direction;
|
||||
static const int kMaxRadius = 10;
|
||||
int radius = random->nextRangeU(1, kMaxRadius);
|
||||
@ -425,7 +425,7 @@ void apply_morphology_pass(GrContext* context,
|
||||
GrMatrix sampleM;
|
||||
sampleM.setIDiv(texture->width(), texture->height());
|
||||
GrPaint paint;
|
||||
paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrMorphologyEffect, (texture, direction, radius, morphType)), sampleM)->unref();
|
||||
paint.colorSampler(0)->setEffect(SkNEW_ARGS(GrMorphologyEffect, (texture, direction, radius, morphType)), sampleM)->unref();
|
||||
context->drawRect(paint, rect);
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ GR_DEFINE_CUSTOM_STAGE_TEST(ColorTableEffect);
|
||||
GrEffect* ColorTableEffect::TestCreate(SkRandom* random,
|
||||
GrContext* context,
|
||||
GrTexture* textures[]) {
|
||||
return SkNEW_ARGS(ColorTableEffect, (textures[GrCustomStageUnitTest::kAlphaTextureIdx]));
|
||||
return SkNEW_ARGS(ColorTableEffect, (textures[GrEffectUnitTest::kAlphaTextureIdx]));
|
||||
}
|
||||
|
||||
GrEffect* SkTable_ColorFilter::asNewCustomStage(GrContext* context) const {
|
||||
|
@ -540,10 +540,10 @@ GrEffect* GrLinearGradient::TestCreate(SkRandom* random,
|
||||
tm));
|
||||
GrSamplerState sampler;
|
||||
shader->asNewCustomStage(context, &sampler);
|
||||
GrAssert(NULL != sampler.getCustomStage());
|
||||
GrAssert(NULL != sampler.getEffect());
|
||||
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
|
||||
sampler.getCustomStage()->ref();
|
||||
return const_cast<GrEffect*>(sampler.getCustomStage());
|
||||
sampler.getEffect()->ref();
|
||||
return const_cast<GrEffect*>(sampler.getEffect());
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@ -570,9 +570,9 @@ bool SkLinearGradient::asNewCustomStage(GrContext* context, GrSamplerState* samp
|
||||
return false;
|
||||
}
|
||||
matrix.postConcat(fPtsToUnit);
|
||||
sampler->setCustomStage(stage, matrix);
|
||||
sampler->setEffect(stage, matrix);
|
||||
} else {
|
||||
sampler->setCustomStage(stage, fPtsToUnit);
|
||||
sampler->setEffect(stage, fPtsToUnit);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -539,10 +539,10 @@ GrEffect* GrRadialGradient::TestCreate(SkRandom* random,
|
||||
tm));
|
||||
GrSamplerState sampler;
|
||||
shader->asNewCustomStage(context, &sampler);
|
||||
GrAssert(NULL != sampler.getCustomStage());
|
||||
GrAssert(NULL != sampler.getEffect());
|
||||
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
|
||||
sampler.getCustomStage()->ref();
|
||||
return const_cast<GrEffect*>(sampler.getCustomStage());
|
||||
sampler.getEffect()->ref();
|
||||
return const_cast<GrEffect*>(sampler.getEffect());
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@ -568,9 +568,9 @@ bool SkRadialGradient::asNewCustomStage(GrContext* context, GrSamplerState* samp
|
||||
return false;
|
||||
}
|
||||
matrix.postConcat(fPtsToUnit);
|
||||
sampler->setCustomStage(stage, matrix);
|
||||
sampler->setEffect(stage, matrix);
|
||||
} else {
|
||||
sampler->setCustomStage(stage, fPtsToUnit);
|
||||
sampler->setEffect(stage, fPtsToUnit);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -445,10 +445,10 @@ GrEffect* GrSweepGradient::TestCreate(SkRandom* random,
|
||||
colors, stops, colorCount));
|
||||
GrSamplerState sampler;
|
||||
shader->asNewCustomStage(context, &sampler);
|
||||
GrAssert(NULL != sampler.getCustomStage());
|
||||
GrAssert(NULL != sampler.getEffect());
|
||||
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
|
||||
sampler.getCustomStage()->ref();
|
||||
return const_cast<GrEffect*>(sampler.getCustomStage());
|
||||
sampler.getEffect()->ref();
|
||||
return const_cast<GrEffect*>(sampler.getEffect());
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@ -475,9 +475,9 @@ bool SkSweepGradient::asNewCustomStage(GrContext* context, GrSamplerState* sampl
|
||||
return false;
|
||||
}
|
||||
matrix.postConcat(fPtsToUnit);
|
||||
sampler->setCustomStage(stage, matrix);
|
||||
sampler->setEffect(stage, matrix);
|
||||
} else {
|
||||
sampler->setCustomStage(stage, fPtsToUnit);
|
||||
sampler->setEffect(stage, fPtsToUnit);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -439,10 +439,10 @@ GrEffect* GrConical2Gradient::TestCreate(SkRandom* random,
|
||||
tm));
|
||||
GrSamplerState sampler;
|
||||
shader->asNewCustomStage(context, &sampler);
|
||||
GrAssert(NULL != sampler.getCustomStage());
|
||||
GrAssert(NULL != sampler.getEffect());
|
||||
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
|
||||
sampler.getCustomStage()->ref();
|
||||
return const_cast<GrEffect*>(sampler.getCustomStage());
|
||||
sampler.getEffect()->ref();
|
||||
return const_cast<GrEffect*>(sampler.getEffect());
|
||||
}
|
||||
|
||||
|
||||
@ -693,7 +693,7 @@ bool SkTwoPointConicalGradient::asNewCustomStage(GrContext* context,
|
||||
matrix.preConcat(localM);
|
||||
}
|
||||
|
||||
sampler->setCustomStage(SkNEW_ARGS(GrConical2Gradient, (context, *this, fTileMode)), matrix)->unref();
|
||||
sampler->setEffect(SkNEW_ARGS(GrConical2Gradient, (context, *this, fTileMode)), matrix)->unref();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -473,10 +473,10 @@ GrEffect* GrRadial2Gradient::TestCreate(SkRandom* random,
|
||||
tm));
|
||||
GrSamplerState sampler;
|
||||
shader->asNewCustomStage(context, &sampler);
|
||||
GrAssert(NULL != sampler.getCustomStage());
|
||||
GrAssert(NULL != sampler.getEffect());
|
||||
// const_cast and ref is a hack! Will remove when asNewCustomStage returns GrEffect*
|
||||
sampler.getCustomStage()->ref();
|
||||
return const_cast<GrEffect*>(sampler.getCustomStage());
|
||||
sampler.getEffect()->ref();
|
||||
return const_cast<GrEffect*>(sampler.getEffect());
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@ -665,7 +665,7 @@ bool SkTwoPointRadialGradient::asNewCustomStage(GrContext* context,
|
||||
matrix.preConcat(localM);
|
||||
}
|
||||
|
||||
sampler->setCustomStage(SkNEW_ARGS(GrRadial2Gradient, (context, *this, fTileMode)), matrix)->unref();
|
||||
sampler->setEffect(SkNEW_ARGS(GrRadial2Gradient, (context, *this, fTileMode)), matrix)->unref();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ void convolve_gaussian(GrDrawTarget* target,
|
||||
SkAutoTUnref<GrConvolutionEffect> conv(SkNEW_ARGS(GrConvolutionEffect,
|
||||
(texture, direction, radius,
|
||||
sigma)));
|
||||
drawState->sampler(0)->setCustomStage(conv, sampleM);
|
||||
drawState->sampler(0)->setEffect(conv, sampleM);
|
||||
target->drawSimpleRect(rect, NULL);
|
||||
}
|
||||
|
||||
@ -1345,7 +1345,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
|
||||
matrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top);
|
||||
}
|
||||
matrix.postIDiv(src->width(), src->height());
|
||||
drawState->sampler(0)->setCustomStage(stage, matrix);
|
||||
drawState->sampler(0)->setEffect(stage, matrix);
|
||||
GrRect rect = GrRect::MakeWH(GrIntToScalar(width), GrIntToScalar(height));
|
||||
fGpu->drawSimpleRect(rect, NULL);
|
||||
// we want to read back from the scratch's origin
|
||||
@ -1553,7 +1553,7 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
|
||||
drawState->setRenderTarget(target);
|
||||
|
||||
matrix.setIDiv(texture->width(), texture->height());
|
||||
drawState->sampler(0)->setCustomStage(stage, matrix);
|
||||
drawState->sampler(0)->setEffect(stage, matrix);
|
||||
|
||||
fGpu->drawSimpleRect(GrRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)), NULL);
|
||||
}
|
||||
@ -1817,8 +1817,8 @@ GrTexture* GrContext::gaussianBlur(GrTexture* srcTexture,
|
||||
scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
|
||||
i < scaleFactorY ? 0.5f : 1.0f);
|
||||
|
||||
paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect,
|
||||
(srcTexture, true)), matrix)->unref();
|
||||
paint.colorSampler(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect,
|
||||
(srcTexture, true)), matrix)->unref();
|
||||
this->drawRectToRect(paint, dstRect, srcRect);
|
||||
srcRect = dstRect;
|
||||
srcTexture = dstTexture;
|
||||
@ -1875,9 +1875,8 @@ GrTexture* GrContext::gaussianBlur(GrTexture* srcTexture,
|
||||
// FIXME: This should be mitchell, not bilinear.
|
||||
matrix.setIDiv(srcTexture->width(), srcTexture->height());
|
||||
this->setRenderTarget(dstTexture->asRenderTarget());
|
||||
paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect,
|
||||
(srcTexture, true)),
|
||||
matrix)->unref();
|
||||
paint.colorSampler(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect,(srcTexture, true)),
|
||||
matrix)->unref();
|
||||
SkRect dstRect(srcRect);
|
||||
scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
|
||||
this->drawRectToRect(paint, dstRect, srcRect);
|
||||
|
@ -69,8 +69,7 @@ public:
|
||||
|
||||
/**
|
||||
* Resets to the default state.
|
||||
* Sampler states *will* be modified: textures or CustomStage objects
|
||||
* will be released.
|
||||
* Sampler states *will* be modified: textures or GrEffect objects will be released.
|
||||
*/
|
||||
void reset() {
|
||||
|
||||
@ -190,27 +189,27 @@ public:
|
||||
* Creates a GrSingleTextureEffect.
|
||||
*/
|
||||
void createTextureEffect(int stage, GrTexture* texture) {
|
||||
GrAssert(!this->getSampler(stage).getCustomStage());
|
||||
this->sampler(stage)->setCustomStage(
|
||||
GrAssert(!this->getSampler(stage).getEffect());
|
||||
this->sampler(stage)->setEffect(
|
||||
SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
|
||||
}
|
||||
void createTextureEffect(int stage, GrTexture* texture, const GrMatrix& matrix) {
|
||||
GrAssert(!this->getSampler(stage).getCustomStage());
|
||||
GrAssert(!this->getSampler(stage).getEffect());
|
||||
GrEffect* customStage = SkNEW_ARGS(GrSingleTextureEffect, (texture));
|
||||
this->sampler(stage)->setCustomStage(customStage, matrix)->unref();
|
||||
this->sampler(stage)->setEffect(customStage, matrix)->unref();
|
||||
}
|
||||
void createTextureEffect(int stage, GrTexture* texture,
|
||||
const GrMatrix& matrix,
|
||||
const GrTextureParams& params) {
|
||||
GrAssert(!this->getSampler(stage).getCustomStage());
|
||||
GrAssert(!this->getSampler(stage).getEffect());
|
||||
GrEffect* customStage = SkNEW_ARGS(GrSingleTextureEffect, (texture, params));
|
||||
this->sampler(stage)->setCustomStage(customStage, matrix)->unref();
|
||||
this->sampler(stage)->setEffect(customStage, matrix)->unref();
|
||||
}
|
||||
|
||||
|
||||
bool stagesDisabled() {
|
||||
for (int i = 0; i < kNumStages; ++i) {
|
||||
if (NULL != fSamplerStates[i].getCustomStage()) {
|
||||
if (NULL != fSamplerStates[i].getEffect()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -218,7 +217,7 @@ public:
|
||||
}
|
||||
|
||||
void disableStage(int index) {
|
||||
fSamplerStates[index].setCustomStage(NULL);
|
||||
fSamplerStates[index].setEffect(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -825,7 +824,7 @@ public:
|
||||
|
||||
bool isStageEnabled(int s) const {
|
||||
GrAssert((unsigned)s < kNumStages);
|
||||
return (NULL != fSamplerStates[s].getCustomStage());
|
||||
return (NULL != fSamplerStates[s].getEffect());
|
||||
}
|
||||
|
||||
// Most stages are usually not used, so conditionals here
|
||||
|
@ -748,7 +748,7 @@ bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex,
|
||||
GrAssert(NULL != drawState.getRenderTarget());
|
||||
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
||||
if (drawState.isStageEnabled(s)) {
|
||||
const GrEffect* stage = drawState.getSampler(s).getCustomStage();
|
||||
const GrEffect* stage = drawState.getSampler(s).getEffect();
|
||||
int numTextures = stage->numTextures();
|
||||
for (int t = 0; t < numTextures; ++t) {
|
||||
GrTexture* texture = stage->texture(t);
|
||||
@ -831,7 +831,7 @@ bool GrDrawTarget::srcAlphaWillBeOne(GrVertexLayout layout) const {
|
||||
// Check if a color stage could create a partial alpha
|
||||
for (int s = 0; s < drawState.getFirstCoverageStage(); ++s) {
|
||||
if (this->isStageEnabled(s)) {
|
||||
const GrEffect* stage = drawState.getSampler(s).getCustomStage();
|
||||
const GrEffect* stage = drawState.getSampler(s).getEffect();
|
||||
// FIXME: The param indicates whether the texture is opaque or not. However, the stage
|
||||
// already controls its textures. It really needs to know whether the incoming color
|
||||
// (from a uni, per-vertex colors, or previous stage) is opaque or not.
|
||||
|
@ -441,7 +441,7 @@ SkGpuRenderTarget* SkGpuDevice::accessRenderTarget() {
|
||||
bool SkGpuDevice::bindDeviceAsTexture(GrPaint* paint) {
|
||||
GrTexture* texture = fRenderTarget->asTexture();
|
||||
if (NULL != texture) {
|
||||
paint->colorSampler(kBitmapTextureIdx)->setCustomStage(
|
||||
paint->colorSampler(kBitmapTextureIdx)->setEffect(
|
||||
SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
|
||||
return true;
|
||||
}
|
||||
@ -514,7 +514,7 @@ inline bool skPaint2GrPaintNoShader(SkGpuDevice* dev,
|
||||
} else {
|
||||
SkAutoTUnref<GrEffect> stage(colorFilter->asNewCustomStage(dev->context()));
|
||||
if (NULL != stage.get()) {
|
||||
grPaint->colorSampler(kColorFilterTextureIdx)->setCustomStage(stage);
|
||||
grPaint->colorSampler(kColorFilterTextureIdx)->setEffect(stage);
|
||||
} else {
|
||||
// TODO: rewrite this using asNewCustomStage()
|
||||
SkColor color;
|
||||
@ -607,7 +607,7 @@ inline bool skPaint2GrPaintShader(SkGpuDevice* dev,
|
||||
GrScalar sy = SkFloatToScalar(1.f / bitmap.height());
|
||||
matrix.postScale(sx, sy);
|
||||
}
|
||||
sampler->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (texture, params)), matrix)->unref();
|
||||
sampler->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture, params)), matrix)->unref();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -874,7 +874,7 @@ bool drawWithGPUMaskFilter(GrContext* context, const SkPath& devPath,
|
||||
matrix.setIDiv(pathTexture->width(), pathTexture->height());
|
||||
// Blend pathTexture over blurTexture.
|
||||
context->setRenderTarget(blurTexture->asRenderTarget());
|
||||
paint.colorSampler(0)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (pathTexture)), matrix)->unref();
|
||||
paint.colorSampler(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (pathTexture)), matrix)->unref();
|
||||
if (SkMaskFilter::kInner_BlurType == blurType) {
|
||||
// inner: dst = dst * src
|
||||
paint.setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff);
|
||||
@ -905,7 +905,7 @@ bool drawWithGPUMaskFilter(GrContext* context, const SkPath& devPath,
|
||||
matrix.postIDiv(blurTexture->width(), blurTexture->height());
|
||||
|
||||
grp->coverageSampler(MASK_IDX)->reset();
|
||||
grp->coverageSampler(MASK_IDX)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (blurTexture)), matrix)->unref();
|
||||
grp->coverageSampler(MASK_IDX)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (blurTexture)), matrix)->unref();
|
||||
context->drawRect(*grp, finalRect);
|
||||
return true;
|
||||
}
|
||||
@ -961,7 +961,7 @@ bool drawWithMaskFilter(GrContext* context, const SkPath& devPath,
|
||||
m.setTranslate(-dstM.fBounds.fLeft*SK_Scalar1, -dstM.fBounds.fTop*SK_Scalar1);
|
||||
m.postIDiv(texture->width(), texture->height());
|
||||
|
||||
grp->coverageSampler(MASK_IDX)->setCustomStage(SkNEW_ARGS(GrSingleTextureEffect, (texture)), m)->unref();
|
||||
grp->coverageSampler(MASK_IDX)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture)), m)->unref();
|
||||
GrRect d;
|
||||
d.setLTRB(GrIntToScalar(dstM.fBounds.fLeft),
|
||||
GrIntToScalar(dstM.fBounds.fTop),
|
||||
@ -1438,7 +1438,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
|
||||
} else {
|
||||
stage.reset(SkNEW_ARGS(GrSingleTextureEffect, (texture, params)));
|
||||
}
|
||||
grPaint->colorSampler(kBitmapTextureIdx)->setCustomStage(stage);
|
||||
grPaint->colorSampler(kBitmapTextureIdx)->setEffect(stage);
|
||||
fContext->drawRectToRect(*grPaint, dstRect, paintRect, &m);
|
||||
}
|
||||
|
||||
@ -1458,7 +1458,7 @@ void apply_custom_stage(GrContext* context,
|
||||
GrMatrix sampleM;
|
||||
sampleM.setIDiv(srcTexture->width(), srcTexture->height());
|
||||
GrPaint paint;
|
||||
paint.colorSampler(0)->setCustomStage(stage, sampleM);
|
||||
paint.colorSampler(0)->setEffect(stage, sampleM);
|
||||
context->drawRect(paint, rect);
|
||||
}
|
||||
|
||||
@ -1516,7 +1516,7 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
|
||||
sampler->reset();
|
||||
// draw sprite uses the default texture params
|
||||
SkAutoCachedTexture act(this, bitmap, NULL, &texture);
|
||||
grPaint.colorSampler(kBitmapTextureIdx)->setCustomStage(SkNEW_ARGS
|
||||
grPaint.colorSampler(kBitmapTextureIdx)->setEffect(SkNEW_ARGS
|
||||
(GrSingleTextureEffect, (texture)))->unref();
|
||||
|
||||
SkImageFilter* filter = paint.getImageFilter();
|
||||
@ -1524,7 +1524,7 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
|
||||
GrTexture* filteredTexture = filter_texture(this, fContext, texture, filter,
|
||||
GrRect::MakeWH(SkIntToScalar(w), SkIntToScalar(h)));
|
||||
if (filteredTexture) {
|
||||
grPaint.colorSampler(kBitmapTextureIdx)->setCustomStage(SkNEW_ARGS
|
||||
grPaint.colorSampler(kBitmapTextureIdx)->setEffect(SkNEW_ARGS
|
||||
(GrSingleTextureEffect, (filteredTexture)))->unref();
|
||||
texture = filteredTexture;
|
||||
filteredTexture->unref();
|
||||
@ -1590,7 +1590,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkDevice* device,
|
||||
return;
|
||||
}
|
||||
|
||||
GrTexture* devTex = grPaint.getColorSampler(kBitmapTextureIdx).getCustomStage()->texture(0);
|
||||
GrTexture* devTex = grPaint.getColorSampler(kBitmapTextureIdx).getEffect()->texture(0);
|
||||
SkASSERT(NULL != devTex);
|
||||
|
||||
SkImageFilter* filter = paint.getImageFilter();
|
||||
@ -1599,7 +1599,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkDevice* device,
|
||||
SkIntToScalar(devTex->height()));
|
||||
GrTexture* filteredTexture = filter_texture(this, fContext, devTex, filter, rect);
|
||||
if (filteredTexture) {
|
||||
grPaint.colorSampler(kBitmapTextureIdx)->setCustomStage(SkNEW_ARGS
|
||||
grPaint.colorSampler(kBitmapTextureIdx)->setEffect(SkNEW_ARGS
|
||||
(GrSingleTextureEffect, (filteredTexture)))->unref();
|
||||
devTex = filteredTexture;
|
||||
filteredTexture->unref();
|
||||
|
@ -109,7 +109,7 @@ GrEffect* GrConfigConversionEffect::TestCreate(SkRandom* random,
|
||||
swapRB = random->nextBool();
|
||||
}
|
||||
return SkNEW_ARGS(GrConfigConversionEffect,
|
||||
(textures[GrCustomStageUnitTest::kSkiaPMTextureIdx], swapRB, pmConv));
|
||||
(textures[GrEffectUnitTest::kSkiaPMTextureIdx], swapRB, pmConv));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -185,16 +185,16 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
||||
(tempTex, false, *pmToUPMRule)));
|
||||
|
||||
context->setRenderTarget(readTex->asRenderTarget());
|
||||
paint.colorSampler(0)->setCustomStage(pmToUPMStage1);
|
||||
paint.colorSampler(0)->setEffect(pmToUPMStage1);
|
||||
context->drawRectToRect(paint, kDstRect, kSrcRect);
|
||||
|
||||
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, firstRead);
|
||||
|
||||
context->setRenderTarget(tempTex->asRenderTarget());
|
||||
paint.colorSampler(0)->setCustomStage(upmToPMStage);
|
||||
paint.colorSampler(0)->setEffect(upmToPMStage);
|
||||
context->drawRectToRect(paint, kDstRect, kSrcRect);
|
||||
context->setRenderTarget(readTex->asRenderTarget());
|
||||
paint.colorSampler(0)->setCustomStage(pmToUPMStage2);
|
||||
paint.colorSampler(0)->setEffect(pmToUPMStage2);
|
||||
context->drawRectToRect(paint, kDstRect, kSrcRect);
|
||||
|
||||
readTex->readPixels(0, 0, 256, 256, kRGBA_8888_GrPixelConfig, secondRead);
|
||||
|
@ -177,8 +177,8 @@ GR_DEFINE_CUSTOM_STAGE_TEST(GrConvolutionEffect);
|
||||
GrEffect* GrConvolutionEffect::TestCreate(SkRandom* random,
|
||||
GrContext* context,
|
||||
GrTexture* textures[]) {
|
||||
int texIdx = random->nextBool() ? GrCustomStageUnitTest::kSkiaPMTextureIdx :
|
||||
GrCustomStageUnitTest::kAlphaTextureIdx;
|
||||
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
|
||||
GrEffectUnitTest::kAlphaTextureIdx;
|
||||
Direction dir = random->nextBool() ? kX_Direction : kY_Direction;
|
||||
int radius = random->nextRangeU(1, kMaxKernelRadius);
|
||||
float kernel[kMaxKernelRadius];
|
||||
|
@ -71,7 +71,7 @@ GR_DEFINE_CUSTOM_STAGE_TEST(GrSingleTextureEffect);
|
||||
GrEffect* GrSingleTextureEffect::TestCreate(SkRandom* random,
|
||||
GrContext* context,
|
||||
GrTexture* textures[]) {
|
||||
int texIdx = random->nextBool() ? GrCustomStageUnitTest::kSkiaPMTextureIdx :
|
||||
GrCustomStageUnitTest::kAlphaTextureIdx;
|
||||
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
|
||||
GrEffectUnitTest::kAlphaTextureIdx;
|
||||
return SkNEW_ARGS(GrSingleTextureEffect, (textures[texIdx]));
|
||||
}
|
||||
|
@ -117,8 +117,8 @@ GR_DEFINE_CUSTOM_STAGE_TEST(GrTextureDomainEffect);
|
||||
GrEffect* GrTextureDomainEffect::TestCreate(SkRandom* random,
|
||||
GrContext* context,
|
||||
GrTexture* textures[]) {
|
||||
int texIdx = random->nextBool() ? GrCustomStageUnitTest::kSkiaPMTextureIdx :
|
||||
GrCustomStageUnitTest::kAlphaTextureIdx;
|
||||
int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
|
||||
GrEffectUnitTest::kAlphaTextureIdx;
|
||||
GrRect domain;
|
||||
domain.fLeft = random->nextUScalar1();
|
||||
domain.fRight = random->nextRangeScalar(domain.fLeft, SK_Scalar1);
|
||||
|
@ -977,8 +977,8 @@ void GrGLProgram::setData(const GrDrawState& drawState) {
|
||||
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
||||
if (NULL != fProgramStage[s]) {
|
||||
const GrSamplerState& sampler = drawState.getSampler(s);
|
||||
GrAssert(NULL != sampler.getCustomStage());
|
||||
fProgramStage[s]->setData(fUniformManager, *sampler.getCustomStage());
|
||||
GrAssert(NULL != sampler.getEffect());
|
||||
fProgramStage[s]->setData(fUniformManager, *sampler.getEffect());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2019,7 +2019,7 @@ inline GrGLenum tile_to_gl_wrap(SkShader::TileMode tm) {
|
||||
void GrGpuGL::flushBoundTextureAndParams(int stage) {
|
||||
GrDrawState* drawState = this->drawState();
|
||||
// FIXME: Assuming at most one texture per custom stage
|
||||
const GrEffect* customStage = drawState->sampler(stage)->getCustomStage();
|
||||
const GrEffect* customStage = drawState->sampler(stage)->getEffect();
|
||||
if (customStage->numTextures() > 0) {
|
||||
GrGLTexture* nextTexture = static_cast<GrGLTexture*>(customStage->texture(0));
|
||||
if (NULL != nextTexture) {
|
||||
|
@ -199,7 +199,7 @@ void GrGpuGL::flushTextureMatrix(int s) {
|
||||
const GrDrawState& drawState = this->getDrawState();
|
||||
|
||||
// FIXME: Still assuming only a single texture per custom stage
|
||||
const GrEffect* stage = drawState.getSampler(s).getCustomStage();
|
||||
const GrEffect* stage = drawState.getSampler(s).getEffect();
|
||||
if (0 == stage->numTextures()) {
|
||||
return;
|
||||
}
|
||||
@ -570,7 +570,7 @@ void setup_custom_stage(GrGLProgram::Desc::StageDesc* stage,
|
||||
const GrGLCaps& caps,
|
||||
const GrEffect** customStages,
|
||||
GrGLProgram* program, int index) {
|
||||
const GrEffect* customStage = sampler.getCustomStage();
|
||||
const GrEffect* customStage = sampler.getEffect();
|
||||
if (customStage) {
|
||||
const GrProgramStageFactory& factory = customStage->getFactory();
|
||||
stage->fCustomStageKey = factory.glStageKey(*customStage, caps);
|
||||
@ -675,7 +675,7 @@ void GrGpuGL::buildProgram(bool isPoints,
|
||||
lastEnabledStage = s;
|
||||
const GrSamplerState& sampler = drawState.getSampler(s);
|
||||
// FIXME: Still assuming one texture per custom stage
|
||||
const GrEffect* customStage = drawState.getSampler(s).getCustomStage();
|
||||
const GrEffect* customStage = drawState.getSampler(s).getEffect();
|
||||
|
||||
if (customStage->numTextures() > 0) {
|
||||
const GrGLTexture* texture =
|
||||
|
Loading…
Reference in New Issue
Block a user