diff options
author | bsalomon <bsalomon@google.com> | 2016-07-13 14:45:28 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-13 14:45:28 -0700 |
commit | 6d6b6ad0f30504b6d0540f1f6bc7c072f33e85b2 (patch) | |
tree | c4a913961ac6937351f2e5608a3b0e9e9d668bd5 /src/gpu/GrBatchAtlas.cpp | |
parent | 50ead53ac97deb23310916e3736c3f5e2d8f7f4b (diff) |
Make GrBatchAtlas robust against attempts to add large rects.
Make GrAADistanceFieldPathRenderer robust against paths that in src space wind up being too large for the atlas.
BUG=chromium:627443
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2144663004
Review-Url: https://codereview.chromium.org/2144663004
Diffstat (limited to 'src/gpu/GrBatchAtlas.cpp')
-rw-r--r-- | src/gpu/GrBatchAtlas.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/gpu/GrBatchAtlas.cpp b/src/gpu/GrBatchAtlas.cpp index 40ab0e6c0e..8cc6f61811 100644 --- a/src/gpu/GrBatchAtlas.cpp +++ b/src/gpu/GrBatchAtlas.cpp @@ -116,11 +116,11 @@ GrBatchAtlas::GrBatchAtlas(GrTexture* texture, int numPlotsX, int numPlotsY) : fTexture(texture) , fAtlasGeneration(kInvalidAtlasGeneration + 1) { - int plotWidth = texture->width() / numPlotsX; - int plotHeight = texture->height() / numPlotsY; + fPlotWidth = texture->width() / numPlotsX; + fPlotHeight = texture->height() / numPlotsY; SkASSERT(numPlotsX * numPlotsY <= BulkUseTokenUpdater::kMaxPlots); - SkASSERT(plotWidth * numPlotsX == texture->width()); - SkASSERT(plotHeight * numPlotsY == texture->height()); + SkASSERT(fPlotWidth * numPlotsX == texture->width()); + SkASSERT(fPlotHeight * numPlotsY == texture->height()); SkDEBUGCODE(fNumPlots = numPlotsX * numPlotsY;) @@ -134,7 +134,7 @@ GrBatchAtlas::GrBatchAtlas(GrTexture* texture, int numPlotsX, int numPlotsY) for (int y = numPlotsY - 1, r = 0; y >= 0; --y, ++r) { for (int x = numPlotsX - 1, c = 0; x >= 0; --x, ++c) { uint32_t index = r * numPlotsX + c; - currPlot->reset(new BatchPlot(index, 1, x, y, plotWidth, plotHeight, + currPlot->reset(new BatchPlot(index, 1, x, y, fPlotWidth, fPlotHeight, texture->desc().fConfig)); // build LRU list @@ -179,6 +179,9 @@ bool GrBatchAtlas::addToAtlas(AtlasID* id, GrDrawBatch::Target* target, int width, int height, const void* image, SkIPoint16* loc) { // We should already have a texture, TODO clean this up SkASSERT(fTexture); + if (width > fPlotWidth || height > fPlotHeight) { + return false; + } // now look through all allocated plots for one we can share, in Most Recently Refed order GrBatchPlotList::Iter plotIter; |