blob: a916fc1d8964a22d987091c4092e0abb8c99c0f9 [file] [log] [blame]
jvanverthfa38a302014-10-06 05:59:05 -07001/*
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 Verth83010462017-03-16 08:45:39 -04008#ifndef GrSmallPathRenderer_DEFINED
9#define GrSmallPathRenderer_DEFINED
jvanverthfa38a302014-10-06 05:59:05 -070010
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "src/gpu/GrDrawOpAtlas.h"
12#include "src/gpu/GrOnFlushResourceProvider.h"
13#include "src/gpu/GrPathRenderer.h"
Michael Ludwig663afe52019-06-03 16:46:19 -040014#include "src/gpu/geometry/GrRect.h"
15#include "src/gpu/geometry/GrShape.h"
jvanverthfa38a302014-10-06 05:59:05 -070016
Mike Kleinc0bd9f92019-04-23 12:05:21 -050017#include "src/core/SkOpts.h"
18#include "src/core/SkTDynamicHash.h"
jvanverthfa38a302014-10-06 05:59:05 -070019
Robert Phillipsb97da532019-02-12 15:24:12 -050020class GrRecordingContext;
jvanverthfa38a302014-10-06 05:59:05 -070021
Robert Phillipsd2e9f762018-03-07 11:54:37 -050022class ShapeData;
23class ShapeDataKey;
24
Jim Van Verth106b5c42017-09-26 12:45:29 -040025class GrSmallPathRenderer : public GrPathRenderer, public GrOnFlushCallbackObject {
jvanverthfa38a302014-10-06 05:59:05 -070026public:
Jim Van Verth83010462017-03-16 08:45:39 -040027 GrSmallPathRenderer();
Brian Salomond3b65972017-03-22 12:05:03 -040028 ~GrSmallPathRenderer() override;
jvanverthfa38a302014-10-06 05:59:05 -070029
Jim Van Verth106b5c42017-09-26 12:45:29 -040030 // 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 Daltonc4b47352019-08-23 10:10:36 -060036 void preFlush(GrOnFlushResourceProvider* onFlushRP, const uint32_t*, int) override {
Robert Phillipscd5099c2018-02-09 09:56:56 -050037 if (fAtlas) {
Chris Daltonc4b47352019-08-23 10:10:36 -060038 fAtlas->instantiate(onFlushRP);
Robert Phillipscd5099c2018-02-09 09:56:56 -050039 }
40 }
Jim Van Verth106b5c42017-09-26 12:45:29 -040041
Chris Dalton3968ff92017-11-27 12:26:31 -070042 void postFlush(GrDeferredUploadToken startTokenForNextFlush,
Greg Danielf41b2bd2019-08-22 16:19:24 -040043 const uint32_t* /*opsTaskIDs*/, int /*numOpsTaskIDs*/) override {
Jim Van Verth106b5c42017-09-26 12:45:29 -040044 if (fAtlas) {
45 fAtlas->compact(startTokenForNextFlush);
46 }
47 }
48
Robert Phillipsd2e9f762018-03-07 11:54:37 -050049 using ShapeCache = SkTDynamicHash<ShapeData, ShapeDataKey>;
50 typedef SkTInternalLList<ShapeData> ShapeDataList;
51
Robert Phillipsb97da532019-02-12 15:24:12 -050052 static std::unique_ptr<GrDrawOp> createOp_TestingOnly(GrRecordingContext*,
Robert Phillips7c525e62018-06-12 10:11:12 -040053 GrPaint&&,
54 const GrShape&,
Robert Phillipsd2e9f762018-03-07 11:54:37 -050055 const SkMatrix& viewMatrix,
56 GrDrawOpAtlas* atlas,
Robert Phillips7c525e62018-06-12 10:11:12 -040057 ShapeCache*,
58 ShapeDataList*,
Robert Phillipsd2e9f762018-03-07 11:54:37 -050059 bool gammaCorrect,
60 const GrUserStencilSettings*);
61 struct PathTestStruct;
62
jvanverthfa38a302014-10-06 05:59:05 -070063private:
Robert Phillipsd2e9f762018-03-07 11:54:37 -050064 class SmallPathOp;
65
bsalomon8acedde2016-06-24 10:42:16 -070066 StencilSupport onGetStencilSupport(const GrShape&) const override {
robertphillipse7d4b2f2015-08-13 07:57:10 -070067 return GrPathRenderer::kNoSupport_StencilSupport;
68 }
bsalomon0aff2fa2015-07-31 06:48:27 -070069
Chris Dalton5ed44232017-09-07 13:22:46 -060070 CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
bsalomon0aff2fa2015-07-31 06:48:27 -070071
72 bool onDrawPath(const DrawPathArgs&) override;
73
Brian Salomon2ee084e2016-12-16 18:59:19 -050074 static void HandleEviction(GrDrawOpAtlas::AtlasID, void*);
joshualitt5bf99f12015-03-13 11:47:42 -070075
Brian Salomon2ee084e2016-12-16 18:59:19 -050076 std::unique_ptr<GrDrawOpAtlas> fAtlas;
Ben Wagner594f9ed2016-11-08 14:13:39 -050077 ShapeCache fShapeCache;
78 ShapeDataList fShapeList;
halcanary9d524f22016-03-29 09:03:52 -070079
jvanverthfa38a302014-10-06 05:59:05 -070080 typedef GrPathRenderer INHERITED;
jvanverthfa38a302014-10-06 05:59:05 -070081};
82
83#endif