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

Unified Diff: src/gpu/GrReorderCommandBuilder.cpp

Issue 1129943004: Initial CL to create Reorder command builder behind a flag (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more tidying 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/GrReorderCommandBuilder.h ('k') | src/gpu/GrTargetCommands.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrReorderCommandBuilder.cpp
diff --git a/src/gpu/GrReorderCommandBuilder.cpp b/src/gpu/GrReorderCommandBuilder.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3ba95d7c966858501e0aed9bd09f4c803b3c2496
--- /dev/null
+++ b/src/gpu/GrReorderCommandBuilder.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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 "GrReorderCommandBuilder.h"
+
+static bool intersect(const SkRect& a, const SkRect& b) {
+ SkASSERT(a.fLeft <= a.fRight && a.fTop <= a.fBottom &&
+ b.fLeft <= b.fRight && b.fTop <= b.fBottom);
+ return a.fLeft < b.fRight && b.fLeft < a.fRight &&
+ a.fTop < b.fBottom && b.fTop < a.fBottom;
+}
+
+GrTargetCommands::Cmd* GrReorderCommandBuilder::recordDrawBatch(State* state, GrBatch* batch) {
+ // Check if there is a Batch Draw we can batch with by linearly searching back until we either
+ // 1) check every draw
+ // 2) intersect with something
+ // 3) find a 'blocker'
+ if (!this->cmdBuffer()->empty()) {
+ GrTargetCommands::CmdBuffer::ReverseIter reverseIter(*this->cmdBuffer());
+
+ do {
+ if (Cmd::kDrawBatch_CmdType == reverseIter->type()) {
+ DrawBatch* previous = static_cast<DrawBatch*>(reverseIter.get());
+
+ if (previous->fState->getPipeline()->isEqual(*state->getPipeline()) &&
+ previous->fBatch->combineIfPossible(batch)) {
+ return NULL;
+ }
+
+ if (intersect(previous->fBatch->bounds(), batch->bounds())) {
+ break;
+ }
+ } else {
+ // TODO temporary until we can navigate the other types of commands
+ break;
+ }
+ } while (reverseIter.previous());
+ }
+
+ return GrNEW_APPEND_TO_RECORDER(*this->cmdBuffer(), DrawBatch, (state, batch,
+ this->batchTarget()));
+}
« no previous file with comments | « src/gpu/GrReorderCommandBuilder.h ('k') | src/gpu/GrTargetCommands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698