Reduce stencil buffer clearing
TBR=bsalomon@google.com
Bug: skia:6953
Change-Id: I079f90711297ee290f2d4011cfcb18b764554deb
Reviewed-on: https://skia-review.googlesource.com/40691
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/gl/GrGLGpuCommandBuffer.cpp b/src/gpu/gl/GrGLGpuCommandBuffer.cpp
new file mode 100644
index 0000000..4f08b83
--- /dev/null
+++ b/src/gpu/gl/GrGLGpuCommandBuffer.cpp
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrGLGpuCommandBuffer.h"
+
+#include "GrFixedClip.h"
+#include "GrRenderTargetPriv.h"
+
+void GrGLGpuRTCommandBuffer::begin() {
+ if (GrLoadOp::kClear == fColorLoadAndStoreInfo.fLoadOp) {
+ fGpu->clear(GrFixedClip::Disabled(), fColorLoadAndStoreInfo.fClearColor,
+ fRenderTarget, fOrigin);
+ }
+ if (GrLoadOp::kClear == fStencilLoadAndStoreInfo.fLoadOp) {
+ GrStencilAttachment* sb = fRenderTarget->renderTargetPriv().getStencilAttachment();
+ if (sb && (sb->isDirty() || fRenderTarget->alwaysClearStencil())) {
+ fGpu->clearStencil(fRenderTarget, 0x0);
+ }
+ }
+}