blob: 912ffe7a6351faf556efb42593689bb6e39e98be [file] [log] [blame]
Robert Phillipscb2e2352017-08-30 16:44:40 -04001/*
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
13void 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}
Robert Phillips5b5d84c2018-08-09 15:12:18 -040025
26void 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}