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 "GrGLGpuCommandBuffer.h"
9 
10 #include "GrFixedClip.h"
11 #include "GrRenderTargetPriv.h"
12 
begin()13 void GrGLGpuRTCommandBuffer::begin() {
14     if (GrLoadOp::kClear == fColorLoadAndStoreInfo.fLoadOp) {
15         fGpu->clear(GrFixedClip::Disabled(), fColorLoadAndStoreInfo.fClearColor,
16                     fRenderTarget, fOrigin);
17     }
18     if (GrLoadOp::kClear == fStencilLoadAndStoreInfo.fLoadOp) {
19         GrStencilAttachment* sb = fRenderTarget->renderTargetPriv().getStencilAttachment();
20         if (sb && (sb->isDirty() || fRenderTarget->alwaysClearStencil())) {
21             fGpu->clearStencil(fRenderTarget, 0x0);
22         }
23     }
24 }
25 
set(GrRenderTarget * rt,GrSurfaceOrigin origin,const GrGpuRTCommandBuffer::LoadAndStoreInfo & colorInfo,const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo & stencilInfo)26 void GrGLGpuRTCommandBuffer::set(GrRenderTarget* rt, GrSurfaceOrigin origin,
27                                  const GrGpuRTCommandBuffer::LoadAndStoreInfo& colorInfo,
28                                  const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo& stencilInfo) {
29     SkASSERT(fGpu);
30     SkASSERT(!fRenderTarget);
31     SkASSERT(fGpu == rt->getContext()->contextPriv().getGpu());
32 
33     this->INHERITED::set(rt, origin);
34     fColorLoadAndStoreInfo = colorInfo;
35     fStencilLoadAndStoreInfo = stencilInfo;
36 }
37