blob: 1b0bbd205dcf5de47686025eb275fb0d1e271c38 [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
8#include "GrDrawableOp.h"
9
10#include "GrContext.h"
11#include "GrContextPriv.h"
12#include "GrGpuCommandBuffer.h"
13#include "GrMemoryPool.h"
14#include "GrOpFlushState.h"
15#include "SkDrawable.h"
16
17std::unique_ptr<GrDrawableOp> GrDrawableOp::Make(
18 GrContext* context, std::unique_ptr<SkDrawable::GpuDrawHandler> drawable,
19 const SkRect& bounds) {
20 GrOpMemoryPool* pool = context->contextPriv().opMemoryPool();
21 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}