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

Issue 1302033003: Revert of fill rect batch refactor into separate batches (Closed)

Created:
5 years, 4 months ago by joshualitt
Modified:
5 years, 3 months ago
CC:
reviews_skia.org
Base URL:
https://skia.googlesource.com/skia.git@master
Target Ref:
refs/heads/master
Project:
skia
Visibility:
Public.

Description

Revert of fill rect batch refactor into separate batches (patchset #4 id:60001 of https://codereview.chromium.org/1295773003/ ) Reason for revert: revert because breaks some mac bots in floating point texture test Original issue's description: > fill rect batch refactor into separate batches > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/ae41b3834301444cf27b8aa729b8ad36666bdc08 TBR=bsalomon@google.com,robertphillips@google.com,joshualitt@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+238 lines, -282 lines) Patch
M src/gpu/batches/GrAAFillRectBatch.cpp View 5 chunks +17 lines, -22 lines 0 comments Download
M src/gpu/batches/GrBWFillRectBatch.cpp View 3 chunks +220 lines, -257 lines 0 comments Download
M src/gpu/batches/GrTInstanceBatch.h View 2 chunks +1 line, -3 lines 0 comments Download

Messages

Total messages: 4 (1 generated)
joshualitt
Created Revert of fill rect batch refactor into separate batches
5 years, 4 months ago (2015-08-20 13:48:37 UTC) #1
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1302033003/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1302033003/1
5 years, 4 months ago (2015-08-20 13:48:51 UTC) #2
commit-bot: I haz the power
5 years, 4 months ago (2015-08-20 13:48:58 UTC) #4
Failed to apply patch for src/gpu/batches/GrBWFillRectBatch.cpp:
While running git apply --index -3 -p1;
  error: patch failed: src/gpu/batches/GrBWFillRectBatch.cpp:11
  Falling back to three-way merge...
  Applied patch to 'src/gpu/batches/GrBWFillRectBatch.cpp' with conflicts.
  U src/gpu/batches/GrBWFillRectBatch.cpp

Patch:       src/gpu/batches/GrBWFillRectBatch.cpp
Index: src/gpu/batches/GrBWFillRectBatch.cpp
diff --git a/src/gpu/batches/GrBWFillRectBatch.cpp
b/src/gpu/batches/GrBWFillRectBatch.cpp
index
ffd4cefc86e174b002a96c3ab7f874ff1f8418e2..6430cf2022d6c8a59244e3ce20999f2604ccee6a
100644
--- a/src/gpu/batches/GrBWFillRectBatch.cpp
+++ b/src/gpu/batches/GrBWFillRectBatch.cpp
@@ -11,230 +11,202 @@
 #include "GrColor.h"
 #include "GrDefaultGeoProcFactory.h"
 #include "GrPrimitiveProcessor.h"
-#include "GrResourceProvider.h"
-#include "GrTInstanceBatch.h"
 #include "GrVertexBatch.h"
 
-// Common functions
-class BWFillRectBatchBase {
-public:
-    static const int kVertsPerInstance = 4;
-    static const int kIndicesPerInstance = 6;
-
-    static const GrIndexBuffer* GetIndexBuffer(GrResourceProvider* rp) {
-        return rp->refQuadIndexBuffer();
-    }
-
-    template <typename Geometry>
-    static void SetBounds(const Geometry& geo, SkRect* outBounds) {
-        geo.fViewMatrix.mapRect(outBounds, geo.fRect);
-    }
-};
-
-/** We always use per-vertex colors so that rects can be batched across color
changes. Sometimes
-    we  have explicit local coords and sometimes not. We *could* always provide
explicit local
-    coords and just duplicate the positions when the caller hasn't provided a
local coord rect,
-    but we haven't seen a use case which frequently switches between local rect
and no local
-    rect draws.
-
-    The color param is used to determine whether the opaque hint can be set on
the draw state.
-    The caller must populate the vertex colors itself.
-
-    The vertex attrib order is always pos, color, [local coords].
- */
-static const GrGeometryProcessor* create_gp(const SkMatrix& viewMatrix,
-                                            bool readsCoverage,
-                                            bool hasExplicitLocalCoords,
-                                            const SkMatrix* localMatrix) {
-    using namespace GrDefaultGeoProcFactory;
-    Color color(Color::kAttribute_Type);
-    Coverage coverage(readsCoverage ? Coverage::kSolid_Type :
Coverage::kNone_Type);
-
-    // if we have a local rect, then we apply the localMatrix directly to the
localRect to
-    // generate vertex local coords
-    if (hasExplicitLocalCoords) {
-        LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
-        return GrDefaultGeoProcFactory::Create(color, coverage, localCoords,
SkMatrix::I());
-    } else {
-        LocalCoords localCoords(LocalCoords::kUsePosition_Type, localMatrix ?
localMatrix : NULL);
-        return GrDefaultGeoProcFactory::CreateForDeviceSpace(color, coverage,
localCoords,
-                                                             viewMatrix);
-    }
-}
-
-static void tesselate(intptr_t vertices,
-                      size_t vertexStride,
-                      GrColor color,
-                      const SkMatrix& viewMatrix,
-                      const SkRect& rect,
-                      const SkRect* localRect,
-                      const SkMatrix* localMatrix) {
-    SkPoint* positions = reinterpret_cast<SkPoint*>(vertices);
-
-    positions->setRectFan(rect.fLeft, rect.fTop,
-                          rect.fRight, rect.fBottom, vertexStride);
-    viewMatrix.mapPointsWithStride(positions, vertexStride,
BWFillRectBatchBase::kVertsPerInstance);
-
-    // TODO we should only do this if local coords are being read
-    if (localRect) {
-        static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
-        SkPoint* coords = reinterpret_cast<SkPoint*>(vertices + kLocalOffset);
-        coords->setRectFan(localRect->fLeft, localRect->fTop,
-                           localRect->fRight, localRect->fBottom,
-                           vertexStride);
-        if (localMatrix) {
-            localMatrix->mapPointsWithStride(coords, vertexStride,
-                                            
BWFillRectBatchBase::kVertsPerInstance);
-        }
-    }
-
-    static const int kColorOffset = sizeof(SkPoint);
-    GrColor* vertColor = reinterpret_cast<GrColor*>(vertices + kColorOffset);
-    for (int j = 0; j < 4; ++j) {
-        *vertColor = color;
-        vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride);
-    }
-}
-
-class BWFillRectBatchNoLocalMatrixImp : public BWFillRectBatchBase {
-public:
-    struct Geometry {
-        SkMatrix fViewMatrix;
-        SkRect fRect;
-        GrColor fColor;
-    };
-
-    static const char* Name() { return "BWFillRectBatchNoLocalMatrix"; }
-
-    static bool CanCombine(const Geometry& mine, const Geometry& theirs,
-                           const GrPipelineOptimizations& opts) {
-        // We apply the viewmatrix to the rect points on the cpu.  However, if
the pipeline uses
-        // local coords then we won't be able to batch.  We could actually
upload the viewmatrix
-        // using vertex attributes in these cases, but haven't investigated
that
-        return !opts.readsLocalCoords() ||
mine.fViewMatrix.cheapEqualTo(theirs.fViewMatrix);
-    }
-
-    static const GrGeometryProcessor* CreateGP(const Geometry& geo,
-                                               const GrPipelineOptimizations&
opts) {
-        const GrGeometryProcessor* gp = create_gp(geo.fViewMatrix,
opts.readsCoverage(), false,
-                                                  NULL);
-
-        SkASSERT(gp->getVertexStride() ==
sizeof(GrDefaultGeoProcFactory::PositionColorAttr));
-        return gp;
-    }
-
-    static void Tesselate(intptr_t vertices, size_t vertexStride, const
Geometry& geo,
-                          const GrPipelineOptimizations& opts) {
-        tesselate(vertices, vertexStride, geo.fColor, geo.fViewMatrix,
geo.fRect, NULL, NULL);
-    }
-};
-
-class BWFillRectBatchLocalMatrixImp : public BWFillRectBatchBase {
-public:
-    struct Geometry {
-        SkMatrix fViewMatrix;
-        SkMatrix fLocalMatrix;
-        SkRect fRect;
-        GrColor fColor;
-    };
-
-    static const char* Name() { return "BWFillRectBatchLocalMatrix"; }
-
-    static bool CanCombine(const Geometry& mine, const Geometry& theirs,
-                           const GrPipelineOptimizations& opts) {
-        // We apply the viewmatrix to the rect points on the cpu.  However, if
the pipeline uses
-        // local coords then we won't be able to batch.  We could actually
upload the viewmatrix
-        // using vertex attributes in these cases, but haven't investigated
that
-        return !opts.readsLocalCoords() ||
mine.fViewMatrix.cheapEqualTo(theirs.fViewMatrix);
-    }
-
-    static const GrGeometryProcessor* CreateGP(const Geometry& geo,
-                                               const GrPipelineOptimizations&
opts) {
-        const GrGeometryProcessor* gp = create_gp(geo.fViewMatrix,
opts.readsCoverage(), false,
-                                                  &geo.fLocalMatrix);
-
-        SkASSERT(gp->getVertexStride() ==
sizeof(GrDefaultGeoProcFactory::PositionColorAttr));
-        return gp;
-    }
-
-    static void Tesselate(intptr_t vertices, size_t vertexStride, const
Geometry& geo,
-                          const GrPipelineOptimizations& opts) {
-        tesselate(vertices, vertexStride, geo.fColor, geo.fViewMatrix,
geo.fRect, NULL,
-                  &geo.fLocalMatrix);
-    }
-};
-
-class BWFillRectBatchLocalRectImp : public BWFillRectBatchBase {
+class GrBatchFlushState;
+class SkMatrix;
+struct SkRect;
+
+class BWFillRectBatch : public GrVertexBatch {
 public:
     struct Geometry {
         SkMatrix fViewMatrix;
         SkRect fRect;
         SkRect fLocalRect;
+        SkMatrix fLocalMatrix;
         GrColor fColor;
+        bool fHasLocalRect;
+        bool fHasLocalMatrix;
     };
 
-    static const char* Name() { return "BWFillRectBatchLocalRect"; }
-
-    static bool CanCombine(const Geometry& mine, const Geometry& theirs,
-                           const GrPipelineOptimizations& opts) {
+    static GrDrawBatch* Create(const Geometry& geometry) {
+        return SkNEW_ARGS(BWFillRectBatch, (geometry));
+    }
+
+    const char* name() const override { return "RectBatch"; }
+
+    void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
+        // When this is called on a batch, there is only one geometry bundle
+        out->setKnownFourComponents(fGeoData[0].fColor);
+    }
+
+    void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override
{
+        out->setKnownSingleComponent(0xff);
+    }
+
+    SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
+
+private:
+    BWFillRectBatch(const Geometry& geometry) {
+        this->initClassID<BWFillRectBatch>();
+        fGeoData.push_back(geometry);
+
+        fBounds = geometry.fRect;
+        geometry.fViewMatrix.mapRect(&fBounds);
+    }
+
+    GrColor color() const { return fBatch.fColor; }
+    bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
+    bool colorIgnored() const { return fBatch.fColorIgnored; }
+    const SkMatrix& viewMatrix() const { return fGeoData[0].fViewMatrix; }
+    const SkMatrix& localMatrix() const { return fGeoData[0].fLocalMatrix; }
+    bool hasLocalRect() const { return fGeoData[0].fHasLocalRect; }
+    bool hasLocalMatrix() const { return fGeoData[0].fHasLocalMatrix; }
+    bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
+
+    void initBatchTracker(const GrPipelineOptimizations& init) override {
+        // Handle any color overrides
+        if (!init.readsColor()) {
+            fGeoData[0].fColor = GrColor_ILLEGAL;
+        }
+        init.getOverrideColorIfSet(&fGeoData[0].fColor);
+
+        // setup batch properti…
(message too large)

Powered by Google App Engine
This is Rietveld 408576698