aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gyp/gpu.gypi2
-rw-r--r--src/gpu/GrOpList.cpp5
-rw-r--r--src/gpu/GrOpList.h6
-rw-r--r--src/gpu/GrRenderTargetOpList.cpp5
-rw-r--r--src/gpu/GrRenderTargetOpList.h1
-rw-r--r--src/gpu/GrTextureOpList.cpp113
-rw-r--r--src/gpu/GrTextureOpList.h69
7 files changed, 194 insertions, 7 deletions
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index 6812ca861f..7b3c7c4eb7 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -184,6 +184,8 @@
'<(skia_src_path)/gpu/GrStyle.h',
'<(skia_src_path)/gpu/GrTessellator.cpp',
'<(skia_src_path)/gpu/GrTessellator.h',
+ '<(skia_src_path)/gpu/GrTextureOpList.cpp',
+ '<(skia_src_path)/gpu/GrTextureOpList.h',
'<(skia_src_path)/gpu/GrTraceMarker.cpp',
'<(skia_src_path)/gpu/GrTraceMarker.h',
'<(skia_src_path)/gpu/GrTracing.h',
diff --git a/src/gpu/GrOpList.cpp b/src/gpu/GrOpList.cpp
index ac7f1b274d..2010e65af3 100644
--- a/src/gpu/GrOpList.cpp
+++ b/src/gpu/GrOpList.cpp
@@ -11,9 +11,10 @@
#include "GrRenderTargetOpList.h"
#include "GrSurface.h"
-GrOpList::GrOpList(GrSurface* surface)
+GrOpList::GrOpList(GrSurface* surface, GrAuditTrail* auditTrail)
: fFlags(0)
- , fTarget(surface) {
+ , fTarget(surface)
+ , fAuditTrail(auditTrail) {
surface->setLastOpList(this);
diff --git a/src/gpu/GrOpList.h b/src/gpu/GrOpList.h
index 4af85128b6..16d8a2b8bd 100644
--- a/src/gpu/GrOpList.h
+++ b/src/gpu/GrOpList.h
@@ -13,12 +13,13 @@
//#define ENABLE_MDB 1
+class GrAuditTrail;
class GrBatchFlushState;
class GrSurface;
class GrOpList : public SkRefCnt {
public:
- GrOpList(GrSurface* surface);
+ GrOpList(GrSurface* surface, GrAuditTrail* auditTrail);
~GrOpList() override;
virtual void prepareBatches(GrBatchFlushState* flushState) = 0;
@@ -118,6 +119,9 @@ private:
// 'this' GrOpList relies on the output of the GrOpLists in 'fDependencies'
SkTDArray<GrOpList*> fDependencies;
+protected:
+ GrAuditTrail* fAuditTrail;
+
typedef SkRefCnt INHERITED;
};
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index 0dbb7772eb..e641e749ff 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -49,11 +49,10 @@ static const int kDefaultMaxBatchLookahead = 10;
GrRenderTargetOpList::GrRenderTargetOpList(GrRenderTarget* rt, GrGpu* gpu,
GrResourceProvider* resourceProvider,
GrAuditTrail* auditTrail, const Options& options)
- : INHERITED(rt)
+ : INHERITED(rt, auditTrail)
, fLastFullClearBatch(nullptr)
, fGpu(SkRef(gpu))
- , fResourceProvider(resourceProvider)
- , fAuditTrail(auditTrail) {
+ , fResourceProvider(resourceProvider) {
// TODO: Stop extracting the context (currently needed by GrClip)
fContext = fGpu->getContext();
diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h
index 080ff69ce4..e93a34a30d 100644
--- a/src/gpu/GrRenderTargetOpList.h
+++ b/src/gpu/GrRenderTargetOpList.h
@@ -160,7 +160,6 @@ private:
GrContext* fContext;
GrGpu* fGpu;
GrResourceProvider* fResourceProvider;
- GrAuditTrail* fAuditTrail;
bool fClipBatchToBounds;
bool fDrawBatchBounds;
diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp
new file mode 100644
index 0000000000..43c2ece3ce
--- /dev/null
+++ b/src/gpu/GrTextureOpList.cpp
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrTextureOpList.h"
+
+#include "GrAuditTrail.h"
+#include "GrGpu.h"
+#include "GrTexture.h"
+
+#include "batches/GrCopySurfaceBatch.h"
+
+////////////////////////////////////////////////////////////////////////////////
+
+GrTextureOpList::GrTextureOpList(GrTexture* tex, GrGpu* gpu, GrAuditTrail* auditTrail)
+ : INHERITED(tex, auditTrail)
+ , fGpu(SkRef(gpu)) {
+}
+
+GrTextureOpList::~GrTextureOpList() {
+ fGpu->unref();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#ifdef SK_DEBUG
+void GrTextureOpList::dump() const {
+ INHERITED::dump();
+
+ SkDebugf("batches (%d):\n", fRecordedBatches.count());
+ for (int i = 0; i < fRecordedBatches.count(); ++i) {
+ SkDebugf("*******************************\n");
+ SkDebugf("%d: %s\n", i, fRecordedBatches[i]->name());
+ SkString str = fRecordedBatches[i]->dumpInfo();
+ SkDebugf("%s\n", str.c_str());
+ const SkRect& clippedBounds = fRecordedBatches[i]->bounds();
+ SkDebugf("ClippedBounds: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
+ clippedBounds.fLeft, clippedBounds.fTop, clippedBounds.fRight,
+ clippedBounds.fBottom);
+ }
+}
+#endif
+
+void GrTextureOpList::prepareBatches(GrBatchFlushState* flushState) {
+ // Semi-usually the GrOpLists are already closed at this point, but sometimes Ganesh
+ // needs to flush mid-draw. In that case, the SkGpuDevice's GrOpLists won't be closed
+ // but need to be flushed anyway. Closing such GrOpLists here will mean new
+ // GrOpLists will be created to replace them if the SkGpuDevice(s) write to them again.
+ this->makeClosed();
+
+ // Loop over the batches that haven't yet generated their geometry
+ for (int i = 0; i < fRecordedBatches.count(); ++i) {
+ if (fRecordedBatches[i]) {
+ fRecordedBatches[i]->prepare(flushState);
+ }
+ }
+}
+
+bool GrTextureOpList::drawBatches(GrBatchFlushState* flushState) {
+ if (0 == fRecordedBatches.count()) {
+ return false;
+ }
+
+ for (int i = 0; i < fRecordedBatches.count(); ++i) {
+ fRecordedBatches[i]->draw(flushState, fRecordedBatches[i]->bounds());
+ }
+
+ fGpu->finishOpList();
+ return true;
+}
+
+void GrTextureOpList::reset() {
+ fRecordedBatches.reset();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+bool GrTextureOpList::copySurface(GrSurface* dst,
+ GrSurface* src,
+ const SkIRect& srcRect,
+ const SkIPoint& dstPoint) {
+ GrBatch* batch = GrCopySurfaceBatch::Create(dst, src, srcRect, dstPoint);
+ if (!batch) {
+ return false;
+ }
+#ifdef ENABLE_MDB
+ this->addDependency(src);
+#endif
+
+ this->recordBatch(batch);
+ batch->unref();
+ return true;
+}
+
+void GrTextureOpList::recordBatch(GrBatch* batch) {
+ // A closed GrOpList should never receive new/more batches
+ SkASSERT(!this->isClosed());
+
+ GR_AUDIT_TRAIL_ADDBATCH(fAuditTrail, batch);
+ GrBATCH_INFO("Re-Recording (%s, B%u)\n"
+ "\tBounds LRTB (%f, %f, %f, %f)\n",
+ batch->name(),
+ batch->uniqueID(),
+ batch->bounds().fLeft, batch->bounds().fRight,
+ batch->bounds().fTop, batch->bounds().fBottom);
+ GrBATCH_INFO(SkTabString(batch->dumpInfo(), 1).c_str());
+ GR_AUDIT_TRAIL_BATCHING_RESULT_NEW(fAuditTrail, batch);
+
+ fRecordedBatches.emplace_back(sk_ref_sp(batch));
+}
diff --git a/src/gpu/GrTextureOpList.h b/src/gpu/GrTextureOpList.h
new file mode 100644
index 0000000000..5b700dcaed
--- /dev/null
+++ b/src/gpu/GrTextureOpList.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrTexureOpList_DEFINED
+#define GrTexureOpList_DEFINED
+
+#include "GrOpList.h"
+
+#include "SkTArray.h"
+
+class GrAuditTrail;
+class GrBatch;
+class GrGpu;
+class GrTexture;
+struct SkIPoint;
+struct SkIRect;
+
+class GrTextureOpList final : public GrOpList {
+public:
+ GrTextureOpList(GrTexture*, GrGpu*, GrAuditTrail*);
+
+ ~GrTextureOpList() override;
+
+ /**
+ * Empties the draw buffer of any queued up draws.
+ */
+ void reset() override;
+
+ void abandonGpuResources() override {}
+ void freeGpuResources() override {}
+
+ /**
+ * Together these two functions flush all queued up draws to GrCommandBuffer. The return value
+ * of drawBatches() indicates whether any commands were actually issued to the GPU.
+ */
+ void prepareBatches(GrBatchFlushState* flushState) override;
+ bool drawBatches(GrBatchFlushState* flushState) override;
+
+ /**
+ * Copies a pixel rectangle from one surface to another. This call may finalize
+ * reserved vertex/index data (as though a draw call was made). The src pixels
+ * copied are specified by srcRect. They are copied to a rect of the same
+ * size in dst with top left at dstPoint. If the src rect is clipped by the
+ * src bounds then pixel values in the dst rect corresponding to area clipped
+ * by the src rect are not overwritten. This method is not guaranteed to succeed
+ * depending on the type of surface, configs, etc, and the backend-specific
+ * limitations.
+ */
+ bool copySurface(GrSurface* dst,
+ GrSurface* src,
+ const SkIRect& srcRect,
+ const SkIPoint& dstPoint);
+
+ SkDEBUGCODE(void dump() const override;)
+
+private:
+ void recordBatch(GrBatch*);
+
+ SkSTArray<2, sk_sp<GrBatch>, true> fRecordedBatches;
+ GrGpu* fGpu;
+
+ typedef GrOpList INHERITED;
+};
+
+#endif