GrClearOp.cpp revision fbcef6eb8abad142daf45418516550f7635b4a52
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 "GrResourceProvider.h" 13 14GrClearOp::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) { 35 SkASSERT(state->drawOpArgs().fRenderTarget); 36 37 state->commandBuffer()->clear(state->drawOpArgs().fRenderTarget, fClip, fColor); 38} 39