diff options
author | 2017-03-01 14:32:46 -0500 | |
---|---|---|
committer | 2017-03-02 12:29:16 +0000 | |
commit | 256c37bc9ea2a0420b8ac1084f6d645aaeb919f0 (patch) | |
tree | 27c6ec1766362477c7d50292c6cbc1f54757bdb9 /src/gpu/GrDrawOpAtlas.h | |
parent | 9c10df3b60f4a7d50c1070a5d8c4aaadb79ba9b7 (diff) |
Remove atlas creation from GrResourceProvider
This is pulled out of: https://skia-review.googlesource.com/c/6680/ (Make SkImage_Gpu be deferred) and is only tangentially related to the goal of that CL.
Change-Id: I6b6db4869597070f85ab3b9fea178fc88c104f87
Reviewed-on: https://skia-review.googlesource.com/9106
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrDrawOpAtlas.h')
-rw-r--r-- | src/gpu/GrDrawOpAtlas.h | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/gpu/GrDrawOpAtlas.h b/src/gpu/GrDrawOpAtlas.h index 917d4ecab6..c857d07703 100644 --- a/src/gpu/GrDrawOpAtlas.h +++ b/src/gpu/GrDrawOpAtlas.h @@ -55,7 +55,26 @@ public: */ typedef void (*EvictionFunc)(GrDrawOpAtlas::AtlasID, void*); - GrDrawOpAtlas(GrContext*, sk_sp<GrTextureProxy>, int numPlotsX, int numPlotsY); + /** + * Returns a GrDrawOpAtlas. This function can be called anywhere, but the returned atlas + * should only be used inside of GrMeshDrawOp::onPrepareDraws. + * @param GrPixelConfig The pixel config which this atlas will store + * @param width width in pixels of the atlas + * @param height height in pixels of the atlas + * @param numPlotsX The number of plots the atlas should be broken up into in the X + * direction + * @param numPlotsY The number of plots the atlas should be broken up into in the Y + * direction + * @param func An eviction function which will be called whenever the atlas has to + * evict data + * @param data User supplied data which will be passed into func whenver an + * eviction occurs + * @return An initialized GrDrawOpAtlas, or nullptr if creation fails + */ + static std::unique_ptr<GrDrawOpAtlas> Make(GrContext*, GrPixelConfig, + int width, int height, + int numPlotsX, int numPlotsY, + GrDrawOpAtlas::EvictionFunc func, void* data); /** * Adds a width x height subimage to the atlas. Upon success it returns an ID and the subimage's @@ -158,6 +177,8 @@ public: } private: + GrDrawOpAtlas(GrContext*, sk_sp<GrTextureProxy>, int numPlotsX, int numPlotsY); + /** * The backing GrTexture for a GrDrawOpAtlas is broken into a spatial grid of Plots. The Plots * keep track of subimage placement via their GrRectanizer. A Plot manages the lifetime of its @@ -253,7 +274,7 @@ private: return (id >> 16) & 0xffffffffffff; } - inline void updatePlot(GrDrawOp::Target*, AtlasID*, Plot*); + inline bool updatePlot(GrDrawOp::Target*, AtlasID*, Plot*); inline void makeMRU(Plot* plot) { if (fPlotList.head() == plot) { |