More prep work in Gr for landing AA hairline renderer.

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



git-svn-id: http://skia.googlecode.com/svn/trunk@2164 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bsalomon@google.com 2011-08-23 20:54:07 +00:00
Родитель 9a87cee904
Коммит 1f221a7021
7 изменённых файлов: 48 добавлений и 15 удалений

Просмотреть файл

@ -182,7 +182,9 @@ public:
/**
* Returns true if the specified use of an indexed texture is supported.
*/
bool supportsIndex8PixelConfig(const GrSamplerState&, int width, int height);
bool supportsIndex8PixelConfig(const GrSamplerState&,
int width,
int height) const;
/**
* Return the current texture cache limits.
@ -386,6 +388,11 @@ public:
///////////////////////////////////////////////////////////////////////////
// Misc.
/**
* Currently needed by SkGpuDevice. Ideally this shouldn't be exposed.
*/
bool supportsShaders() const;
/**
* Flags that affect flush() behavior.
*/
@ -510,6 +517,7 @@ public:
///////////////////////////////////////////////////////////////////////////
// Functions intended for internal use only.
GrGpu* getGpu() { return fGpu; }
const GrGpu* getGpu() const { return fGpu; }
GrFontCache* getFontCache() { return fFontCache; }
GrDrawTarget* getTextTarget(const GrPaint& paint);
void flushText();

Просмотреть файл

@ -31,7 +31,8 @@ public:
* Average of 4 bilinear filterings spaced +/- 1 texel from sample
* position in x and y. Intended for averaging 16 texels in a downsample
* pass. (rasterizing such that texture samples fall exactly halfway
* between texels in x and y spaced 4 texels apart.)
* between texels in x and y spaced 4 texels apart.) Only supported
* on shader backends.
*/
k4x4Downsample_Filter,
/**

Просмотреть файл

@ -551,7 +551,7 @@ GrResource* GrContext::createPlatformSurface(const GrPlatformSurfaceDesc& desc)
///////////////////////////////////////////////////////////////////////////////
bool GrContext::supportsIndex8PixelConfig(const GrSamplerState& sampler,
int width, int height) {
int width, int height) const {
if (!fGpu->supports8BitPalette()) {
return false;
}
@ -639,7 +639,10 @@ bool GrContext::doOffscreenAA(GrDrawTarget* target,
if (!paint.fAntiAlias) {
return false;
}
if (isHairLines && target->willUseHWAALines()) {
// Line primitves are always rasterized as 1 pixel wide.
// Super-sampling would make them too thin but MSAA would be OK.
if (isHairLines &&
(!PREFER_MSAA_OFFSCREEN_AA || !fGpu->supportsFullsceneAA())) {
return false;
}
if (target->getRenderTarget()->isMultisampled()) {
@ -693,7 +696,7 @@ bool GrContext::prepareForOffscreenAA(GrDrawTarget* target,
record->fScale = 1;
desc.fAALevel = kMed_GrAALevel;
} else {
record->fDownsample = (fGpu->supports4x4DownsampleFilter()) ?
record->fDownsample = (fGpu->supportsShaders()) ?
OffscreenRecord::k4x4SinglePass_Downsample :
OffscreenRecord::k4x4TwoPass_Downsample;
record->fScale = OFFSCREEN_SSAA_SCALE;
@ -1492,6 +1495,10 @@ void GrContext::drawPath(const GrPaint& paint, const GrPath& path,
////////////////////////////////////////////////////////////////////////////////
bool GrContext::supportsShaders() const {
return fGpu->supportsShaders();
}
void GrContext::flush(int flagsBitfield) {
if (kDiscard_FlushBit & flagsBitfield) {
fDrawBuffer->reset();

Просмотреть файл

@ -183,6 +183,16 @@ public:
*/
bool supportsHWAALines() const { return fAALineSupport; }
/**
* Are shaders supported.
*/
bool supportsShaders() const { return fShaderSupport; }
/**
* Are derivative instructions supported in fragment shaders
*/
bool supportsShaderDerivatives() const { return fShaderDerivativeSupport; }
/**
* Does the subclass support GrSamplerState::k4x4Downsample_Filter
*/
@ -193,8 +203,8 @@ public:
* blending with partial coverage with certain blend modes (dst coeff is
* not 1, ISA, or ISC)
*/
bool supportsDualSourceBlending() const {
return fDualSourceBlendingSupport;
bool supportsDualSourceBlending() const {
return fDualSourceBlendingSupport;
}
/**
@ -363,6 +373,8 @@ protected:
bool fTwoSidedStencilSupport;
bool fStencilWrapOpsSupport;
bool fAALineSupport;
bool fShaderSupport;
bool fShaderDerivativeSupport;
bool fFSAASupport;
bool f4X4DownsampleFilterSupport; // supports GrSamplerState::k4x4Downsample_Filter
bool fDualSourceBlendingSupport;

Просмотреть файл

@ -62,7 +62,8 @@ GrGLBinding get_binding_in_use(const GrGLInterface* gl) {
GrGpuGLFixed::GrGpuGLFixed(const GrGLInterface* gl)
: GrGpuGL(gl, get_binding_in_use(gl)) {
f4X4DownsampleFilterSupport = false;
fShaderSupport = false;
fShaderDerivativeSupport = false;
fDualSourceBlendingSupport = false;
}

Просмотреть файл

@ -185,11 +185,11 @@ bool GrGpuGLShaders::programUnitTest() {
pdesc.fFirstCoverageStage = idx;
bool edgeAA = random.nextF() > .5f;
if (edgeAA) {
pdesc.fEdgeAANumEdges = random.nextF() * this->getMaxEdges() + 1;
pdesc.fEdgeAAConcave = random.nextF() > .5f;
} else {
pdesc.fEdgeAANumEdges = 0;
if (edgeAA) {
pdesc.fEdgeAANumEdges = random.nextF() * this->getMaxEdges() + 1;
pdesc.fEdgeAAConcave = random.nextF() > .5f;
} else {
pdesc.fEdgeAANumEdges = 0;
}
if (fDualSourceBlendingSupport) {
@ -256,13 +256,16 @@ GrGLBinding get_binding_in_use(const GrGLInterface* gl) {
GrGpuGLShaders::GrGpuGLShaders(const GrGLInterface* gl)
: GrGpuGL(gl, get_binding_in_use(gl)) {
f4X4DownsampleFilterSupport = true;
fShaderSupport = true;
if (kDesktop_GrGLBinding == this->glBinding()) {
fDualSourceBlendingSupport =
fGLVersion >= 3.3f ||
this->hasExtension("GL_ARB_blend_func_extended");
fShaderDerivativeSupport = true;
} else {
fDualSourceBlendingSupport = false;
fShaderDerivativeSupport =
this->hasExtension("GL_OES_standard_derivatives");
}
fProgramData = NULL;

Просмотреть файл

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