small cleanup of GrAtlas
BUG=skia:
Review URL: https://codereview.chromium.org/1142263002
diff --git a/src/gpu/GrAtlas.cpp b/src/gpu/GrAtlas.cpp
index 7ebdf6e..0322f70 100644
--- a/src/gpu/GrAtlas.cpp
+++ b/src/gpu/GrAtlas.cpp
@@ -21,8 +21,7 @@
#endif
GrPlot::GrPlot()
- : fDrawToken(NULL, 0)
- , fID(-1)
+ : fID(-1)
, fTexture(NULL)
, fRects(NULL)
, fAtlas(NULL)
@@ -106,36 +105,6 @@
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 @@
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 1b0854b..23cb326 100644
--- a/src/gpu/GrAtlas.h
+++ b/src/gpu/GrAtlas.h
@@ -41,11 +41,6 @@
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 @@
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 @@
// 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 @@
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 e0b96b2..a5e3b8e 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -202,23 +202,6 @@
*/
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 4c60b69..908632c 100644
--- a/src/gpu/GrInOrderDrawBuffer.h
+++ b/src/gpu/GrInOrderDrawBuffer.h
@@ -34,9 +34,6 @@
~GrInOrderDrawBuffer() override;
- // tracking for draws
- DrawToken getCurrentDrawToken() override { return DrawToken(this, fDrawID); }
-
void clearStencilClip(const SkIRect& rect,
bool insideClip,
GrRenderTarget* renderTarget) override;