зеркало из https://github.com/mozilla/moz-skia.git
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:
Родитель
3d19c385e7
Коммит
dafde9e2c1
|
@ -450,11 +450,6 @@ public:
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Misc.
|
// Misc.
|
||||||
|
|
||||||
/**
|
|
||||||
* Currently needed by SkGpuDevice. Ideally this shouldn't be exposed.
|
|
||||||
*/
|
|
||||||
bool supportsShaders() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flags that affect flush() behavior.
|
* Flags that affect flush() behavior.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -676,7 +676,6 @@ inline bool disable_coverage_aa_for_blend(GrDrawTarget* target) {
|
||||||
|
|
||||||
struct GrContext::OffscreenRecord {
|
struct GrContext::OffscreenRecord {
|
||||||
enum Downsample {
|
enum Downsample {
|
||||||
k4x4TwoPass_Downsample,
|
|
||||||
k4x4SinglePass_Downsample,
|
k4x4SinglePass_Downsample,
|
||||||
kFSAA_Downsample
|
kFSAA_Downsample
|
||||||
} fDownsample;
|
} fDownsample;
|
||||||
|
@ -685,8 +684,7 @@ struct GrContext::OffscreenRecord {
|
||||||
int fTileCountX;
|
int fTileCountX;
|
||||||
int fTileCountY;
|
int fTileCountY;
|
||||||
int fScale;
|
int fScale;
|
||||||
GrAutoScratchTexture fOffscreen0;
|
GrAutoScratchTexture fOffscreen;
|
||||||
GrAutoScratchTexture fOffscreen1;
|
|
||||||
GrDrawTarget::SavedDrawState fSavedState;
|
GrDrawTarget::SavedDrawState fSavedState;
|
||||||
GrClip fClip;
|
GrClip fClip;
|
||||||
};
|
};
|
||||||
|
@ -749,9 +747,7 @@ bool GrContext::prepareForOffscreenAA(GrDrawTarget* target,
|
||||||
record->fScale = 1;
|
record->fScale = 1;
|
||||||
desc.fAALevel = kMed_GrAALevel;
|
desc.fAALevel = kMed_GrAALevel;
|
||||||
} else {
|
} else {
|
||||||
record->fDownsample = fGpu->getCaps().fShaderSupport ?
|
record->fDownsample = OffscreenRecord::k4x4SinglePass_Downsample;
|
||||||
OffscreenRecord::k4x4SinglePass_Downsample :
|
|
||||||
OffscreenRecord::k4x4TwoPass_Downsample;
|
|
||||||
record->fScale = OFFSCREEN_SSAA_SCALE;
|
record->fScale = OFFSCREEN_SSAA_SCALE;
|
||||||
// both downsample paths assume this
|
// both downsample paths assume this
|
||||||
GR_STATIC_ASSERT(4 == OFFSCREEN_SSAA_SCALE);
|
GR_STATIC_ASSERT(4 == OFFSCREEN_SSAA_SCALE);
|
||||||
|
@ -760,29 +756,17 @@ bool GrContext::prepareForOffscreenAA(GrDrawTarget* target,
|
||||||
|
|
||||||
desc.fWidth *= record->fScale;
|
desc.fWidth *= record->fScale;
|
||||||
desc.fHeight *= record->fScale;
|
desc.fHeight *= record->fScale;
|
||||||
record->fOffscreen0.set(this, desc);
|
record->fOffscreen.set(this, desc);
|
||||||
if (NULL == record->fOffscreen0.texture()) {
|
if (NULL == record->fOffscreen.texture()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// the approximate lookup might have given us some slop space, might as well
|
// the approximate lookup might have given us some slop space, might as well
|
||||||
// use it when computing the tiles size.
|
// use it when computing the tiles size.
|
||||||
// these are scale values, will adjust after considering
|
// these are scale values, will adjust after considering
|
||||||
// the possible second offscreen.
|
// the possible second offscreen.
|
||||||
record->fTileSizeX = record->fOffscreen0.texture()->width();
|
record->fTileSizeX = record->fOffscreen.texture()->width();
|
||||||
record->fTileSizeY = record->fOffscreen0.texture()->height();
|
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->fTileSizeX /= record->fScale;
|
||||||
record->fTileSizeY /= record->fScale;
|
record->fTileSizeY /= record->fScale;
|
||||||
|
|
||||||
|
@ -800,14 +784,14 @@ void GrContext::setupOffscreenAAPass1(GrDrawTarget* target,
|
||||||
int tileX, int tileY,
|
int tileX, int tileY,
|
||||||
OffscreenRecord* record) {
|
OffscreenRecord* record) {
|
||||||
|
|
||||||
GrRenderTarget* offRT0 = record->fOffscreen0.texture()->asRenderTarget();
|
GrRenderTarget* offRT = record->fOffscreen.texture()->asRenderTarget();
|
||||||
GrAssert(NULL != offRT0);
|
GrAssert(NULL != offRT);
|
||||||
|
|
||||||
GrPaint tempPaint;
|
GrPaint tempPaint;
|
||||||
tempPaint.reset();
|
tempPaint.reset();
|
||||||
this->setPaint(tempPaint, target);
|
this->setPaint(tempPaint, target);
|
||||||
GrDrawState* drawState = target->drawState();
|
GrDrawState* drawState = target->drawState();
|
||||||
drawState->setRenderTarget(offRT0);
|
drawState->setRenderTarget(offRT);
|
||||||
#if PREFER_MSAA_OFFSCREEN_AA
|
#if PREFER_MSAA_OFFSCREEN_AA
|
||||||
drawState->enableState(GrDrawState::kHWAntialias_StateBit);
|
drawState->enableState(GrDrawState::kHWAntialias_StateBit);
|
||||||
#endif
|
#endif
|
||||||
|
@ -868,7 +852,7 @@ void GrContext::doOffscreenAAPass2(GrDrawTarget* target,
|
||||||
filter = GrSamplerState::kBilinear_Filter;
|
filter = GrSamplerState::kBilinear_Filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrTexture* src = record->fOffscreen0.texture();
|
GrTexture* src = record->fOffscreen.texture();
|
||||||
int scale;
|
int scale;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -877,25 +861,7 @@ void GrContext::doOffscreenAAPass2(GrDrawTarget* target,
|
||||||
|
|
||||||
GrDrawState* drawState = target->drawState();
|
GrDrawState* drawState = target->drawState();
|
||||||
|
|
||||||
if (OffscreenRecord::k4x4TwoPass_Downsample == record->fDownsample) {
|
if (OffscreenRecord::kFSAA_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) {
|
|
||||||
scale = 1;
|
scale = 1;
|
||||||
GrIRect rect = SkIRect::MakeWH(tileRect.width(), tileRect.height());
|
GrIRect rect = SkIRect::MakeWH(tileRect.width(), tileRect.height());
|
||||||
src->asRenderTarget()->overrideResolveRect(rect);
|
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) {
|
void GrContext::flush(int flagsBitfield) {
|
||||||
if (kDiscard_FlushBit & flagsBitfield) {
|
if (kDiscard_FlushBit & flagsBitfield) {
|
||||||
fDrawBuffer->reset();
|
fDrawBuffer->reset();
|
||||||
|
|
|
@ -888,12 +888,8 @@ GrDrawTarget::getBlendOpts(bool forceCoverage,
|
||||||
// (0,1).
|
// (0,1).
|
||||||
if ((kZero_BlendCoeff == *srcCoeff && dstCoeffIsOne)) {
|
if ((kZero_BlendCoeff == *srcCoeff && dstCoeffIsOne)) {
|
||||||
if (drawState.getStencil().doesWrite()) {
|
if (drawState.getStencil().doesWrite()) {
|
||||||
if (fCaps.fShaderSupport) {
|
return kDisableBlend_BlendOptFlag |
|
||||||
return kDisableBlend_BlendOptFlag |
|
kEmitTransBlack_BlendOptFlag;
|
||||||
kEmitTransBlack_BlendOptFlag;
|
|
||||||
} else {
|
|
||||||
return kDisableBlend_BlendOptFlag;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return kSkipDraw_BlendOptFlag;
|
return kSkipDraw_BlendOptFlag;
|
||||||
}
|
}
|
||||||
|
@ -920,8 +916,7 @@ GrDrawTarget::getBlendOpts(bool forceCoverage,
|
||||||
// if there is no coverage and coeffs are (1,0) then we
|
// 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
|
// won't need to read the dst at all, it gets replaced by src
|
||||||
return kDisableBlend_BlendOptFlag;
|
return kDisableBlend_BlendOptFlag;
|
||||||
} else if (kZero_BlendCoeff == *srcCoeff &&
|
} else if (kZero_BlendCoeff == *srcCoeff) {
|
||||||
fCaps.fShaderSupport) {
|
|
||||||
// if the op is "clear" then we don't need to emit a color
|
// if the op is "clear" then we don't need to emit a color
|
||||||
// or blend, just write transparent black into the dst.
|
// or blend, just write transparent black into the dst.
|
||||||
*srcCoeff = kOne_BlendCoeff;
|
*srcCoeff = kOne_BlendCoeff;
|
||||||
|
@ -936,30 +931,26 @@ GrDrawTarget::getBlendOpts(bool forceCoverage,
|
||||||
if (this->canTweakAlphaForCoverage()) {
|
if (this->canTweakAlphaForCoverage()) {
|
||||||
return kCoverageAsAlpha_BlendOptFlag;
|
return kCoverageAsAlpha_BlendOptFlag;
|
||||||
}
|
}
|
||||||
// We haven't implemented support for these optimizations in the
|
if (dstCoeffIsZero) {
|
||||||
// fixed pipe (which is on its deathbed)
|
if (kZero_BlendCoeff == *srcCoeff) {
|
||||||
if (fCaps.fShaderSupport) {
|
// the source color is not included in the blend
|
||||||
if (dstCoeffIsZero) {
|
// the dst coeff is effectively zero so blend works out to:
|
||||||
if (kZero_BlendCoeff == *srcCoeff) {
|
// (c)(0)D + (1-c)D = (1-c)D.
|
||||||
// the source color is not included in the blend
|
*dstCoeff = kISA_BlendCoeff;
|
||||||
// the dst coeff is effectively zero so blend works out to:
|
return kEmitCoverage_BlendOptFlag;
|
||||||
// (c)(0)D + (1-c)D = (1-c)D.
|
} else if (srcAIsOne) {
|
||||||
*dstCoeff = kISA_BlendCoeff;
|
// the dst coeff is effectively zero so blend works out to:
|
||||||
return kEmitCoverage_BlendOptFlag;
|
// cS + (c)(0)D + (1-c)D = cS + (1-c)D.
|
||||||
} else if (srcAIsOne) {
|
// If Sa is 1 then we can replace Sa with c
|
||||||
// the dst coeff is effectively zero so blend works out to:
|
// and set dst coeff to 1-Sa.
|
||||||
// cS + (c)(0)D + (1-c)D = cS + (1-c)D.
|
*dstCoeff = kISA_BlendCoeff;
|
||||||
// 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 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;
|
return kNone_BlendOpt;
|
||||||
|
@ -1213,7 +1204,6 @@ void GrDrawTarget::Caps::print() const {
|
||||||
GrPrintf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]);
|
GrPrintf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]);
|
||||||
GrPrintf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport]);
|
GrPrintf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport]);
|
||||||
GrPrintf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]);
|
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("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport]);
|
||||||
GrPrintf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]);
|
GrPrintf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]);
|
||||||
GrPrintf("FSAA Support : %s\n", gNY[fFSAASupport]);
|
GrPrintf("FSAA Support : %s\n", gNY[fFSAASupport]);
|
||||||
|
|
|
@ -45,7 +45,6 @@ public:
|
||||||
bool fTwoSidedStencilSupport : 1;
|
bool fTwoSidedStencilSupport : 1;
|
||||||
bool fStencilWrapOpsSupport : 1;
|
bool fStencilWrapOpsSupport : 1;
|
||||||
bool fHWAALineSupport : 1;
|
bool fHWAALineSupport : 1;
|
||||||
bool fShaderSupport : 1;
|
|
||||||
bool fShaderDerivativeSupport : 1;
|
bool fShaderDerivativeSupport : 1;
|
||||||
bool fGeometryShaderSupport : 1;
|
bool fGeometryShaderSupport : 1;
|
||||||
bool fFSAASupport : 1;
|
bool fFSAASupport : 1;
|
||||||
|
|
|
@ -309,8 +309,7 @@ GrGpuGLShaders::GrGpuGLShaders(const GrGLInterface* gl)
|
||||||
GrGLSLGeneration glslGeneration =
|
GrGLSLGeneration glslGeneration =
|
||||||
GetGLSLGeneration(this->glBinding(), gl);
|
GetGLSLGeneration(this->glBinding(), gl);
|
||||||
|
|
||||||
// Enable supported shader-releated caps
|
// Enable supported shader-related caps
|
||||||
fCaps.fShaderSupport = true;
|
|
||||||
fCaps.fSupportPerVertexCoverage = true;
|
fCaps.fSupportPerVertexCoverage = true;
|
||||||
if (kDesktop_GrGLBinding == this->glBinding()) {
|
if (kDesktop_GrGLBinding == this->glBinding()) {
|
||||||
fCaps.fDualSourceBlendingSupport =
|
fCaps.fDualSourceBlendingSupport =
|
||||||
|
|
|
@ -856,8 +856,7 @@ static bool drawWithGPUMaskFilter(GrContext* context, const SkPath& path,
|
||||||
#endif
|
#endif
|
||||||
SkMaskFilter::BlurInfo info;
|
SkMaskFilter::BlurInfo info;
|
||||||
SkMaskFilter::BlurType blurType = filter->asABlur(&info);
|
SkMaskFilter::BlurType blurType = filter->asABlur(&info);
|
||||||
if (SkMaskFilter::kNone_BlurType == blurType ||
|
if (SkMaskFilter::kNone_BlurType == blurType) {
|
||||||
!context->supportsShaders()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SkScalar radius = info.fIgnoreTransform ? info.fRadius
|
SkScalar radius = info.fIgnoreTransform ? info.fRadius
|
||||||
|
|
Загрузка…
Ссылка в новой задаче