Remove getter of writable GrEffectStage from GrDrawState.
Upcoming changes will require GrDrawState to know things about the set of installed effects. Thus all setting of effects must go through a GrDrawState function (setEffect()). This change accomplishes that. Review URL: https://codereview.appspot.com/7214045 git-svn-id: http://skia.googlecode.com/svn/trunk@7411 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
093455c116
commit
adc6536fe5
@ -910,14 +910,17 @@ private:
|
|||||||
// for use with textures released from an GrAutoScratchTexture.
|
// for use with textures released from an GrAutoScratchTexture.
|
||||||
void addExistingTextureToCache(GrTexture* texture);
|
void addExistingTextureToCache(GrTexture* texture);
|
||||||
|
|
||||||
bool installPMToUPMEffect(GrTexture* texture,
|
/**
|
||||||
|
* These functions create premul <-> unpremul effects if it is possible to generate a pair
|
||||||
|
* of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. Otherwise, they
|
||||||
|
* return NULL.
|
||||||
|
*/
|
||||||
|
const GrEffectRef* createPMToUPMEffect(GrTexture* texture,
|
||||||
bool swapRAndB,
|
bool swapRAndB,
|
||||||
const SkMatrix& matrix,
|
const SkMatrix& matrix);
|
||||||
GrEffectStage* stage);
|
const GrEffectRef* createUPMToPMEffect(GrTexture* texture,
|
||||||
bool installUPMToPMEffect(GrTexture* texture,
|
|
||||||
bool swapRAndB,
|
bool swapRAndB,
|
||||||
const SkMatrix& matrix,
|
const SkMatrix& matrix);
|
||||||
GrEffectStage* stage);
|
|
||||||
|
|
||||||
typedef GrRefCnt INHERITED;
|
typedef GrRefCnt INHERITED;
|
||||||
};
|
};
|
||||||
|
@ -45,11 +45,9 @@ void setup_drawstate_aaclip(GrGpu* gpu,
|
|||||||
SkIntToScalar(-devBound.fTop));
|
SkIntToScalar(-devBound.fTop));
|
||||||
mat.preConcat(drawState->getViewMatrix());
|
mat.preConcat(drawState->getViewMatrix());
|
||||||
|
|
||||||
drawState->stage(kMaskStage)->reset();
|
|
||||||
|
|
||||||
SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height());
|
SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height());
|
||||||
// This could be a long-lived effect that is cached with the alpha-mask.
|
// This could be a long-lived effect that is cached with the alpha-mask.
|
||||||
drawState->stage(kMaskStage)->setEffect(
|
drawState->setEffect(kMaskStage,
|
||||||
GrTextureDomainEffect::Create(result,
|
GrTextureDomainEffect::Create(result,
|
||||||
mat,
|
mat,
|
||||||
GrTextureDomainEffect::MakeTexelDomain(result, domainTexels),
|
GrTextureDomainEffect::MakeTexelDomain(result, domainTexels),
|
||||||
@ -352,7 +350,7 @@ void GrClipMaskManager::mergeMask(GrTexture* dstMask,
|
|||||||
|
|
||||||
SkMatrix sampleM;
|
SkMatrix sampleM;
|
||||||
sampleM.setIDiv(srcMask->width(), srcMask->height());
|
sampleM.setIDiv(srcMask->width(), srcMask->height());
|
||||||
drawState->stage(0)->setEffect(
|
drawState->setEffect(0,
|
||||||
GrTextureDomainEffect::Create(srcMask,
|
GrTextureDomainEffect::Create(srcMask,
|
||||||
sampleM,
|
sampleM,
|
||||||
GrTextureDomainEffect::MakeTexelDomain(srcMask, srcBound),
|
GrTextureDomainEffect::MakeTexelDomain(srcMask, srcBound),
|
||||||
|
@ -204,7 +204,7 @@ void convolve_gaussian(GrDrawTarget* target,
|
|||||||
direction,
|
direction,
|
||||||
radius,
|
radius,
|
||||||
sigma));
|
sigma));
|
||||||
drawState->stage(0)->setEffect(conv);
|
drawState->setEffect(0, conv);
|
||||||
target->drawSimpleRect(rect, NULL);
|
target->drawSimpleRect(rect, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1375,7 +1375,6 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
|
|||||||
ast.set(this, desc, match);
|
ast.set(this, desc, match);
|
||||||
GrTexture* texture = ast.texture();
|
GrTexture* texture = ast.texture();
|
||||||
if (texture) {
|
if (texture) {
|
||||||
GrEffectStage stage;
|
|
||||||
// compute a matrix to perform the draw
|
// compute a matrix to perform the draw
|
||||||
SkMatrix textureMatrix;
|
SkMatrix textureMatrix;
|
||||||
if (flipY) {
|
if (flipY) {
|
||||||
@ -1387,30 +1386,30 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
|
|||||||
}
|
}
|
||||||
textureMatrix.postIDiv(src->width(), src->height());
|
textureMatrix.postIDiv(src->width(), src->height());
|
||||||
|
|
||||||
bool effectInstalled = false;
|
SkAutoTUnref<const GrEffectRef> effect;
|
||||||
if (unpremul) {
|
if (unpremul) {
|
||||||
if (this->installPMToUPMEffect(src, swapRAndB, textureMatrix, &stage)) {
|
effect.reset(this->createPMToUPMEffect(src, swapRAndB, textureMatrix));
|
||||||
effectInstalled = true;
|
if (NULL != effect) {
|
||||||
unpremul = false; // we no longer need to do this on CPU after the readback.
|
unpremul = false; // we no longer need to do this on CPU after the readback.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If we failed to create a PM->UPM effect and have no other conversions to perform then
|
// If we failed to create a PM->UPM effect and have no other conversions to perform then
|
||||||
// there is no longer any point to using the scratch.
|
// there is no longer any point to using the scratch.
|
||||||
if (effectInstalled || flipY || swapRAndB) {
|
if (NULL != effect || flipY || swapRAndB) {
|
||||||
if (!effectInstalled) {
|
if (!effect) {
|
||||||
SkAssertResult(GrConfigConversionEffect::InstallEffect(
|
effect.reset(GrConfigConversionEffect::Create(
|
||||||
src,
|
src,
|
||||||
swapRAndB,
|
swapRAndB,
|
||||||
GrConfigConversionEffect::kNone_PMConversion,
|
GrConfigConversionEffect::kNone_PMConversion,
|
||||||
textureMatrix,
|
textureMatrix));
|
||||||
&stage));
|
|
||||||
}
|
}
|
||||||
swapRAndB = false; // we will handle the swap in the draw.
|
swapRAndB = false; // we will handle the swap in the draw.
|
||||||
flipY = false; // we already incorporated the y flip in the matrix
|
flipY = false; // we already incorporated the y flip in the matrix
|
||||||
|
|
||||||
GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
|
GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
|
||||||
GrDrawState* drawState = fGpu->drawState();
|
GrDrawState* drawState = fGpu->drawState();
|
||||||
*drawState->stage(0) = stage;
|
GrAssert(effect);
|
||||||
|
*drawState->setEffect(0, effect);
|
||||||
|
|
||||||
drawState->setRenderTarget(texture->asRenderTarget());
|
drawState->setRenderTarget(texture->asRenderTarget());
|
||||||
GrRect rect = GrRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
|
GrRect rect = GrRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
|
||||||
@ -1503,7 +1502,7 @@ void GrContext::copyTexture(GrTexture* src, GrRenderTarget* dst, const SkIPoint*
|
|||||||
|
|
||||||
// Writes pending to the source texture are not tracked, so a flush
|
// Writes pending to the source texture are not tracked, so a flush
|
||||||
// is required to ensure that the copy captures the most recent contents
|
// is required to ensure that the copy captures the most recent contents
|
||||||
// of the source texture. See similar behaviour in
|
// of the source texture. See similar behavior in
|
||||||
// GrContext::resolveRenderTarget.
|
// GrContext::resolveRenderTarget.
|
||||||
this->flush();
|
this->flush();
|
||||||
|
|
||||||
@ -1584,23 +1583,19 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrEffectStage stage;
|
SkAutoTUnref<const GrEffectRef> effect;
|
||||||
SkMatrix textureMatrix;
|
SkMatrix textureMatrix;
|
||||||
textureMatrix.setIDiv(texture->width(), texture->height());
|
textureMatrix.setIDiv(texture->width(), texture->height());
|
||||||
|
|
||||||
// allocate a tmp buffer and sw convert the pixels to premul
|
// allocate a tmp buffer and sw convert the pixels to premul
|
||||||
SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0);
|
SkAutoSTMalloc<128 * 128, uint32_t> tmpPixels(0);
|
||||||
|
|
||||||
bool effectInstalled = false;
|
|
||||||
if (kUnpremul_PixelOpsFlag & flags) {
|
if (kUnpremul_PixelOpsFlag & flags) {
|
||||||
if (kRGBA_8888_GrPixelConfig != config && kBGRA_8888_GrPixelConfig != config) {
|
if (kRGBA_8888_GrPixelConfig != config && kBGRA_8888_GrPixelConfig != config) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
effectInstalled = this->installUPMToPMEffect(texture,
|
effect.reset(this->createUPMToPMEffect(texture, swapRAndB, textureMatrix));
|
||||||
swapRAndB,
|
if (NULL == effect) {
|
||||||
textureMatrix,
|
|
||||||
&stage);
|
|
||||||
if (!effectInstalled) {
|
|
||||||
SkCanvas::Config8888 srcConfig8888, dstConfig8888;
|
SkCanvas::Config8888 srcConfig8888, dstConfig8888;
|
||||||
GR_DEBUGCODE(bool success = )
|
GR_DEBUGCODE(bool success = )
|
||||||
grconfig_to_config8888(config, true, &srcConfig8888);
|
grconfig_to_config8888(config, true, &srcConfig8888);
|
||||||
@ -1617,13 +1612,11 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
|
|||||||
rowBytes = 4 * width;
|
rowBytes = 4 * width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!effectInstalled) {
|
if (NULL == effect) {
|
||||||
SkAssertResult(GrConfigConversionEffect::InstallEffect(
|
effect.reset(GrConfigConversionEffect::Create(texture,
|
||||||
texture,
|
|
||||||
swapRAndB,
|
swapRAndB,
|
||||||
GrConfigConversionEffect::kNone_PMConversion,
|
GrConfigConversionEffect::kNone_PMConversion,
|
||||||
textureMatrix,
|
textureMatrix));
|
||||||
&stage));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->writeTexturePixels(texture,
|
this->writeTexturePixels(texture,
|
||||||
@ -1633,7 +1626,8 @@ void GrContext::writeRenderTargetPixels(GrRenderTarget* target,
|
|||||||
|
|
||||||
GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
|
GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
|
||||||
GrDrawState* drawState = fGpu->drawState();
|
GrDrawState* drawState = fGpu->drawState();
|
||||||
*drawState->stage(0) = stage;
|
GrAssert(effect);
|
||||||
|
*drawState->setEffect(0, effect);
|
||||||
|
|
||||||
SkMatrix matrix;
|
SkMatrix matrix;
|
||||||
matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
|
matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
|
||||||
@ -1822,10 +1816,9 @@ void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrContext::installPMToUPMEffect(GrTexture* texture,
|
const GrEffectRef* GrContext::createPMToUPMEffect(GrTexture* texture,
|
||||||
bool swapRAndB,
|
bool swapRAndB,
|
||||||
const SkMatrix& matrix,
|
const SkMatrix& matrix) {
|
||||||
GrEffectStage* stage) {
|
|
||||||
if (!fDidTestPMConversions) {
|
if (!fDidTestPMConversions) {
|
||||||
test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
|
test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
|
||||||
fDidTestPMConversions = true;
|
fDidTestPMConversions = true;
|
||||||
@ -1833,17 +1826,15 @@ bool GrContext::installPMToUPMEffect(GrTexture* texture,
|
|||||||
GrConfigConversionEffect::PMConversion pmToUPM =
|
GrConfigConversionEffect::PMConversion pmToUPM =
|
||||||
static_cast<GrConfigConversionEffect::PMConversion>(fPMToUPMConversion);
|
static_cast<GrConfigConversionEffect::PMConversion>(fPMToUPMConversion);
|
||||||
if (GrConfigConversionEffect::kNone_PMConversion != pmToUPM) {
|
if (GrConfigConversionEffect::kNone_PMConversion != pmToUPM) {
|
||||||
GrConfigConversionEffect::InstallEffect(texture, swapRAndB, pmToUPM, matrix, stage);
|
return GrConfigConversionEffect::Create(texture, swapRAndB, pmToUPM, matrix);
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrContext::installUPMToPMEffect(GrTexture* texture,
|
const GrEffectRef* GrContext::createUPMToPMEffect(GrTexture* texture,
|
||||||
bool swapRAndB,
|
bool swapRAndB,
|
||||||
const SkMatrix& matrix,
|
const SkMatrix& matrix) {
|
||||||
GrEffectStage* stage) {
|
|
||||||
if (!fDidTestPMConversions) {
|
if (!fDidTestPMConversions) {
|
||||||
test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
|
test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
|
||||||
fDidTestPMConversions = true;
|
fDidTestPMConversions = true;
|
||||||
@ -1851,10 +1842,9 @@ bool GrContext::installUPMToPMEffect(GrTexture* texture,
|
|||||||
GrConfigConversionEffect::PMConversion upmToPM =
|
GrConfigConversionEffect::PMConversion upmToPM =
|
||||||
static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion);
|
static_cast<GrConfigConversionEffect::PMConversion>(fUPMToPMConversion);
|
||||||
if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) {
|
if (GrConfigConversionEffect::kNone_PMConversion != upmToPM) {
|
||||||
GrConfigConversionEffect::InstallEffect(texture, swapRAndB, upmToPM, matrix, stage);
|
return GrConfigConversionEffect::Create(texture, swapRAndB, upmToPM, matrix);
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,9 @@ void GrDrawState::setFromPaint(const GrPaint& paint) {
|
|||||||
for (int i = 0; i < GrPaint::kMaxColorStages; ++i) {
|
for (int i = 0; i < GrPaint::kMaxColorStages; ++i) {
|
||||||
int s = i + GrPaint::kFirstColorStage;
|
int s = i + GrPaint::kFirstColorStage;
|
||||||
if (paint.isColorStageEnabled(i)) {
|
if (paint.isColorStageEnabled(i)) {
|
||||||
*this->stage(s) = paint.getColorStage(i);
|
fStages[s] = paint.getColorStage(i);
|
||||||
|
} else {
|
||||||
|
fStages[s].setEffect(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,7 +24,9 @@ void GrDrawState::setFromPaint(const GrPaint& paint) {
|
|||||||
for (int i = 0; i < GrPaint::kMaxCoverageStages; ++i) {
|
for (int i = 0; i < GrPaint::kMaxCoverageStages; ++i) {
|
||||||
int s = i + GrPaint::kFirstCoverageStage;
|
int s = i + GrPaint::kFirstCoverageStage;
|
||||||
if (paint.isCoverageStageEnabled(i)) {
|
if (paint.isCoverageStageEnabled(i)) {
|
||||||
*this->stage(s) = paint.getCoverageStage(i);
|
fStages[s] = paint.getCoverageStage(i);
|
||||||
|
} else {
|
||||||
|
fStages[s].setEffect(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +52,7 @@ void GrDrawState::AutoViewMatrixRestore::restore() {
|
|||||||
fDrawState->setViewMatrix(fViewMatrix);
|
fDrawState->setViewMatrix(fViewMatrix);
|
||||||
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
||||||
if (fRestoreMask & (1 << s)) {
|
if (fRestoreMask & (1 << s)) {
|
||||||
fDrawState->stage(s)->restoreCoordChange(fSavedCoordChanges[s]);
|
fDrawState->fStages[s].restoreCoordChange(fSavedCoordChanges[s]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,8 +75,8 @@ void GrDrawState::AutoViewMatrixRestore::set(GrDrawState* drawState,
|
|||||||
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
||||||
if (!(explicitCoordStageMask & (1 << s)) && drawState->isStageEnabled(s)) {
|
if (!(explicitCoordStageMask & (1 << s)) && drawState->isStageEnabled(s)) {
|
||||||
fRestoreMask |= (1 << s);
|
fRestoreMask |= (1 << s);
|
||||||
fDrawState->stage(s)->saveCoordChange(&fSavedCoordChanges[s]);
|
fDrawState->fStages[s].saveCoordChange(&fSavedCoordChanges[s]);
|
||||||
drawState->stage(s)->preConcatCoordChange(preconcatMatrix);
|
drawState->fStages[s].preConcatCoordChange(preconcatMatrix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,7 +88,7 @@ void GrDrawState::AutoDeviceCoordDraw::restore() {
|
|||||||
fDrawState->setViewMatrix(fViewMatrix);
|
fDrawState->setViewMatrix(fViewMatrix);
|
||||||
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
|
||||||
if (fRestoreMask & (1 << s)) {
|
if (fRestoreMask & (1 << s)) {
|
||||||
fDrawState->stage(s)->restoreCoordChange(fSavedCoordChanges[s]);
|
fDrawState->fStages[s].restoreCoordChange(fSavedCoordChanges[s]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,7 +121,7 @@ bool GrDrawState::AutoDeviceCoordDraw::set(GrDrawState* drawState,
|
|||||||
inverted = true;
|
inverted = true;
|
||||||
}
|
}
|
||||||
fRestoreMask |= (1 << s);
|
fRestoreMask |= (1 << s);
|
||||||
GrEffectStage* stage = drawState->stage(s);
|
GrEffectStage* stage = drawState->fStages + s;
|
||||||
stage->saveCoordChange(&fSavedCoordChanges[s]);
|
stage->saveCoordChange(&fSavedCoordChanges[s]);
|
||||||
stage->preConcatCoordChange(invVM);
|
stage->preConcatCoordChange(invVM);
|
||||||
}
|
}
|
||||||
|
@ -185,16 +185,21 @@ public:
|
|||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
/// @name Textures
|
/// @name Effect Stages
|
||||||
////
|
////
|
||||||
|
|
||||||
|
const GrEffectRef* setEffect(int stageIdx, const GrEffectRef* effect) {
|
||||||
|
fStages[stageIdx].setEffect(effect);
|
||||||
|
return effect;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a GrSimpleTextureEffect.
|
* Creates a GrSimpleTextureEffect.
|
||||||
*/
|
*/
|
||||||
void createTextureEffect(int stageIdx, GrTexture* texture, const SkMatrix& matrix) {
|
void createTextureEffect(int stageIdx, GrTexture* texture, const SkMatrix& matrix) {
|
||||||
GrAssert(!this->getStage(stageIdx).getEffect());
|
GrAssert(!this->getStage(stageIdx).getEffect());
|
||||||
GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix);
|
GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix);
|
||||||
this->stage(stageIdx)->setEffect(effect)->unref();
|
this->setEffect(stageIdx, effect)->unref();
|
||||||
}
|
}
|
||||||
void createTextureEffect(int stageIdx,
|
void createTextureEffect(int stageIdx,
|
||||||
GrTexture* texture,
|
GrTexture* texture,
|
||||||
@ -202,7 +207,7 @@ public:
|
|||||||
const GrTextureParams& params) {
|
const GrTextureParams& params) {
|
||||||
GrAssert(!this->getStage(stageIdx).getEffect());
|
GrAssert(!this->getStage(stageIdx).getEffect());
|
||||||
GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, params);
|
GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, params);
|
||||||
this->stage(stageIdx)->setEffect(effect)->unref();
|
this->setEffect(stageIdx, effect)->unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool stagesDisabled() {
|
bool stagesDisabled() {
|
||||||
@ -214,9 +219,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void disableStage(int stageIdx) {
|
void disableStage(int stageIdx) { this->setEffect(stageIdx, NULL); }
|
||||||
fStages[stageIdx].setEffect(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Release all the GrEffects referred to by this draw state.
|
* Release all the GrEffects referred to by this draw state.
|
||||||
@ -239,12 +242,6 @@ public:
|
|||||||
GrDrawState* fDrawState;
|
GrDrawState* fDrawState;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @name Stages
|
|
||||||
////
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current stage by index.
|
* Returns the current stage by index.
|
||||||
*/
|
*/
|
||||||
@ -253,14 +250,6 @@ public:
|
|||||||
return fStages[stageIdx];
|
return fStages[stageIdx];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Writable pointer to a stage.
|
|
||||||
*/
|
|
||||||
GrEffectStage* stage(int stageIdx) {
|
|
||||||
GrAssert((unsigned)stageIdx < kNumStages);
|
|
||||||
return fStages + stageIdx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the source coord system is changing. preConcat gives the transformation from the
|
* Called when the source coord system is changing. preConcat gives the transformation from the
|
||||||
* old coord system to the new coord system.
|
* old coord system to the new coord system.
|
||||||
|
@ -197,7 +197,6 @@ void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
|
|||||||
kPathMaskStage = GrPaint::kTotalStages,
|
kPathMaskStage = GrPaint::kTotalStages,
|
||||||
};
|
};
|
||||||
GrAssert(!drawState->isStageEnabled(kPathMaskStage));
|
GrAssert(!drawState->isStageEnabled(kPathMaskStage));
|
||||||
drawState->stage(kPathMaskStage)->reset();
|
|
||||||
drawState->createTextureEffect(kPathMaskStage, texture, SkMatrix::I());
|
drawState->createTextureEffect(kPathMaskStage, texture, SkMatrix::I());
|
||||||
SkScalar w = SkIntToScalar(rect.width());
|
SkScalar w = SkIntToScalar(rect.width());
|
||||||
SkScalar h = SkIntToScalar(rect.height());
|
SkScalar h = SkIntToScalar(rect.height());
|
||||||
|
@ -30,8 +30,6 @@ void GrTextContext::flushGlyphs() {
|
|||||||
GrDrawState* drawState = fDrawTarget->drawState();
|
GrDrawState* drawState = fDrawTarget->drawState();
|
||||||
if (fCurrVertex > 0) {
|
if (fCurrVertex > 0) {
|
||||||
// setup our sampler state for our text texture/atlas
|
// setup our sampler state for our text texture/atlas
|
||||||
drawState->stage(kGlyphMaskStage)->reset();
|
|
||||||
|
|
||||||
GrAssert(GrIsALIGN4(fCurrVertex));
|
GrAssert(GrIsALIGN4(fCurrVertex));
|
||||||
GrAssert(fCurrTexture);
|
GrAssert(fCurrTexture);
|
||||||
GrTextureParams params(SkShader::kRepeat_TileMode, false);
|
GrTextureParams params(SkShader::kRepeat_TileMode, false);
|
||||||
|
@ -261,29 +261,26 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrConfigConversionEffect::InstallEffect(GrTexture* texture,
|
const GrEffectRef* GrConfigConversionEffect::Create(GrTexture* texture,
|
||||||
bool swapRedAndBlue,
|
bool swapRedAndBlue,
|
||||||
PMConversion pmConversion,
|
PMConversion pmConversion,
|
||||||
const SkMatrix& matrix,
|
const SkMatrix& matrix) {
|
||||||
GrEffectStage* stage) {
|
|
||||||
if (!swapRedAndBlue && kNone_PMConversion == pmConversion) {
|
if (!swapRedAndBlue && kNone_PMConversion == pmConversion) {
|
||||||
// If we returned a GrConfigConversionEffect that was equivalent to a GrSingleTextureEffect
|
// If we returned a GrConfigConversionEffect that was equivalent to a GrSimpleTextureEffect
|
||||||
// then we may pollute our texture cache with redundant shaders. So in the case that no
|
// then we may pollute our texture cache with redundant shaders. So in the case that no
|
||||||
// conversions were requested we instead return a GrSingleTextureEffect.
|
// conversions were requested we instead return a GrSimpleTextureEffect.
|
||||||
stage->setEffect(GrSimpleTextureEffect::Create(texture, matrix))->unref();
|
return GrSimpleTextureEffect::Create(texture, matrix);
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
if (kRGBA_8888_GrPixelConfig != texture->config() &&
|
if (kRGBA_8888_GrPixelConfig != texture->config() &&
|
||||||
kBGRA_8888_GrPixelConfig != texture->config() &&
|
kBGRA_8888_GrPixelConfig != texture->config() &&
|
||||||
kNone_PMConversion != pmConversion) {
|
kNone_PMConversion != pmConversion) {
|
||||||
// The PM conversions assume colors are 0..255
|
// The PM conversions assume colors are 0..255
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
AutoEffectUnref effect(SkNEW_ARGS(GrConfigConversionEffect, (texture,
|
AutoEffectUnref effect(SkNEW_ARGS(GrConfigConversionEffect, (texture,
|
||||||
swapRedAndBlue,
|
swapRedAndBlue,
|
||||||
pmConversion,
|
pmConversion,
|
||||||
matrix)));
|
matrix)));
|
||||||
stage->setEffect(CreateEffectRef(effect))->unref();
|
return CreateEffectRef(effect);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Installs an effect in the GrEffectStage to perform a config conversion.
|
// Installs an effect in the GrEffectStage to perform a config conversion.
|
||||||
static bool InstallEffect(GrTexture*,
|
static const GrEffectRef* Create(GrTexture*,
|
||||||
bool swapRedAndBlue,
|
bool swapRedAndBlue,
|
||||||
PMConversion pmConversion,
|
PMConversion pmConversion,
|
||||||
const SkMatrix& matrix,
|
const SkMatrix& matrix);
|
||||||
GrEffectStage* stage);
|
|
||||||
|
|
||||||
static const char* Name() { return "Config Conversion"; }
|
static const char* Name() { return "Config Conversion"; }
|
||||||
typedef GrGLConfigConversionEffect GLEffect;
|
typedef GrGLConfigConversionEffect GLEffect;
|
||||||
|
@ -169,12 +169,10 @@ void forceLinking();
|
|||||||
void forceLinking() {
|
void forceLinking() {
|
||||||
SkLightingImageFilter::CreateDistantLitDiffuse(SkPoint3(0,0,0), 0, 0, 0);
|
SkLightingImageFilter::CreateDistantLitDiffuse(SkPoint3(0,0,0), 0, 0, 0);
|
||||||
SkMagnifierImageFilter mag(SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1);
|
SkMagnifierImageFilter mag(SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1);
|
||||||
GrEffectStage dummyStage;
|
GrConfigConversionEffect::Create(NULL,
|
||||||
GrConfigConversionEffect::InstallEffect(NULL,
|
|
||||||
false,
|
false,
|
||||||
GrConfigConversionEffect::kNone_PMConversion,
|
GrConfigConversionEffect::kNone_PMConversion,
|
||||||
SkMatrix::I(),
|
SkMatrix::I());
|
||||||
&dummyStage);
|
|
||||||
SkScalar matrix[20];
|
SkScalar matrix[20];
|
||||||
SkColorMatrixFilter cmf(matrix);
|
SkColorMatrixFilter cmf(matrix);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user