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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "src/gpu/GrDrawOpAtlas.h" |
| 12 | #include "src/gpu/GrOnFlushResourceProvider.h" |
| 13 | #include "src/gpu/GrPathRenderer.h" |
Michael Ludwig | 663afe5 | 2019-06-03 16:46:19 -0400 | [diff] [blame] | 14 | #include "src/gpu/geometry/GrRect.h" |
| 15 | #include "src/gpu/geometry/GrShape.h" |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 16 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 17 | #include "src/core/SkOpts.h" |
| 18 | #include "src/core/SkTDynamicHash.h" |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 19 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 20 | class GrRecordingContext; |
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 | |
Chris Dalton | c4b4735 | 2019-08-23 10:10:36 -0600 | [diff] [blame] | 36 | void preFlush(GrOnFlushResourceProvider* onFlushRP, const uint32_t*, int) override { |
Robert Phillips | cd5099c | 2018-02-09 09:56:56 -0500 | [diff] [blame] | 37 | if (fAtlas) { |
Chris Dalton | c4b4735 | 2019-08-23 10:10:36 -0600 | [diff] [blame] | 38 | fAtlas->instantiate(onFlushRP); |
Robert Phillips | cd5099c | 2018-02-09 09:56:56 -0500 | [diff] [blame] | 39 | } |
| 40 | } |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 41 | |
Chris Dalton | 3968ff9 | 2017-11-27 12:26:31 -0700 | [diff] [blame] | 42 | void postFlush(GrDeferredUploadToken startTokenForNextFlush, |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 43 | const uint32_t* /*opsTaskIDs*/, int /*numOpsTaskIDs*/) override { |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 44 | if (fAtlas) { |
| 45 | fAtlas->compact(startTokenForNextFlush); |
| 46 | } |
| 47 | } |
| 48 | |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 49 | using ShapeCache = SkTDynamicHash<ShapeData, ShapeDataKey>; |
| 50 | typedef SkTInternalLList<ShapeData> ShapeDataList; |
| 51 | |
Robert Phillips | b97da53 | 2019-02-12 15:24:12 -0500 | [diff] [blame] | 52 | static std::unique_ptr<GrDrawOp> createOp_TestingOnly(GrRecordingContext*, |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 53 | GrPaint&&, |
| 54 | const GrShape&, |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 55 | const SkMatrix& viewMatrix, |
| 56 | GrDrawOpAtlas* atlas, |
Robert Phillips | 7c525e6 | 2018-06-12 10:11:12 -0400 | [diff] [blame] | 57 | ShapeCache*, |
| 58 | ShapeDataList*, |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 59 | bool gammaCorrect, |
| 60 | const GrUserStencilSettings*); |
| 61 | struct PathTestStruct; |
| 62 | |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 63 | private: |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 64 | class SmallPathOp; |
| 65 | |
bsalomon | 8acedde | 2016-06-24 10:42:16 -0700 | [diff] [blame] | 66 | StencilSupport onGetStencilSupport(const GrShape&) const override { |
robertphillips | e7d4b2f | 2015-08-13 07:57:10 -0700 | [diff] [blame] | 67 | return GrPathRenderer::kNoSupport_StencilSupport; |
| 68 | } |
bsalomon | 0aff2fa | 2015-07-31 06:48:27 -0700 | [diff] [blame] | 69 | |
Chris Dalton | 5ed4423 | 2017-09-07 13:22:46 -0600 | [diff] [blame] | 70 | CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; |
bsalomon | 0aff2fa | 2015-07-31 06:48:27 -0700 | [diff] [blame] | 71 | |
| 72 | bool onDrawPath(const DrawPathArgs&) override; |
| 73 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 74 | static void HandleEviction(GrDrawOpAtlas::AtlasID, void*); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 75 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 76 | std::unique_ptr<GrDrawOpAtlas> fAtlas; |
Ben Wagner | 594f9ed | 2016-11-08 14:13:39 -0500 | [diff] [blame] | 77 | ShapeCache fShapeCache; |
| 78 | ShapeDataList fShapeList; |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 79 | |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 80 | typedef GrPathRenderer INHERITED; |
jvanverth | fa38a30 | 2014-10-06 05:59:05 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | #endif |