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

Unified Diff: src/gpu/GrAADistanceFieldPathRenderer.cpp

Issue 919693003: remove goto in Distance field path renderer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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/GrAADistanceFieldPathRenderer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAADistanceFieldPathRenderer.cpp
diff --git a/src/gpu/GrAADistanceFieldPathRenderer.cpp b/src/gpu/GrAADistanceFieldPathRenderer.cpp
index b11769c7c743a57cdfc88ecdabaced1f34635d4d..f2d618efcde2a3116ceef6364325a39213531139 100755
--- a/src/gpu/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/GrAADistanceFieldPathRenderer.cpp
@@ -150,6 +150,40 @@ bool GrAADistanceFieldPathRenderer::onDrawPath(GrDrawTarget* target,
// padding around path bounds to allow for antialiased pixels
const SkScalar kAntiAliasPad = 1.0f;
+inline bool GrAADistanceFieldPathRenderer::uploadPath(GrPlot** plot, SkIPoint16* atlasLocation,
+ int width, int height, void* dfStorage) {
+ *plot = fAtlas->addToAtlas(&fPlotUsage, width, height, dfStorage, atlasLocation);
+
+ // if atlas full
+ if (NULL == *plot) {
+ if (this->freeUnusedPlot()) {
+ *plot = fAtlas->addToAtlas(&fPlotUsage, width, height, dfStorage, atlasLocation);
+ if (*plot) {
+ return true;
+ }
+ }
+
+ if (c_DumpPathCache) {
+#ifdef SK_DEVELOPER
+ GrTexture* texture = fAtlas->getTexture();
+ texture->surfacePriv().savePixels("pathcache.png");
+#endif
+ }
+
+ // before we purge the cache, we must flush any accumulated draws
+ fContext->flush();
+
+ if (this->freeUnusedPlot()) {
+ *plot = fAtlas->addToAtlas(&fPlotUsage, width, height, dfStorage, atlasLocation);
+ if (*plot) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return true;
+}
+
GrAADistanceFieldPathRenderer::PathData* GrAADistanceFieldPathRenderer::addPathToAtlas(
const SkPath& path,
const SkStrokeRec& stroke,
@@ -209,42 +243,12 @@ GrAADistanceFieldPathRenderer::PathData* GrAADistanceFieldPathRenderer::addPathT
helper.toSDF((unsigned char*) dfStorage.get());
// add to atlas
+ GrPlot* plot;
SkIPoint16 atlasLocation;
- GrPlot* plot = fAtlas->addToAtlas(&fPlotUsage, width, height, dfStorage.get(),
- &atlasLocation);
-
- // if atlas full
- if (NULL == plot) {
- if (this->freeUnusedPlot()) {
- plot = fAtlas->addToAtlas(&fPlotUsage, width, height, dfStorage.get(),
- &atlasLocation);
- if (plot) {
- goto HAS_ATLAS;
- }
- }
-
- if (c_DumpPathCache) {
-#ifdef SK_DEVELOPER
- GrTexture* texture = fAtlas->getTexture();
- texture->surfacePriv().savePixels("pathcache.png");
-#endif
- }
-
- // before we purge the cache, we must flush any accumulated draws
- fContext->flush();
-
- if (this->freeUnusedPlot()) {
- plot = fAtlas->addToAtlas(&fPlotUsage, width, height, dfStorage.get(),
- &atlasLocation);
- if (plot) {
- goto HAS_ATLAS;
- }
- }
-
+ if (!this->uploadPath(&plot, &atlasLocation, width, height, dfStorage.get())) {
jvanverth1 2015/02/11 18:14:20 I think this should be okay -- but I would test on
return NULL;
}
-
-HAS_ATLAS:
+
// add to cache
PathData* pathData = SkNEW(PathData);
pathData->fKey.fGenID = path.getGenerationID();
« no previous file with comments | « src/gpu/GrAADistanceFieldPathRenderer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698