Home | History | Annotate | Download | only in ops
      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 "GrClearOp.h"
      9 
     10 #include "GrGpuCommandBuffer.h"
     11 #include "GrOpFlushState.h"
     12 #include "GrProxyProvider.h"
     13 
     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 (GrProxyProvider::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) {
     35     SkASSERT(state->rtCommandBuffer());
     36     state->rtCommandBuffer()->clear(fClip, fColor);
     37 }
     38