Remove shadersupport caps bit

Review URL: http://codereview.appspot.com/5528076/



git-svn-id: http://skia.googlecode.com/svn/trunk@3015 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bsalomon@google.com 2012-01-11 18:45:39 +00:00
parent 3d19c385e7
commit dafde9e2c1
6 changed files with 34 additions and 90 deletions

View File

@ -450,11 +450,6 @@ public:
///////////////////////////////////////////////////////////////////////////
// Misc.
/**
* Currently needed by SkGpuDevice. Ideally this shouldn't be exposed.
*/
bool supportsShaders() const;
/**
* Flags that affect flush() behavior.
*/

View File

@ -676,7 +676,6 @@ inline bool disable_coverage_aa_for_blend(GrDrawTarget* target) {
struct GrContext::OffscreenRecord {
enum Downsample {
k4x4TwoPass_Downsample,
k4x4SinglePass_Downsample,
kFSAA_Downsample
} fDownsample;
@ -685,8 +684,7 @@ struct GrContext::OffscreenRecord {
int fTileCountX;
int fTileCountY;
int fScale;
GrAutoScratchTexture fOffscreen0;
GrAutoScratchTexture fOffscreen1;
GrAutoScratchTexture fOffscreen;
GrDrawTarget::SavedDrawState fSavedState;
GrClip fClip;
};
@ -749,9 +747,7 @@ bool GrContext::prepareForOffscreenAA(GrDrawTarget* target,
record->fScale = 1;
desc.fAALevel = kMed_GrAALevel;
} else {
record->fDownsample = fGpu->getCaps().fShaderSupport ?
OffscreenRecord::k4x4SinglePass_Downsample :
OffscreenRecord::k4x4TwoPass_Downsample;
record->fDownsample = OffscreenRecord::k4x4SinglePass_Downsample;
record->fScale = OFFSCREEN_SSAA_SCALE;
// both downsample paths assume this
GR_STATIC_ASSERT(4 == OFFSCREEN_SSAA_SCALE);
@ -760,29 +756,17 @@ bool GrContext::prepareForOffscreenAA(GrDrawTarget* target,
desc.fWidth *= record->fScale;
desc.fHeight *= record->fScale;
record->fOffscreen0.set(this, desc);
if (NULL == record->fOffscreen0.texture()) {
record->fOffscreen.set(this, desc);
if (NULL == record->fOffscreen.texture()) {
return false;
}
// the approximate lookup might have given us some slop space, might as well
// use it when computing the tiles size.
// these are scale values, will adjust after considering
// the possible second offscreen.
record->fTileSizeX = record->fOffscreen0.texture()->width();
record->fTileSizeY = record->fOffscreen0.texture()->height();
record->fTileSizeX = record->fOffscreen.texture()->width();
record->fTileSizeY = record->fOffscreen.texture()->height();
if (OffscreenRecord::k4x4TwoPass_Downsample == record->fDownsample) {
desc.fWidth /= 2;
desc.fHeight /= 2;
record->fOffscreen1.set(this, desc);
if (NULL == record->fOffscreen1.texture()) {
return false;
}
record->fTileSizeX = GrMin(record->fTileSizeX,
2 * record->fOffscreen0.texture()->width());
record->fTileSizeY = GrMin(record->fTileSizeY,
2 * record->fOffscreen0.texture()->height());
}
record->fTileSizeX /= record->fScale;
record->fTileSizeY /= record->fScale;
@ -800,14 +784,14 @@ void GrContext::setupOffscreenAAPass1(GrDrawTarget* target,
int tileX, int tileY,
OffscreenRecord* record) {
GrRenderTarget* offRT0 = record->fOffscreen0.texture()->asRenderTarget();
GrAssert(NULL != offRT0);
GrRenderTarget* offRT = record->fOffscreen.texture()->asRenderTarget();
GrAssert(NULL != offRT);
GrPaint tempPaint;
tempPaint.reset();
this->setPaint(tempPaint, target);
GrDrawState* drawState = target->drawState();
drawState->setRenderTarget(offRT0);
drawState->setRenderTarget(offRT);
#if PREFER_MSAA_OFFSCREEN_AA
drawState->enableState(GrDrawState::kHWAntialias_StateBit);
#endif
@ -868,7 +852,7 @@ void GrContext::doOffscreenAAPass2(GrDrawTarget* target,
filter = GrSamplerState::kBilinear_Filter;
}
GrTexture* src = record->fOffscreen0.texture();
GrTexture* src = record->fOffscreen.texture();
int scale;
enum {
@ -877,25 +861,7 @@ void GrContext::doOffscreenAAPass2(GrDrawTarget* target,
GrDrawState* drawState = target->drawState();
if (OffscreenRecord::k4x4TwoPass_Downsample == record->fDownsample) {
GrAssert(NULL != record->fOffscreen1.texture());
scale = 2;
GrRenderTarget* dst = record->fOffscreen1.texture()->asRenderTarget();
// Do 2x2 downsample from first to second
drawState->setTexture(kOffscreenStage, src);
drawState->setRenderTarget(dst);
drawState->setViewMatrix(GrMatrix::I());
GrSamplerState* sampler = drawState->sampler(kOffscreenStage);
sampler->reset(GrSamplerState::kClamp_WrapMode, filter);
sampler->matrix()->setScale(scale * GR_Scalar1 / src->width(),
scale * GR_Scalar1 / src->height());
GrRect rect = SkRect::MakeWH(SkIntToScalar(scale * tileRect.width()),
SkIntToScalar(scale * tileRect.height()));
target->drawSimpleRect(rect, NULL, 1 << kOffscreenStage);
src = record->fOffscreen1.texture();
} else if (OffscreenRecord::kFSAA_Downsample == record->fDownsample) {
if (OffscreenRecord::kFSAA_Downsample == record->fDownsample) {
scale = 1;
GrIRect rect = SkIRect::MakeWH(tileRect.width(), tileRect.height());
src->asRenderTarget()->overrideResolveRect(rect);
@ -1612,10 +1578,6 @@ void GrContext::drawPath(const GrPaint& paint, const GrPath& path,
////////////////////////////////////////////////////////////////////////////////
bool GrContext::supportsShaders() const {
return fGpu->getCaps().fShaderSupport;
}
void GrContext::flush(int flagsBitfield) {
if (kDiscard_FlushBit & flagsBitfield) {
fDrawBuffer->reset();

View File

@ -888,12 +888,8 @@ GrDrawTarget::getBlendOpts(bool forceCoverage,
// (0,1).
if ((kZero_BlendCoeff == *srcCoeff && dstCoeffIsOne)) {
if (drawState.getStencil().doesWrite()) {
if (fCaps.fShaderSupport) {
return kDisableBlend_BlendOptFlag |
kEmitTransBlack_BlendOptFlag;
} else {
return kDisableBlend_BlendOptFlag;
}
return kDisableBlend_BlendOptFlag |
kEmitTransBlack_BlendOptFlag;
} else {
return kSkipDraw_BlendOptFlag;
}
@ -920,8 +916,7 @@ GrDrawTarget::getBlendOpts(bool forceCoverage,
// if there is no coverage and coeffs are (1,0) then we
// won't need to read the dst at all, it gets replaced by src
return kDisableBlend_BlendOptFlag;
} else if (kZero_BlendCoeff == *srcCoeff &&
fCaps.fShaderSupport) {
} else if (kZero_BlendCoeff == *srcCoeff) {
// if the op is "clear" then we don't need to emit a color
// or blend, just write transparent black into the dst.
*srcCoeff = kOne_BlendCoeff;
@ -936,30 +931,26 @@ GrDrawTarget::getBlendOpts(bool forceCoverage,
if (this->canTweakAlphaForCoverage()) {
return kCoverageAsAlpha_BlendOptFlag;
}
// We haven't implemented support for these optimizations in the
// fixed pipe (which is on its deathbed)
if (fCaps.fShaderSupport) {
if (dstCoeffIsZero) {
if (kZero_BlendCoeff == *srcCoeff) {
// the source color is not included in the blend
// the dst coeff is effectively zero so blend works out to:
// (c)(0)D + (1-c)D = (1-c)D.
*dstCoeff = kISA_BlendCoeff;
return kEmitCoverage_BlendOptFlag;
} else if (srcAIsOne) {
// the dst coeff is effectively zero so blend works out to:
// cS + (c)(0)D + (1-c)D = cS + (1-c)D.
// If Sa is 1 then we can replace Sa with c
// and set dst coeff to 1-Sa.
*dstCoeff = kISA_BlendCoeff;
return kCoverageAsAlpha_BlendOptFlag;
}
} else if (dstCoeffIsOne) {
// the dst coeff is effectively one so blend works out to:
// cS + (c)(1)D + (1-c)D = cS + D.
*dstCoeff = kOne_BlendCoeff;
if (dstCoeffIsZero) {
if (kZero_BlendCoeff == *srcCoeff) {
// the source color is not included in the blend
// the dst coeff is effectively zero so blend works out to:
// (c)(0)D + (1-c)D = (1-c)D.
*dstCoeff = kISA_BlendCoeff;
return kEmitCoverage_BlendOptFlag;
} else if (srcAIsOne) {
// the dst coeff is effectively zero so blend works out to:
// cS + (c)(0)D + (1-c)D = cS + (1-c)D.
// If Sa is 1 then we can replace Sa with c
// and set dst coeff to 1-Sa.
*dstCoeff = kISA_BlendCoeff;
return kCoverageAsAlpha_BlendOptFlag;
}
} else if (dstCoeffIsOne) {
// the dst coeff is effectively one so blend works out to:
// cS + (c)(1)D + (1-c)D = cS + D.
*dstCoeff = kOne_BlendCoeff;
return kCoverageAsAlpha_BlendOptFlag;
}
}
return kNone_BlendOpt;
@ -1213,7 +1204,6 @@ void GrDrawTarget::Caps::print() const {
GrPrintf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]);
GrPrintf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport]);
GrPrintf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]);
GrPrintf("Shader Support : %s\n", gNY[fShaderSupport]);
GrPrintf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport]);
GrPrintf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]);
GrPrintf("FSAA Support : %s\n", gNY[fFSAASupport]);

View File

@ -45,7 +45,6 @@ public:
bool fTwoSidedStencilSupport : 1;
bool fStencilWrapOpsSupport : 1;
bool fHWAALineSupport : 1;
bool fShaderSupport : 1;
bool fShaderDerivativeSupport : 1;
bool fGeometryShaderSupport : 1;
bool fFSAASupport : 1;

View File

@ -309,8 +309,7 @@ GrGpuGLShaders::GrGpuGLShaders(const GrGLInterface* gl)
GrGLSLGeneration glslGeneration =
GetGLSLGeneration(this->glBinding(), gl);
// Enable supported shader-releated caps
fCaps.fShaderSupport = true;
// Enable supported shader-related caps
fCaps.fSupportPerVertexCoverage = true;
if (kDesktop_GrGLBinding == this->glBinding()) {
fCaps.fDualSourceBlendingSupport =

View File

@ -856,8 +856,7 @@ static bool drawWithGPUMaskFilter(GrContext* context, const SkPath& path,
#endif
SkMaskFilter::BlurInfo info;
SkMaskFilter::BlurType blurType = filter->asABlur(&info);
if (SkMaskFilter::kNone_BlurType == blurType ||
!context->supportsShaders()) {
if (SkMaskFilter::kNone_BlurType == blurType) {
return false;
}
SkScalar radius = info.fIgnoreTransform ? info.fRadius