jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Jim Van Verth | 8301046 | 2017-03-16 08:45:39 -0400 | [diff] [blame] | 8 | #ifndef GrSmallPathRenderer_DEFINED |
| 9 | #define GrSmallPathRenderer_DEFINED |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 10 | |
Brian Salomon | 903da79 | 2016-12-16 14:24:46 -0500 | [diff] [blame] | 11 | #include "GrDrawOpAtlas.h" |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 12 | #include "GrOnFlushResourceProvider.h" |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 13 | #include "GrPathRenderer.h" |
| 14 | #include "GrRect.h" |
bsalomon | ee43241 | 2016-06-27 07:18:18 -0700 | [diff] [blame] | 15 | #include "GrShape.h" |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 16 | |
mtklein | 4e97607 | 2016-08-08 09:06:27 -0700 | [diff] [blame] | 17 | #include "SkOpts.h" |
bsalomon | 71cb0c2 | 2014-11-14 12:10:14 -0800 | [diff] [blame] | 18 | #include "SkTDynamicHash.h" |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 19 | |
| 20 | class GrContext; |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 21 | |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 22 | class ShapeData; |
| 23 | class ShapeDataKey; |
| 24 | |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 25 | class GrSmallPathRenderer : public GrPathRenderer, public GrOnFlushCallbackObject { |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 26 | public: |
Jim Van Verth | 8301046 | 2017-03-16 08:45:39 -0400 | [diff] [blame] | 27 | GrSmallPathRenderer(); |
Brian Salomon | d3b6597 | 2017-03-22 12:05:03 -0400 | [diff] [blame] | 28 | ~GrSmallPathRenderer() override; |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 29 | |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 30 | // GrOnFlushCallbackObject overrides |
| 31 | // |
| 32 | // Note: because this class is associated with a path renderer we want it to be removed from |
| 33 | // the list of active OnFlushBackkbackObjects in an freeGpuResources call (i.e., we accept the |
| 34 | // default retainOnFreeGpuResources implementation). |
| 35 | |
Robert Phillips | cd5099c | 2018-02-09 09:56:56 -0500 | [diff] [blame] | 36 | void preFlush(GrOnFlushResourceProvider* onFlushResourceProvider, const uint32_t*, int, |
| 37 | SkTArray<sk_sp<GrRenderTargetContext>>*) override { |
| 38 | if (fAtlas) { |
| 39 | fAtlas->instantiate(onFlushResourceProvider); |
| 40 | } |
| 41 | } |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 42 | |
Chris Dalton | 3968ff9 | 2017-11-27 12:26:31 -0700 | [diff] [blame] | 43 | void postFlush(GrDeferredUploadToken startTokenForNextFlush, |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 44 | const uint32_t* /*opListIDs*/, int /*numOpListIDs*/) override { |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 45 | if (fAtlas) { |
| 46 | fAtlas->compact(startTokenForNextFlush); |
| 47 | } |
| 48 | } |
| 49 | |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 50 | using ShapeCache = SkTDynamicHash<ShapeData, ShapeDataKey>; |
| 51 | typedef SkTInternalLList<ShapeData> ShapeDataList; |
| 52 | |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 53 | static std::unique_ptr<GrDrawOp> createOp_TestingOnly(GrContext*, |
| 54 | GrPaint&&, |
| 55 | const GrShape&, |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 56 | const SkMatrix& viewMatrix, |
| 57 | GrDrawOpAtlas* atlas, |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 58 | ShapeCache*, |
| 59 | ShapeDataList*, |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 60 | bool gammaCorrect, |
| 61 | const GrUserStencilSettings*); |
| 62 | struct PathTestStruct; |
| 63 | |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 64 | private: |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 65 | class SmallPathOp; |
| 66 | |
bsalomon | 8acedde | 2016-06-24 10:42:16 -0700 | [diff] [blame] | 67 | StencilSupport onGetStencilSupport(const GrShape&) const override { |
robertphillips | e7d4b2f | 2015-08-13 07:57:10 -0700 | [diff] [blame] | 68 | return GrPathRenderer::kNoSupport_StencilSupport; |
| 69 | } |
bsalomon | 0aff2fa | 2015-07-31 06:48:27 -0700 | [diff] [blame] | 70 | |
Chris Dalton | 5ed4423 | 2017-09-07 13:22:46 -0600 | [diff] [blame] | 71 | CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; |
bsalomon | 0aff2fa | 2015-07-31 06:48:27 -0700 | [diff] [blame] | 72 | |
| 73 | bool onDrawPath(const DrawPathArgs&) override; |
| 74 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 75 | static void HandleEviction(GrDrawOpAtlas::AtlasID, void*); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 76 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 77 | std::unique_ptr<GrDrawOpAtlas> fAtlas; |
Ben Wagner | 594f9ed | 2016-11-08 14:13:39 -0500 | [diff] [blame] | 78 | ShapeCache fShapeCache; |
| 79 | ShapeDataList fShapeList; |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 80 | |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 81 | typedef GrPathRenderer INHERITED; |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | #endif |