1 /*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "src/gpu/gl/GrGLGpuCommandBuffer.h"
9
10 #include "src/gpu/GrContextPriv.h"
11 #include "src/gpu/GrFixedClip.h"
12 #include "src/gpu/GrRenderTargetPriv.h"
13
begin()14 void GrGLGpuRTCommandBuffer::begin() {
15 if (GrLoadOp::kClear == fColorLoadAndStoreInfo.fLoadOp) {
16 fGpu->clear(GrFixedClip::Disabled(), fColorLoadAndStoreInfo.fClearColor,
17 fRenderTarget, fOrigin);
18 }
19 if (GrLoadOp::kClear == fStencilLoadAndStoreInfo.fLoadOp) {
20 GrStencilAttachment* sb = fRenderTarget->renderTargetPriv().getStencilAttachment();
21 if (sb && (sb->isDirty() || fRenderTarget->alwaysClearStencil())) {
22 fGpu->clearStencil(fRenderTarget, 0x0);
23 }
24 }
25 }
26
set(GrRenderTarget * rt,GrSurfaceOrigin origin,const GrGpuRTCommandBuffer::LoadAndStoreInfo & colorInfo,const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo & stencilInfo)27 void GrGLGpuRTCommandBuffer::set(GrRenderTarget* rt, GrSurfaceOrigin origin,
28 const GrGpuRTCommandBuffer::LoadAndStoreInfo& colorInfo,
29 const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo& stencilInfo) {
30 SkASSERT(fGpu);
31 SkASSERT(!fRenderTarget);
32 SkASSERT(fGpu == rt->getContext()->priv().getGpu());
33
34 this->INHERITED::set(rt, origin);
35 fColorLoadAndStoreInfo = colorInfo;
36 fStencilLoadAndStoreInfo = stencilInfo;
37 }
38