aboutsummaryrefslogtreecommitdiff
path: root/src/gpu
diff options
context:
space:
mode:
authorBrian Salomon <bsalomon@google.com>2019-01-28 09:52:34 -0500
committerSkia Commit-Bot <skia-commit-bot@chromium.org>2019-01-28 15:18:26 +0000
commit805cc7a2f890ee27136464473f1424c0038767d7 (patch)
tree35558b644c45b5251aa5a70c8a320dc749dae3e1 /src/gpu
parent3c03c851ad50308cc55eabcad149090a07a814d6 (diff)
downloadskqp-805cc7a2f890ee27136464473f1424c0038767d7.tar.gz
Avoid setting the GL color mask and clear color redundantly before glClear.
Change-Id: I0830e62fc65fd4a85c27db01aab8e16697c840f7 Reviewed-on: https://skia-review.googlesource.com/c/187304 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/gl/GrGLGpu.cpp26
-rw-r--r--src/gpu/gl/GrGLGpu.h3
2 files changed, 21 insertions, 8 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 02df297de5..4a03a26400 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -540,6 +540,8 @@ void GrGLGpu::onResetContext(uint32_t resetBits) {
// we only ever use lines in hairline mode
GL_CALL(LineWidth(1));
GL_CALL(Disable(GR_GL_DITHER));
+
+ fHWClearColor[0] = fHWClearColor[1] = fHWClearColor[2] = fHWClearColor[3] = SK_FloatNaN;
}
if (resetBits & kMSAAEnable_GrGLBackendState) {
@@ -1615,9 +1617,8 @@ sk_sp<GrTexture> GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
kDst_TempFBOTarget);
this->disableScissor();
this->disableWindowRectangles();
- GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE));
- fHWWriteToColor = kYes_TriState;
- GL_CALL(ClearColor(0, 0, 0, 0));
+ this->flushColorWrite(true);
+ this->flushClearColor(0, 0, 0, 0);
GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT));
this->unbindTextureFBOForPixelOps(GR_GL_FRAMEBUFFER, tex.get());
fHWBoundRenderTargetUniqueID.makeInvalid();
@@ -2164,19 +2165,17 @@ void GrGLGpu::clear(const GrFixedClip& clip, const SkPMColor4f& color,
}
this->flushScissor(clip.scissorState(), glRT->getViewport(), origin);
this->flushWindowRectangles(clip.windowRectsState(), glRT, origin);
-
- GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE));
- fHWWriteToColor = kYes_TriState;
+ this->flushColorWrite(true);
GrGLfloat r = color.fR, g = color.fG, b = color.fB, a = color.fA;
-
if (this->glCaps().clearToBoundaryValuesIsBroken() &&
(1 == r || 0 == r) && (1 == g || 0 == g) && (1 == b || 0 == b) && (1 == a || 0 == a)) {
static const GrGLfloat safeAlpha1 = nextafter(1.f, 2.f);
static const GrGLfloat safeAlpha0 = nextafter(0.f, -1.f);
a = (1 == a) ? safeAlpha1 : safeAlpha0;
}
- GL_CALL(ClearColor(r, g, b, a));
+ this->flushClearColor(r, g, b, a);
+
GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT));
}
@@ -3095,6 +3094,17 @@ void GrGLGpu::flushColorWrite(bool writeColor) {
}
}
+void GrGLGpu::flushClearColor(GrGLfloat r, GrGLfloat g, GrGLfloat b, GrGLfloat a) {
+ if (r != fHWClearColor[0] || g != fHWClearColor[1] ||
+ b != fHWClearColor[2] || a != fHWClearColor[3]) {
+ GL_CALL(ClearColor(r, g, b, a));
+ fHWClearColor[0] = r;
+ fHWClearColor[1] = g;
+ fHWClearColor[2] = b;
+ fHWClearColor[3] = a;
+ }
+}
+
void GrGLGpu::setTextureUnit(int unit) {
SkASSERT(unit >= 0 && unit < fHWBoundTextureUniqueIDs.count());
if (unit != fHWActiveTextureUnitIdx) {
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index e97ed7a185..eb721b361d 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -338,6 +338,7 @@ private:
};
void flushColorWrite(bool writeColor);
+ void flushClearColor(GrGLfloat r, GrGLfloat g, GrGLfloat b, GrGLfloat a);
// flushes the scissor. see the note on flushBoundTextureAndParams about
// flushing the scissor after that function is called.
@@ -587,6 +588,8 @@ private:
TriState fHWSRGBFramebuffer;
SkTArray<GrGpuResource::UniqueID, true> fHWBoundTextureUniqueIDs;
+ GrGLfloat fHWClearColor[4];
+
GrGLuint fBoundDrawFramebuffer = 0;
// EXT_raster_multisample.