Robert Phillips | cb2e235 | 2017-08-30 16:44:40 -0400 | [diff] [blame] | 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 | |
Greg Daniel | 2d41d0d | 2019-08-26 11:08:51 -0400 | [diff] [blame] | 8 | #include "src/gpu/gl/GrGLOpsRenderPass.h" |
Robert Phillips | cb2e235 | 2017-08-30 16:44:40 -0400 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "src/gpu/GrContextPriv.h" |
| 11 | #include "src/gpu/GrFixedClip.h" |
| 12 | #include "src/gpu/GrRenderTargetPriv.h" |
Robert Phillips | cb2e235 | 2017-08-30 16:44:40 -0400 | [diff] [blame] | 13 | |
Greg Daniel | 2d41d0d | 2019-08-26 11:08:51 -0400 | [diff] [blame] | 14 | void GrGLOpsRenderPass::begin() { |
Michael Ludwig | 6e17f1d | 2019-05-15 14:00:20 +0000 | [diff] [blame] | 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 | |
Greg Daniel | 2d41d0d | 2019-08-26 11:08:51 -0400 | [diff] [blame] | 27 | void GrGLOpsRenderPass::set(GrRenderTarget* rt, GrSurfaceOrigin origin, |
| 28 | const GrOpsRenderPass::LoadAndStoreInfo& colorInfo, |
| 29 | const GrOpsRenderPass::StencilLoadAndStoreInfo& stencilInfo) { |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 30 | SkASSERT(fGpu); |
| 31 | SkASSERT(!fRenderTarget); |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 32 | SkASSERT(fGpu == rt->getContext()->priv().getGpu()); |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 33 | |
| 34 | this->INHERITED::set(rt, origin); |
| 35 | fColorLoadAndStoreInfo = colorInfo; |
| 36 | fStencilLoadAndStoreInfo = stencilInfo; |
| 37 | } |