Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: src/gpu/GrDrawTarget.cpp

Issue 701573002: Workaround for PowerVR clear issue. (Closed) Base URL: https://skia.googlesource.com/skia.git@no_null
Patch Set: Add missing spaces Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrDrawTarget.cpp
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 8f436f2906fb2c6d800edfe0efb165383a4300cf..08a62a534cf0ff0d9f0ee42bf9d0b52659365c78 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -546,6 +546,31 @@ 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.
+ // The driver will ignore a clear if it is the only thing rendered to a
+ // target before the target is read.
+ SkIRect rtRect = SkIRect::MakeWH(renderTarget->width(), renderTarget->height());
+ if (NULL == rect || canIgnoreRect || rect->contains(rtRect)) {
+ rect = &rtRect;
+ // We first issue a discard() since that may help tilers.
+ this->discard(renderTarget);
+ }
+ 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 +994,8 @@ void GrDrawTargetCaps::reset() {
fGpuTracingSupport = false;
fCompressedTexSubImageSupport = false;
+ fUseDrawInsteadOfClear = false;
+
fMapBufferFlags = kNone_MapFlags;
fMaxRenderTargetSize = 0;
@@ -995,6 +1022,8 @@ GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) {
fGpuTracingSupport = other.fGpuTracingSupport;
fCompressedTexSubImageSupport = other.fCompressedTexSubImageSupport;
+ fUseDrawInsteadOfClear = other.fUseDrawInsteadOfClear;
+
fMapBufferFlags = other.fMapBufferFlags;
fMaxRenderTargetSize = other.fMaxRenderTargetSize;
@@ -1030,25 +1059,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
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrDrawTargetCaps.h » ('j') | src/gpu/gl/GrGLUtil.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698