blob: 6f89d7471f9459b3448c0f10f534b54c459f794d [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"
12#include "src/gpu/GrGpuCommandBuffer.h"
13#include "src/gpu/GrMemoryPool.h"
14#include "src/gpu/GrOpFlushState.h"
15#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 Daniel64cc9aa2018-10-19 13:54:56 -040032 SkASSERT(state->commandBuffer());
33 state->rtCommandBuffer()->executeDrawable(std::move(fDrawable));
34}