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

Unified Diff: src/gpu/GrBatchAtlas.cpp

Issue 2144663004: Make GrBatchAtlas robust against attempts to add large rects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix warning Created 4 years, 5 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/GrBatchAtlas.h ('k') | src/gpu/batches/GrAADistanceFieldPathRenderer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrBatchAtlas.cpp
diff --git a/src/gpu/GrBatchAtlas.cpp b/src/gpu/GrBatchAtlas.cpp
index 40ab0e6c0e09d562ecc483d6130a2a65db509a41..8cc6f6181149f3223c78e06f79255c7289fccd57 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;
« no previous file with comments | « src/gpu/GrBatchAtlas.h ('k') | src/gpu/batches/GrAADistanceFieldPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698