blob: e954083deb7e2a33e547dab72208156fd14a336e [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "src/gpu/ops/GrClearOp.h"
Robert Phillipsb0e93a22017-08-29 08:26:54 -04009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/private/GrRecordingContext.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "src/gpu/GrMemoryPool.h"
12#include "src/gpu/GrOpFlushState.h"
Greg Daniel2d41d0d2019-08-26 11:08:51 -040013#include "src/gpu/GrOpsRenderPass.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050014#include "src/gpu/GrProxyProvider.h"
15#include "src/gpu/GrRecordingContextPriv.h"
Robert Phillipsb0e93a22017-08-29 08:26:54 -040016
Robert Phillipsb97da532019-02-12 15:24:12 -050017std::unique_ptr<GrClearOp> GrClearOp::Make(GrRecordingContext* context,
Michael Ludwig1e632792020-05-21 12:45:31 -040018 const GrScissorState& scissor,
Michael Ludwigd1d997e2020-06-04 15:52:44 -040019 const SkPMColor4f& color) {
Robert Phillips9da87e02019-02-04 13:26:26 -050020 GrOpMemoryPool* pool = context->priv().opMemoryPool();
Michael Ludwigd1d997e2020-06-04 15:52:44 -040021 return pool->allocate<GrClearOp>(scissor, color);
Robert Phillips7c525e62018-06-12 10:11:12 -040022}
23
Michael Ludwigd1d997e2020-06-04 15:52:44 -040024GrClearOp::GrClearOp(const GrScissorState& scissor, const SkPMColor4f& color)
Jim Van Verth6a40abc2017-11-02 16:56:09 +000025 : INHERITED(ClassID())
Michael Ludwig1e632792020-05-21 12:45:31 -040026 , fScissor(scissor)
Robert Phillipsfbcef6e2017-06-15 12:07:18 -040027 , fColor(color) {
Michael Ludwigd1d997e2020-06-04 15:52:44 -040028 this->setBounds(SkRect::Make(scissor.rect()), HasAABloat::kNo, IsHairline::kNo);
Robert Phillipsfbcef6e2017-06-15 12:07:18 -040029}
30
Brian Salomon588cec72018-11-14 13:56:37 -050031void GrClearOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
Greg Daniel2d41d0d2019-08-26 11:08:51 -040032 SkASSERT(state->opsRenderPass());
Michael Ludwig1e632792020-05-21 12:45:31 -040033 state->opsRenderPass()->clear(fScissor, fColor);
Robert Phillipsfbcef6e2017-06-15 12:07:18 -040034}