blob: 66a63f91bc5b175317e501e53fc462ff50874717 [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"
11#include "include/private/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
17std::unique_ptr<GrDrawableOp> 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) {
Robert Phillips9da87e02019-02-04 13:26:26 -050020 GrOpMemoryPool* pool = context->priv().opMemoryPool();
Greg Daniel64cc9aa2018-10-19 13:54:56 -040021 return pool->allocate<GrDrawableOp>(std::move(drawable), bounds);
22}
23
24GrDrawableOp::GrDrawableOp(std::unique_ptr<SkDrawable::GpuDrawHandler> drawable,
25 const SkRect& bounds)
26 : INHERITED(ClassID())
27 , fDrawable(std::move(drawable)) {
28 this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
29}
30
Brian Salomon588cec72018-11-14 13:56:37 -050031void GrDrawableOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
Greg Daniel2d41d0d2019-08-26 11:08:51 -040032 SkASSERT(state->opsRenderPass());
33 state->opsRenderPass()->executeDrawable(std::move(fDrawable));
Greg Daniel64cc9aa2018-10-19 13:54:56 -040034}