Chromium Code Reviews| Index: src/gpu/GrDrawTarget.cpp |
| diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp |
| index 8f436f2906fb2c6d800edfe0efb165383a4300cf..36e735d53e3f78d0fd781868c8c3a775eedf9211 100644 |
| --- a/src/gpu/GrDrawTarget.cpp |
| +++ b/src/gpu/GrDrawTarget.cpp |
| @@ -546,6 +546,30 @@ void GrDrawTarget::drawPaths(const GrPathRange* pathRange, |
| dstCopy.texture() ? &dstCopy : NULL); |
| } |
| +void GrDrawTarget::clear(const SkIRect* rect, GrColor color, bool canIgnoreRect, |
| + GrRenderTarget* renderTarget) { |
| + if (fCaps->useDrawInsteadOfClear()) { |
| + // This works around a driver bug with clear by drawing a rect instead. |
| + SkIRect tmpRect; |
| + if (NULL == rect || canIgnoreRect) { |
| + tmpRect = SkIRect::MakeWH(renderTarget->width(), renderTarget->height()); |
| + rect = &tmpRect; |
| + // We first issue a discard() since that may help tilers. |
| + this->discard(renderTarget); |
| + } |
|
robertphillips
2014/11/05 14:22:59
// We cannot just set canIgnoreRect to false and f
bsalomon
2014/11/05 14:56:47
Combined this with the comment above (right after
|
| + AutoStateRestore asr(this, kReset_ASRInit, &SkMatrix::I()); |
| + |
| + this->drawState()->setColor(color); |
| + this->drawState()->disableState(GrDrawState::kClip_StateBit); |
| + this->drawState()->disableState(GrDrawState::kHWAntialias_StateBit); |
| + this->drawState()->setRenderTarget(renderTarget); |
| + |
| + this->drawSimpleRect(*rect); |
| + } else { |
| + this->onClear(rect, color, canIgnoreRect, renderTarget); |
| + } |
| +} |
| + |
| typedef GrTraceMarkerSet::Iter TMIter; |
| void GrDrawTarget::saveActiveTraceMarkers() { |
| if (this->caps()->gpuTracingSupport()) { |
| @@ -969,6 +993,8 @@ void GrDrawTargetCaps::reset() { |
| fGpuTracingSupport = false; |
| fCompressedTexSubImageSupport = false; |
| + fUseDrawInsteadOfClear = false; |
| + |
| fMapBufferFlags = kNone_MapFlags; |
| fMaxRenderTargetSize = 0; |
| @@ -995,6 +1021,8 @@ GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) { |
| fGpuTracingSupport = other.fGpuTracingSupport; |
| fCompressedTexSubImageSupport = other.fCompressedTexSubImageSupport; |
| + fUseDrawInsteadOfClear = other.fUseDrawInsteadOfClear; |
| + |
| fMapBufferFlags = other.fMapBufferFlags; |
| fMaxRenderTargetSize = other.fMaxRenderTargetSize; |
| @@ -1030,25 +1058,29 @@ static SkString map_flags_to_string(uint32_t flags) { |
| SkString GrDrawTargetCaps::dump() const { |
| SkString r; |
| static const char* gNY[] = {"NO", "YES"}; |
| - r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]); |
| - r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport]); |
| - r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]); |
| - r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport]); |
| - r.appendf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]); |
| - r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport]); |
| - r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]); |
| - r.appendf("Dual Source Blending Support : %s\n", gNY[fDualSourceBlendingSupport]); |
| - r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]); |
| - r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport]); |
| - r.appendf("Discard Render Target Support: %s\n", gNY[fDiscardRenderTargetSupport]); |
| - r.appendf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]); |
| - r.appendf("Gpu Tracing Support : %s\n", gNY[fGpuTracingSupport]); |
| - r.appendf("Compressed Update Support : %s\n", gNY[fCompressedTexSubImageSupport]); |
| - r.appendf("Max Texture Size : %d\n", fMaxTextureSize); |
| - r.appendf("Max Render Target Size : %d\n", fMaxRenderTargetSize); |
| - r.appendf("Max Sample Count : %d\n", fMaxSampleCount); |
| - |
| - r.appendf("Map Buffer Support : %s\n", map_flags_to_string(fMapBufferFlags).c_str()); |
| + r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]); |
| + r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport]); |
| + r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]); |
| + r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport]); |
| + r.appendf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]); |
| + r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport]); |
| + r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]); |
| + r.appendf("Dual Source Blending Support : %s\n", gNY[fDualSourceBlendingSupport]); |
| + r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]); |
| + r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport]); |
| + r.appendf("Discard Render Target Support : %s\n", gNY[fDiscardRenderTargetSupport]); |
| + r.appendf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]); |
| + r.appendf("Gpu Tracing Support : %s\n", gNY[fGpuTracingSupport]); |
| + r.appendf("Compressed Update Support : %s\n", gNY[fCompressedTexSubImageSupport]); |
| + |
| + r.appendf("Draw Instead of Clear [workaround] : %s\n", gNY[fUseDrawInsteadOfClear]); |
| + |
| + r.appendf("Max Texture Size : %d\n", fMaxTextureSize); |
| + r.appendf("Max Render Target Size : %d\n", fMaxRenderTargetSize); |
| + r.appendf("Max Sample Count : %d\n", fMaxSampleCount); |
| + |
| + r.appendf("Map Buffer Support : %s\n", |
| + map_flags_to_string(fMapBufferFlags).c_str()); |
| static const char* kConfigNames[] = { |
| "Unknown", // kUnknown_GrPixelConfig |