1 /*
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 "src/gpu/ops/GrDrawableOp.h"
9
10 #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"
16
Make(GrRecordingContext * context,std::unique_ptr<SkDrawable::GpuDrawHandler> drawable,const SkRect & bounds)17 std::unique_ptr<GrDrawableOp> GrDrawableOp::Make(
18 GrRecordingContext* context, std::unique_ptr<SkDrawable::GpuDrawHandler> drawable,
19 const SkRect& bounds) {
20 GrOpMemoryPool* pool = context->priv().opMemoryPool();
21 return pool->allocate<GrDrawableOp>(std::move(drawable), bounds);
22 }
23
GrDrawableOp(std::unique_ptr<SkDrawable::GpuDrawHandler> drawable,const SkRect & bounds)24 GrDrawableOp::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
onExecute(GrOpFlushState * state,const SkRect & chainBounds)31 void GrDrawableOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
32 SkASSERT(state->commandBuffer());
33 state->rtCommandBuffer()->executeDrawable(std::move(fDrawable));
34 }
35