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

Unified Diff: src/gpu/batches/GrNinePatch.cpp

Issue 2255683004: Revert of Batched implementation of drawLattice() for GPU (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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/batches/GrNinePatch.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrNinePatch.cpp
diff --git a/src/gpu/batches/GrNinePatch.cpp b/src/gpu/batches/GrNinePatch.cpp
index 729d27ecac268b7d7cf4bec723d2545bc9d29715..cde3d266ca6f26b18ba0e797dbb489c79c09a01f 100644
--- a/src/gpu/batches/GrNinePatch.cpp
+++ b/src/gpu/batches/GrNinePatch.cpp
@@ -29,14 +29,15 @@
static const int kVertsPerRect = 4;
static const int kIndicesPerRect = 6;
+ static const int kRectsPerInstance = 9; // We could skip empty rects
GrNonAANinePatchBatch(GrColor color, const SkMatrix& viewMatrix, int imageWidth,
- int imageHeight, std::unique_ptr<SkLatticeIter> iter, const SkRect &dst)
+ int imageHeight, const SkIRect& center, const SkRect &dst)
: INHERITED(ClassID()) {
Patch& patch = fPatches.push_back();
patch.fViewMatrix = viewMatrix;
patch.fColor = color;
- patch.fIter = std::move(iter);
+ patch.fCenter = center;
patch.fDst = dst;
fImageWidth = imageWidth;
@@ -52,9 +53,12 @@
SkString str;
for (int i = 0; i < fPatches.count(); ++i) {
- str.appendf("%d: Color: 0x%08x Dst [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
+ str.appendf("%d: Color: 0x%08x Center [L: %d, T: %d, R: %d, B: %d], "
+ "Dst [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
i,
fPatches[i].fColor,
+ fPatches[i].fCenter.fLeft, fPatches[i].fCenter.fTop,
+ fPatches[i].fCenter.fRight, fPatches[i].fCenter.fBottom,
fPatches[i].fDst.fLeft, fPatches[i].fDst.fTop,
fPatches[i].fDst.fRight, fPatches[i].fDst.fBottom);
}
@@ -80,39 +84,34 @@
size_t vertexStride = gp->getVertexStride();
int patchCnt = fPatches.count();
- int numRects = 0;
- for (int i = 0; i < patchCnt; i++) {
- numRects += fPatches[i].fIter->numRects();
- }
SkAutoTUnref<const GrBuffer> indexBuffer(
target->resourceProvider()->refQuadIndexBuffer());
InstancedHelper helper;
void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexStride,
indexBuffer, kVertsPerRect,
- kIndicesPerRect, patchCnt * numRects);
+ kIndicesPerRect, patchCnt * kRectsPerInstance);
if (!vertices || !indexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
}
- intptr_t verts = reinterpret_cast<intptr_t>(vertices);
for (int i = 0; i < patchCnt; i++) {
+ intptr_t verts = reinterpret_cast<intptr_t>(vertices) +
+ i * kRectsPerInstance * kVertsPerRect * vertexStride;
+
const Patch& patch = fPatches[i];
-
- // Apply the view matrix here if it is scale-translate. Otherwise, we need to
- // wait until we've created the dst rects.
- bool isScaleTranslate = patch.fViewMatrix.isScaleTranslate();
- if (isScaleTranslate) {
- patch.fIter->mapDstScaleTranslate(patch.fViewMatrix);
- }
+ SkLatticeIter iter(fImageWidth, fImageHeight, patch.fCenter, patch.fDst);
SkRect srcR, dstR;
- intptr_t patchVerts = verts;
- while (patch.fIter->next(&srcR, &dstR)) {
+ while (iter.next(&srcR, &dstR)) {
SkPoint* positions = reinterpret_cast<SkPoint*>(verts);
+
positions->setRectFan(dstR.fLeft, dstR.fTop,
dstR.fRight, dstR.fBottom, vertexStride);
+
+ SkASSERT(!patch.fViewMatrix.hasPerspective());
+ patch.fViewMatrix.mapPointsWithStride(positions, vertexStride, kVertsPerRect);
// Setup local coords
static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
@@ -126,13 +125,6 @@
vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride);
}
verts += kVertsPerRect * vertexStride;
- }
-
- // If we didn't handle it above, apply the matrix here.
- if (!isScaleTranslate) {
- SkPoint* positions = reinterpret_cast<SkPoint*>(patchVerts);
- patch.fViewMatrix.mapPointsWithStride(positions, vertexStride,
- kVertsPerRect * patch.fIter->numRects());
}
}
helper.recordDraw(target, gp.get());
@@ -159,14 +151,14 @@
fOverrides = that->fOverrides;
}
- fPatches.move_back_n(that->fPatches.count(), that->fPatches.begin());
+ fPatches.push_back_n(that->fPatches.count(), that->fPatches.begin());
this->joinBounds(*that);
return true;
}
struct Patch {
SkMatrix fViewMatrix;
- std::unique_ptr<SkLatticeIter> fIter;
+ SkIRect fCenter;
SkRect fDst;
GrColor fColor;
};
@@ -181,8 +173,7 @@
namespace GrNinePatch {
GrDrawBatch* CreateNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWidth, int imageHeight,
- std::unique_ptr<SkLatticeIter> iter, const SkRect& dst) {
- return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight, std::move(iter),
- dst);
+ const SkIRect& center, const SkRect& dst) {
+ return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight, center, dst);
}
};
« no previous file with comments | « src/gpu/batches/GrNinePatch.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698