blob: 702edcc3da4ec46ed2985d22e2f1abc9f71d5e65 [file] [log] [blame]
Robert Phillipsfbcef6e2017-06-15 12:07:18 -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.
Robert Phillipsb0e93a22017-08-29 08:26:54 -04006 */
7
8#include "GrClearOp.h"
9
10#include "GrGpuCommandBuffer.h"
11#include "GrOpFlushState.h"
Robert Phillipsfbcef6e2017-06-15 12:07:18 -040012#include "GrResourceProvider.h"
Robert Phillipsb0e93a22017-08-29 08:26:54 -040013
Robert Phillipsfbcef6e2017-06-15 12:07:18 -040014GrClearOp::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
34void GrClearOp::onExecute(GrOpFlushState* state) {
Greg Daniel500d58b2017-08-24 15:59:33 -040035 SkASSERT(state->rtCommandBuffer());
36 state->rtCommandBuffer()->clear(fClip, fColor);
Robert Phillipsfbcef6e2017-06-15 12:07:18 -040037}