diff options
author | 2015-05-19 14:41:41 -0700 | |
---|---|---|
committer | 2015-05-19 14:41:41 -0700 | |
commit | d706f11b6e3f4398ab93b23458a7599ee324be2c (patch) | |
tree | 685098a2fd9538271bf9a843eb5115b1e3010caf /src | |
parent | bb87b2104b5fe5f61c88756af6e25fbd3f5ca773 (diff) |
small cleanup of GrAtlas
BUG=skia:
Review URL: https://codereview.chromium.org/1142263002
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrAtlas.cpp | 60 | ||||
-rw-r--r-- | src/gpu/GrAtlas.h | 16 | ||||
-rw-r--r-- | src/gpu/GrDrawTarget.h | 17 | ||||
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.h | 3 |
4 files changed, 2 insertions, 94 deletions
diff --git a/src/gpu/GrAtlas.cpp b/src/gpu/GrAtlas.cpp index 7ebdf6eb12..0322f70dc0 100644 --- a/src/gpu/GrAtlas.cpp +++ b/src/gpu/GrAtlas.cpp @@ -21,8 +21,7 @@ static int g_UploadCount = 0; #endif GrPlot::GrPlot() - : fDrawToken(NULL, 0) - , fID(-1) + : fID(-1) , fTexture(NULL) , fRects(NULL) , fAtlas(NULL) @@ -106,36 +105,6 @@ bool GrPlot::addSubImage(int width, int height, const void* image, SkIPoint16* l return true; } -void GrPlot::uploadToTexture() { - static const float kNearlyFullTolerance = 0.85f; - - // should only do this if batching is enabled - SkASSERT(fBatchUploads); - - if (fDirty) { - TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "GrPlot::uploadToTexture"); - SkASSERT(fTexture); - // We pass the flag that does not force a flush. We assume our caller is - // smart and hasn't referenced the part of the texture we're about to update - // since the last flush. - size_t rowBytes = fBytesPerPixel*fRects->width(); - const unsigned char* dataPtr = fPlotData; - dataPtr += rowBytes*fDirtyRect.fTop; - dataPtr += fBytesPerPixel*fDirtyRect.fLeft; - fTexture->writePixels(fOffset.fX + fDirtyRect.fLeft, fOffset.fY + fDirtyRect.fTop, - fDirtyRect.width(), fDirtyRect.height(), fTexture->config(), dataPtr, - rowBytes, GrContext::kDontFlush_PixelOpsFlag); - fDirtyRect.setEmpty(); - fDirty = false; - // If the Plot is nearly full, anything else we add will probably be small and one - // at a time, so free up the memory and after this upload any new images directly. - if (fRects->percentFull() > kNearlyFullTolerance) { - SkDELETE_ARRAY(fPlotData); - fPlotData = NULL; - } - } -} - void GrPlot::resetRects() { SkASSERT(fRects); fRects->reset(); @@ -258,30 +227,3 @@ void GrAtlas::RemovePlot(ClientPlotUsage* usage, const GrPlot* plot) { usage->fPlots.remove(index); } } - -// get a plot that's not being used by the current draw -GrPlot* GrAtlas::getUnusedPlot() { - GrPlotList::Iter plotIter; - plotIter.init(fPlotList, GrPlotList::Iter::kTail_IterStart); - GrPlot* plot; - while ((plot = plotIter.get())) { - if (plot->drawToken().isIssued()) { - return plot; - } - plotIter.prev(); - } - - return NULL; -} - -void GrAtlas::uploadPlotsToTexture() { - if (fBatchUploads) { - GrPlotList::Iter plotIter; - plotIter.init(fPlotList, GrPlotList::Iter::kHead_IterStart); - GrPlot* plot; - while ((plot = plotIter.get())) { - plot->uploadToTexture(); - plotIter.next(); - } - } -} diff --git a/src/gpu/GrAtlas.h b/src/gpu/GrAtlas.h index 1b0854b85e..23cb326fee 100644 --- a/src/gpu/GrAtlas.h +++ b/src/gpu/GrAtlas.h @@ -41,11 +41,6 @@ public: bool addSubImage(int width, int height, const void*, SkIPoint16*); - GrDrawTarget::DrawToken drawToken() const { return fDrawToken; } - void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; } - - void uploadToTexture(); - void resetRects(); private: @@ -54,9 +49,6 @@ private: void init(GrAtlas* atlas, int id, int offX, int offY, int width, int height, size_t bpp, bool batchUploads); - // for recycling - GrDrawTarget::DrawToken fDrawToken; - int fID; unsigned char* fPlotData; GrTexture* fTexture; @@ -108,16 +100,10 @@ public: // remove reference to this plot static void RemovePlot(ClientPlotUsage* usage, const GrPlot* plot); - // get a plot that's not being used by the current draw - // this allows us to overwrite this plot without flushing - GrPlot* getUnusedPlot(); - GrTexture* getTexture() const { return fTexture; } - void uploadPlotsToTexture(); - enum IterOrder { kLRUFirst_IterOrder, kMRUFirst_IterOrder @@ -125,7 +111,7 @@ public: typedef GrPlotList::Iter PlotIter; GrPlot* iterInit(PlotIter* iter, IterOrder order) { - return iter->init(fPlotList, kLRUFirst_IterOrder == order + return iter->init(fPlotList, kLRUFirst_IterOrder == order ? GrPlotList::Iter::kTail_IterStart : GrPlotList::Iter::kHead_IterStart); } diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h index e0b96b2a3b..a5e3b8efee 100644 --- a/src/gpu/GrDrawTarget.h +++ b/src/gpu/GrDrawTarget.h @@ -202,23 +202,6 @@ public: */ virtual void purgeResources() {}; - /////////////////////////////////////////////////////////////////////////// - // Draw execution tracking (for font atlases and other resources) - class DrawToken { - public: - DrawToken(GrDrawTarget* drawTarget, uint32_t drawID) : - fDrawTarget(drawTarget), fDrawID(drawID) {} - - bool isIssued() { return fDrawTarget && fDrawTarget->isIssued(fDrawID); } - - private: - GrDrawTarget* fDrawTarget; - uint32_t fDrawID; // this may wrap, but we're doing direct comparison - // so that should be okay - }; - - virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); } - bool programUnitTest(int maxStages); protected: diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h index 4c60b691b0..908632ce6d 100644 --- a/src/gpu/GrInOrderDrawBuffer.h +++ b/src/gpu/GrInOrderDrawBuffer.h @@ -34,9 +34,6 @@ public: ~GrInOrderDrawBuffer() override; - // tracking for draws - DrawToken getCurrentDrawToken() override { return DrawToken(this, fDrawID); } - void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* renderTarget) override; |