blob: 4756606581509762f73af4911325763aaaa151e1 [file] [log] [blame]
Greg Daniel64cc9aa2018-10-19 13:54:56 -04001/*
2 * Copyright 2018 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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "src/gpu/ops/GrDrawableOp.h"
Greg Daniel64cc9aa2018-10-19 13:54:56 -04009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/core/SkDrawable.h"
Robert Phillipsb7bfbc22020-07-01 12:55:01 -040011#include "include/gpu/GrRecordingContext.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050012#include "src/gpu/GrMemoryPool.h"
13#include "src/gpu/GrOpFlushState.h"
Greg Daniel2d41d0d2019-08-26 11:08:51 -040014#include "src/gpu/GrOpsRenderPass.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050015#include "src/gpu/GrRecordingContextPriv.h"
Greg Daniel64cc9aa2018-10-19 13:54:56 -040016
Herb Derbyc76d4092020-10-07 16:46:15 -040017GrOp::Owner GrDrawableOp::Make(
Robert Phillipsb97da532019-02-12 15:24:12 -050018 GrRecordingContext* context, std::unique_ptr<SkDrawable::GpuDrawHandler> drawable,
Greg Daniel64cc9aa2018-10-19 13:54:56 -040019 const SkRect& bounds) {
Herb Derbyc76d4092020-10-07 16:46:15 -040020 return GrOp::Make<GrDrawableOp>(context, std::move(drawable), bounds);
Greg Daniel64cc9aa2018-10-19 13:54:56 -040021}
22
23GrDrawableOp::GrDrawableOp(std::unique_ptr<SkDrawable::GpuDrawHandler> drawable,
24 const SkRect& bounds)
25 : INHERITED(ClassID())
26 , fDrawable(std::move(drawable)) {
Robert Phillipsc655c3a2020-03-18 13:23:45 -040027 this->setBounds(bounds, HasAABloat::kNo, IsHairline::kNo);
Greg Daniel64cc9aa2018-10-19 13:54:56 -040028}
29
Brian Salomon588cec72018-11-14 13:56:37 -050030void GrDrawableOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
Greg Daniel2d41d0d2019-08-26 11:08:51 -040031 SkASSERT(state->opsRenderPass());
32 state->opsRenderPass()->executeDrawable(std::move(fDrawable));
Greg Daniel64cc9aa2018-10-19 13:54:56 -040033}