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

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

Issue 1842753002: Style bikeshed - remove extraneous whitespace (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/GrDrawAtlasBatch.h ('k') | src/gpu/batches/GrDrawBatch.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrDrawAtlasBatch.cpp
diff --git a/src/gpu/batches/GrDrawAtlasBatch.cpp b/src/gpu/batches/GrDrawAtlasBatch.cpp
index f3b497a13239e299f125b6184a1e51048fce7058..3884ef200f055f4c7736c5573b7cb2b8796411a0 100644
--- a/src/gpu/batches/GrDrawAtlasBatch.cpp
+++ b/src/gpu/batches/GrDrawAtlasBatch.cpp
@@ -45,7 +45,7 @@ static const GrGeometryProcessor* set_vertex_attributes(bool hasColors,
if (hasColors) {
gpColor.fType = Color::kAttribute_Type;
}
-
+
Coverage coverage(coverageIgnored ? Coverage::kNone_Type : Coverage::kSolid_Type);
LocalCoords localCoords(LocalCoords::kHasExplicit_Type);
return GrDefaultGeoProcFactory::Create(gpColor, coverage, localCoords, viewMatrix);
@@ -57,14 +57,14 @@ void GrDrawAtlasBatch::onPrepareDraws(Target* target) const {
this->color(),
this->viewMatrix(),
this->coverageIgnored()));
-
+
target->initDraw(gp);
-
+
int instanceCount = fGeoData.count();
size_t vertexStride = gp->getVertexStride();
SkASSERT(vertexStride == sizeof(SkPoint) + sizeof(SkPoint)
+ (this->hasColors() ? sizeof(GrColor) : 0));
-
+
QuadHelper helper;
int numQuads = this->quadCount();
void* verts = helper.init(target, vertexStride, numQuads);
@@ -72,11 +72,11 @@ void GrDrawAtlasBatch::onPrepareDraws(Target* target) const {
SkDebugf("Could not allocate vertices\n");
return;
}
-
+
uint8_t* vertPtr = reinterpret_cast<uint8_t*>(verts);
for (int i = 0; i < instanceCount; i++) {
const Geometry& args = fGeoData[i];
-
+
size_t allocSize = args.fVerts.count();
memcpy(vertPtr, args.fVerts.begin(), allocSize);
vertPtr += allocSize;
@@ -90,10 +90,10 @@ GrDrawAtlasBatch::GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& vie
: INHERITED(ClassID()) {
SkASSERT(xforms);
SkASSERT(rects);
-
+
fViewMatrix = viewMatrix;
Geometry& installedGeo = fGeoData.push_back(geometry);
-
+
// Figure out stride and offsets
// Order within the vertex is: position [color] texCoord
size_t texOffset = sizeof(SkPoint);
@@ -103,13 +103,13 @@ GrDrawAtlasBatch::GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& vie
texOffset += sizeof(GrColor);
vertexStride += sizeof(GrColor);
}
-
+
// Compute buffer size and alloc buffer
fQuadCount = spriteCount;
int allocSize = static_cast<int>(4*vertexStride*spriteCount);
installedGeo.fVerts.reset(allocSize);
uint8_t* currVertex = installedGeo.fVerts.begin();
-
+
SkRect bounds;
bounds.setLargestInverted();
int paintAlpha = GrColorUnpackA(installedGeo.fColor);
@@ -118,7 +118,7 @@ GrDrawAtlasBatch::GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& vie
SkPoint quad[4];
const SkRect& currRect = rects[spriteIndex];
xforms[spriteIndex].toQuad(currRect.width(), currRect.height(), quad);
-
+
// Copy colors if necessary
if (colors) {
// convert to GrColor
@@ -127,13 +127,13 @@ GrDrawAtlasBatch::GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& vie
color = SkColorSetA(color, SkMulDiv255Round(SkColorGetA(color), paintAlpha));
}
GrColor grColor = SkColorToPremulGrColor(color);
-
+
*(reinterpret_cast<GrColor*>(currVertex+sizeof(SkPoint))) = grColor;
*(reinterpret_cast<GrColor*>(currVertex+vertexStride+sizeof(SkPoint))) = grColor;
*(reinterpret_cast<GrColor*>(currVertex+2*vertexStride+sizeof(SkPoint))) = grColor;
*(reinterpret_cast<GrColor*>(currVertex+3*vertexStride+sizeof(SkPoint))) = grColor;
}
-
+
// Copy position and uv to verts
*(reinterpret_cast<SkPoint*>(currVertex)) = quad[0];
*(reinterpret_cast<SkPoint*>(currVertex+texOffset)) = SkPoint::Make(currRect.fLeft,
@@ -146,26 +146,26 @@ GrDrawAtlasBatch::GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& vie
currRect.fTop);
bounds.growToInclude(quad[1].fX, quad[1].fY);
currVertex += vertexStride;
-
+
*(reinterpret_cast<SkPoint*>(currVertex)) = quad[2];
*(reinterpret_cast<SkPoint*>(currVertex+texOffset)) = SkPoint::Make(currRect.fRight,
currRect.fBottom);
bounds.growToInclude(quad[2].fX, quad[2].fY);
currVertex += vertexStride;
-
+
*(reinterpret_cast<SkPoint*>(currVertex)) = quad[3];
*(reinterpret_cast<SkPoint*>(currVertex+texOffset)) = SkPoint::Make(currRect.fLeft,
currRect.fBottom);
bounds.growToInclude(quad[3].fX, quad[3].fY);
currVertex += vertexStride;
}
-
+
viewMatrix.mapRect(&bounds);
// Outset for a half pixel in each direction to account for snapping in non-AA case
bounds.outset(0.5f, 0.5f);
this->setBounds(bounds);
}
-
+
bool GrDrawAtlasBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
GrDrawAtlasBatch* that = t->cast<GrDrawAtlasBatch>();
@@ -178,21 +178,21 @@ bool GrDrawAtlasBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) {
if (!this->viewMatrix().cheapEqualTo(that->viewMatrix())) {
return false;
}
-
+
if (this->hasColors() != that->hasColors()) {
return false;
}
-
+
if (!this->hasColors() && this->color() != that->color()) {
return false;
}
-
+
if (this->color() != that->color()) {
fColor = GrColor_ILLEGAL;
}
fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin());
fQuadCount += that->quadCount();
-
+
this->joinBounds(that->bounds());
return true;
}
@@ -219,7 +219,7 @@ static SkRSXform random_xform(SkRandom* random) {
static SkRect random_texRect(SkRandom* random) {
static const SkScalar kMinCoord = 0.0f;
static const SkScalar kMaxCoord = 1024.f;
-
+
SkRect texRect = SkRect::MakeLTRB(random->nextRangeScalar(kMinCoord, kMaxCoord),
random->nextRangeScalar(kMinCoord, kMaxCoord),
random->nextRangeScalar(kMinCoord, kMaxCoord),
@@ -243,21 +243,21 @@ static void randomize_params(uint32_t count, SkRandom* random,
DRAW_BATCH_TEST_DEFINE(GrDrawAtlasBatch) {
uint32_t spriteCount = random->nextRangeU(1, 100);
-
+
SkTArray<SkRSXform> xforms(spriteCount);
SkTArray<SkRect> texRects(spriteCount);
SkTArray<GrColor> colors;
-
+
bool hasColors = random->nextBool();
-
+
randomize_params(spriteCount,
random,
&xforms,
&texRects,
&colors, hasColors);
-
+
SkMatrix viewMatrix = GrTest::TestMatrix(random);
-
+
GrDrawAtlasBatch::Geometry geometry;
geometry.fColor = GrRandomColor(random);
return GrDrawAtlasBatch::Create(geometry, viewMatrix, spriteCount, xforms.begin(),
« no previous file with comments | « src/gpu/batches/GrDrawAtlasBatch.h ('k') | src/gpu/batches/GrDrawBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698