Add drawDrawable support to GrRenderTargetContext.
This also includes adding drawable Op and plumbing it through to the GPU.
BUG=skia:
Change-Id: I0b2464c5a458c2fbf05b9528e47b9e6e3ac27d57
Reviewed-on: https://skia-review.googlesource.com/c/9645
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/ops/GrDrawableOp.cpp b/src/gpu/ops/GrDrawableOp.cpp
new file mode 100644
index 0000000..6e648be
--- /dev/null
+++ b/src/gpu/ops/GrDrawableOp.cpp
@@ -0,0 +1,35 @@
+/*
+ * 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 "GrDrawableOp.h"
+
+#include "GrContext.h"
+#include "GrContextPriv.h"
+#include "GrGpuCommandBuffer.h"
+#include "GrMemoryPool.h"
+#include "GrOpFlushState.h"
+#include "SkDrawable.h"
+
+std::unique_ptr<GrDrawableOp> GrDrawableOp::Make(
+ GrContext* context, std::unique_ptr<SkDrawable::GpuDrawHandler> drawable,
+ const SkRect& bounds) {
+ GrOpMemoryPool* pool = context->contextPriv().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) {
+ SkASSERT(state->commandBuffer());
+ state->rtCommandBuffer()->executeDrawable(std::move(fDrawable));
+}
+