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

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

Issue 2111943002: Hide GrNonAANinePatchBatch::Geometry and rename to Patch (Closed) Base URL: https://chromium.googlesource.com/skia.git@moremsaapr
Patch Set: Created 4 years, 6 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 | « no previous file | 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 5f5339543b0eb65bc0788bab5cc3de26720e6ce2..1c90f83dbcd6d1ccd1d78393c267fca815b4c56b 100644
--- a/src/gpu/batches/GrNinePatch.cpp
+++ b/src/gpu/batches/GrNinePatch.cpp
@@ -31,27 +31,20 @@ public:
static const int kIndicesPerRect = 6;
static const int kRectsPerInstance = 9; // We could skip empty rects
- struct Geometry {
- SkMatrix fViewMatrix;
- SkIRect fCenter;
- SkRect fDst;
- GrColor fColor;
- };
-
GrNonAANinePatchBatch(GrColor color, const SkMatrix& viewMatrix, int imageWidth,
int imageHeight, const SkIRect& center, const SkRect &dst)
: INHERITED(ClassID()) {
- Geometry& geo = fGeoData.push_back();
- geo.fViewMatrix = viewMatrix;
- geo.fColor = color;
- geo.fCenter = center;
- geo.fDst = dst;
+ Patch& patch = fPatches.push_back();
+ patch.fViewMatrix = viewMatrix;
+ patch.fColor = color;
+ patch.fCenter = center;
+ patch.fDst = dst;
fImageWidth = imageWidth;
fImageHeight = imageHeight;
// setup bounds
- geo.fViewMatrix.mapRect(&fBounds, geo.fDst);
+ patch.fViewMatrix.mapRect(&fBounds, patch.fDst);
}
const char* name() const override { return "NonAANinePatchBatch"; }
@@ -59,15 +52,15 @@ public:
SkString dumpInfo() const override {
SkString str;
- for (int i = 0; i < fGeoData.count(); ++i) {
+ for (int i = 0; i < fPatches.count(); ++i) {
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,
- fGeoData[i].fColor,
- fGeoData[i].fCenter.fLeft, fGeoData[i].fCenter.fTop,
- fGeoData[i].fCenter.fRight, fGeoData[i].fCenter.fBottom,
- fGeoData[i].fDst.fLeft, fGeoData[i].fDst.fTop,
- fGeoData[i].fDst.fRight, fGeoData[i].fDst.fBottom);
+ 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);
}
str.append(INHERITED::dumpInfo());
@@ -81,8 +74,6 @@ public:
coverage->setKnownSingleComponent(0xff);
}
- SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
-
private:
void onPrepareDraws(Target* target) const override {
sk_sp<GrGeometryProcessor> gp(create_gp(fOverrides.readsCoverage()));
@@ -92,25 +83,25 @@ private:
}
size_t vertexStride = gp->getVertexStride();
- int instanceCount = fGeoData.count();
+ int patchCnt = fPatches.count();
SkAutoTUnref<const GrBuffer> indexBuffer(
target->resourceProvider()->refQuadIndexBuffer());
InstancedHelper helper;
void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexStride,
indexBuffer, kVertsPerRect,
- kIndicesPerRect, instanceCount * kRectsPerInstance);
+ kIndicesPerRect, patchCnt * kRectsPerInstance);
if (!vertices || !indexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
}
- for (int i = 0; i < instanceCount; i++) {
+ for (int i = 0; i < patchCnt; i++) {
intptr_t verts = reinterpret_cast<intptr_t>(vertices) +
i * kRectsPerInstance * kVertsPerRect * vertexStride;
- const Geometry& geo = fGeoData[i];
- SkNinePatchIter iter(fImageWidth, fImageHeight, geo.fCenter, geo.fDst);
+ const Patch& patch = fPatches[i];
+ SkNinePatchIter iter(fImageWidth, fImageHeight, patch.fCenter, patch.fDst);
SkRect srcR, dstR;
while (iter.next(&srcR, &dstR)) {
@@ -119,8 +110,8 @@ private:
positions->setRectFan(dstR.fLeft, dstR.fTop,
dstR.fRight, dstR.fBottom, vertexStride);
- SkASSERT(!geo.fViewMatrix.hasPerspective());
- geo.fViewMatrix.mapPointsWithStride(positions, vertexStride, kVertsPerRect);
+ SkASSERT(!patch.fViewMatrix.hasPerspective());
+ patch.fViewMatrix.mapPointsWithStride(positions, vertexStride, kVertsPerRect);
// Setup local coords
static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
@@ -130,7 +121,7 @@ private:
static const int kColorOffset = sizeof(SkPoint);
GrColor* vertColor = reinterpret_cast<GrColor*>(verts + kColorOffset);
for (int j = 0; j < 4; ++j) {
- *vertColor = geo.fColor;
+ *vertColor = patch.fColor;
vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride);
}
verts += kVertsPerRect * vertexStride;
@@ -140,7 +131,7 @@ private:
}
void initBatchTracker(const GrXPOverridesForBatch& overrides) override {
- overrides.getOverrideColorIfSet(&fGeoData[0].fColor);
+ overrides.getOverrideColorIfSet(&fPatches[0].fColor);
fOverrides = overrides;
}
@@ -160,15 +151,22 @@ private:
fOverrides = that->fOverrides;
}
- fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
+ fPatches.push_back_n(that->fPatches.count(), that->fPatches.begin());
this->joinBounds(that->bounds());
return true;
}
+ struct Patch {
+ SkMatrix fViewMatrix;
+ SkIRect fCenter;
+ SkRect fDst;
+ GrColor fColor;
+ };
+
GrXPOverridesForBatch fOverrides;
int fImageWidth;
int fImageHeight;
- SkSTArray<1, Geometry, true> fGeoData;
+ SkSTArray<1, Patch, true> fPatches;
typedef GrVertexBatch INHERITED;
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698