blob: 6f89d7471f9459b3448c0f10f534b54c459f794d [file] [log] [blame]
/*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "src/gpu/ops/GrDrawableOp.h"
#include "include/core/SkDrawable.h"
#include "include/private/GrRecordingContext.h"
#include "src/gpu/GrGpuCommandBuffer.h"
#include "src/gpu/GrMemoryPool.h"
#include "src/gpu/GrOpFlushState.h"
#include "src/gpu/GrRecordingContextPriv.h"
std::unique_ptr<GrDrawableOp> GrDrawableOp::Make(
GrRecordingContext* context, std::unique_ptr<SkDrawable::GpuDrawHandler> drawable,
const SkRect& bounds) {
GrOpMemoryPool* pool = context->priv().opMemoryPool();
return pool->allocate<GrDrawableOp>(std::move(drawable), bounds);
}
GrDrawableOp::GrDrawableOp(std::unique_ptr<SkDrawable::GpuDrawHandler> drawable,
const SkRect& bounds)
: INHERITED(ClassID())
, fDrawable(std::move(drawable)) {
this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
}
void GrDrawableOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
SkASSERT(state->commandBuffer());
state->rtCommandBuffer()->executeDrawable(std::move(fDrawable));
}