remove goto in Distance field path renderer
BUG=skia: Review URL: https://codereview.chromium.org/919693003
This commit is contained in:
parent
bb0502eec5
commit
9491f7ff31
@ -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())) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HAS_ATLAS:
|
||||
|
||||
// add to cache
|
||||
PathData* pathData = SkNEW(PathData);
|
||||
pathData->fKey.fGenID = path.getGenerationID();
|
||||
|
@ -83,6 +83,8 @@ private:
|
||||
|
||||
bool internalDrawPath(GrDrawTarget*, GrPipelineBuilder*, GrColor, const SkMatrix& viewMatrix,
|
||||
const SkPath& path, const PathData* pathData);
|
||||
inline bool uploadPath(GrPlot** plot, SkIPoint16* atlasLocation, int width, int height,
|
||||
void* dfStorage);
|
||||
PathData* addPathToAtlas(const SkPath& path, const SkStrokeRec& stroke, bool antiAlias,
|
||||
uint32_t dimension, SkScalar scale);
|
||||
bool freeUnusedPlot();
|
||||
|
Loading…
Reference in New Issue
Block a user