Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Unified Diff: src/gpu/GrImmediateDrawTarget.cpp

Issue 1126043007: Adding immediate mode draw target for debug (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrImmediateDrawTarget.h ('k') | src/gpu/GrInOrderDrawBuffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrImmediateDrawTarget.cpp
diff --git a/src/gpu/GrImmediateDrawTarget.cpp b/src/gpu/GrImmediateDrawTarget.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4c42a30f864d7c3982b80642882329ddeff24446
--- /dev/null
+++ b/src/gpu/GrImmediateDrawTarget.cpp
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrImmediateDrawTarget.h"
+
+#include "GrBatch.h"
+#include "GrGpu.h"
+#include "GrPipeline.h"
+#include "GrRenderTarget.h"
+#include "SkRect.h"
+#include "SkTypes.h"
+
+GrImmediateDrawTarget::GrImmediateDrawTarget(GrContext* context)
+ : INHERITED(context)
+ , fBatchTarget(this->getGpu())
+ , fDrawID(0) {
+}
+
+GrImmediateDrawTarget::~GrImmediateDrawTarget() {
+ this->reset();
+}
+
+void GrImmediateDrawTarget::onDrawBatch(GrBatch* batch,
+ const PipelineInfo& pipelineInfo) {
+ SkAlignedSStorage<sizeof(GrPipeline)> pipelineStorage;
+ GrPipeline* pipeline = reinterpret_cast<GrPipeline*>(pipelineStorage.get());
+ if (!this->setupPipelineAndShouldDraw(pipeline, pipelineInfo)) {
+ pipeline->~GrPipeline();
+ return;
+ }
+
+ batch->initBatchTracker(pipeline->getInitBatchTracker());
+
+ fBatchTarget.resetNumberOfDraws();
+
+ batch->generateGeometry(&fBatchTarget, pipeline);
+ batch->setNumberOfDraws(fBatchTarget.numberOfDraws());
+
+ fBatchTarget.preFlush();
+ fBatchTarget.flushNext(batch->numberOfDraws());
+ fBatchTarget.postFlush();
+
+ pipeline->~GrPipeline();
+}
+
+void GrImmediateDrawTarget::onClear(const SkIRect* rect, GrColor color,
+ bool canIgnoreRect, GrRenderTarget* renderTarget) {
+ this->getGpu()->clear(rect, color, canIgnoreRect, renderTarget);
+}
+
+void GrImmediateDrawTarget::onCopySurface(GrSurface* dst,
+ GrSurface* src,
+ const SkIRect& srcRect,
+ const SkIPoint& dstPoint) {
+ SkASSERT(this->getGpu()->canCopySurface(dst, src, srcRect, dstPoint));
+ this->getGpu()->copySurface(dst, src, srcRect, dstPoint);
+}
+
+void GrImmediateDrawTarget::clearStencilClip(const SkIRect& rect,
+ bool insideClip,
+ GrRenderTarget* renderTarget) {
+ this->getGpu()->clearStencilClip(rect, insideClip, renderTarget);
+}
+
+void GrImmediateDrawTarget::discard(GrRenderTarget* renderTarget) {
+ if (!this->caps()->discardRenderTargetSupport()) {
+ return;
+ }
+
+ this->getGpu()->discard(renderTarget);
+}
+
+void GrImmediateDrawTarget::onReset() {
+ fBatchTarget.reset();
+}
+
+void GrImmediateDrawTarget::onFlush() {
+ ++fDrawID;
+}
+
+bool
+GrImmediateDrawTarget::setupPipelineAndShouldDraw(GrPipeline* pipeline,
+ const GrDrawTarget::PipelineInfo& pipelineInfo) {
+ this->setupPipeline(pipelineInfo, pipeline);
+
+ if (pipeline->mustSkip()) {
+ return false;
+ }
+
+ this->recordXferBarrierIfNecessary(pipeline);
+ return true;
+}
+
+void GrImmediateDrawTarget::recordXferBarrierIfNecessary(const GrPipeline* pipeline) {
+ const GrXferProcessor& xp = *pipeline->getXferProcessor();
+ GrRenderTarget* rt = pipeline->getRenderTarget();
+
+ GrXferBarrierType barrierType;
+ if (xp.willNeedXferBarrier(rt, *this->caps(), &barrierType)) {
+ this->getGpu()->xferBarrier(rt, barrierType);
+ }
+}
« no previous file with comments | « src/gpu/GrImmediateDrawTarget.h ('k') | src/gpu/GrInOrderDrawBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698