Robert Phillips | fbcef6e | 2017-06-15 12:07:18 -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. |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame^] | 6 | */ |
| 7 | |
| 8 | #include "GrClearOp.h" |
| 9 | |
| 10 | #include "GrGpuCommandBuffer.h" |
| 11 | #include "GrOpFlushState.h" |
Robert Phillips | fbcef6e | 2017-06-15 12:07:18 -0400 | [diff] [blame] | 12 | #include "GrResourceProvider.h" |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame^] | 13 | |
Robert Phillips | fbcef6e | 2017-06-15 12:07:18 -0400 | [diff] [blame] | 14 | GrClearOp::GrClearOp(const GrFixedClip& clip, GrColor color, GrSurfaceProxy* proxy) |
| 15 | : INHERITED(ClassID()) |
| 16 | , fClip(clip) |
| 17 | , fColor(color) { |
| 18 | const SkIRect rtRect = SkIRect::MakeWH(proxy->width(), proxy->height()); |
| 19 | if (fClip.scissorEnabled()) { |
| 20 | // Don't let scissors extend outside the RT. This may improve op combining. |
| 21 | if (!fClip.intersect(rtRect)) { |
| 22 | SkASSERT(0); // should be caught upstream |
| 23 | fClip = GrFixedClip(SkIRect::MakeEmpty()); |
| 24 | } |
| 25 | |
| 26 | if (GrResourceProvider::IsFunctionallyExact(proxy) && fClip.scissorRect() == rtRect) { |
| 27 | fClip.disableScissor(); |
| 28 | } |
| 29 | } |
| 30 | this->setBounds(SkRect::Make(fClip.scissorEnabled() ? fClip.scissorRect() : rtRect), |
| 31 | HasAABloat::kNo, IsZeroArea::kNo); |
| 32 | } |
| 33 | |
| 34 | void GrClearOp::onExecute(GrOpFlushState* state) { |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 35 | SkASSERT(state->rtCommandBuffer()); |
| 36 | state->rtCommandBuffer()->clear(fClip, fColor); |
Robert Phillips | fbcef6e | 2017-06-15 12:07:18 -0400 | [diff] [blame] | 37 | } |