reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2010 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. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 8 | #ifndef GrDrawTarget_DEFINED |
| 9 | #define GrDrawTarget_DEFINED |
| 10 | |
joshualitt | 44701df | 2015-02-23 14:44:57 -0800 | [diff] [blame] | 11 | #include "GrClip.h" |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 12 | #include "GrClipMaskManager.h" |
commit-bot@chromium.org | 2a05de0 | 2014-03-25 15:17:32 +0000 | [diff] [blame] | 13 | #include "GrContext.h" |
joshualitt | 8072caa | 2015-02-12 14:20:52 -0800 | [diff] [blame] | 14 | #include "GrPathProcessor.h" |
| 15 | #include "GrPrimitiveProcessor.h" |
bsalomon@google.com | 934c570 | 2012-03-20 21:17:58 +0000 | [diff] [blame] | 16 | #include "GrIndexBuffer.h" |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 17 | #include "GrPathRendering.h" |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 18 | #include "GrPipelineBuilder.h" |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 19 | #include "GrPipeline.h" |
joshualitt | 7eb8c7b | 2014-11-18 14:24:27 -0800 | [diff] [blame] | 20 | #include "GrVertexBuffer.h" |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 21 | #include "GrXferProcessor.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 22 | |
bsalomon@google.com | 8d67c07 | 2012-12-13 20:38:14 +0000 | [diff] [blame] | 23 | #include "SkClipStack.h" |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 24 | #include "SkMatrix.h" |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 25 | #include "SkPath.h" |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 26 | #include "SkStrokeRec.h" |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 27 | #include "SkTArray.h" |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 28 | #include "SkTLazy.h" |
commit-bot@chromium.org | a0b4028 | 2013-09-18 13:00:55 +0000 | [diff] [blame] | 29 | #include "SkTypes.h" |
bsalomon@google.com | 8d67c07 | 2012-12-13 20:38:14 +0000 | [diff] [blame] | 30 | #include "SkXfermode.h" |
Scroggo | 97c88c2 | 2011-05-11 14:05:25 +0000 | [diff] [blame] | 31 | |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 32 | class GrBatch; |
joshualitt | 44701df | 2015-02-23 14:44:57 -0800 | [diff] [blame] | 33 | class GrClip; |
bsalomon | 4b91f76 | 2015-05-19 09:29:46 -0700 | [diff] [blame] | 34 | class GrCaps; |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 35 | class GrPath; |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 36 | class GrPathRange; |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 37 | class GrDrawBatch; |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 38 | |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 39 | class GrDrawTarget : public SkRefCnt { |
bsalomon@google.com | f660187 | 2012-08-28 21:11:35 +0000 | [diff] [blame] | 40 | public: |
mtklein | 2766c00 | 2015-06-26 11:45:03 -0700 | [diff] [blame] | 41 | |
bsalomon@google.com | f660187 | 2012-08-28 21:11:35 +0000 | [diff] [blame] | 42 | |
cdalton | 55b24af | 2014-11-25 11:00:56 -0800 | [diff] [blame] | 43 | typedef GrPathRange::PathIndexType PathIndexType; |
| 44 | typedef GrPathRendering::PathTransformType PathTransformType; |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 45 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 46 | /////////////////////////////////////////////////////////////////////////// |
| 47 | |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 48 | // The context may not be fully constructed and should not be used during GrDrawTarget |
| 49 | // construction. |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 50 | GrDrawTarget(GrGpu* gpu, GrResourceProvider*); |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 51 | |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 52 | virtual ~GrDrawTarget(); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 53 | |
| 54 | /** |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 55 | * Empties the draw buffer of any queued up draws. |
| 56 | */ |
robertphillips | e40d397 | 2015-05-07 09:51:43 -0700 | [diff] [blame] | 57 | void reset() { this->onReset(); } |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 58 | |
| 59 | /** |
| 60 | * This plays any queued up draws to its GrGpu target. It also resets this object (i.e. flushing |
| 61 | * is destructive). |
| 62 | */ |
| 63 | void flush(); |
| 64 | |
| 65 | /** |
bsalomon@google.com | 18c9c19 | 2011-09-22 21:01:31 +0000 | [diff] [blame] | 66 | * Gets the capabilities of the draw target. |
| 67 | */ |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 68 | const GrCaps* caps() const { return fCaps; } |
bsalomon@google.com | 18c9c19 | 2011-09-22 21:01:31 +0000 | [diff] [blame] | 69 | |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 70 | void drawBatch(const GrPipelineBuilder&, GrDrawBatch*); |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 71 | |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 72 | /** |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 73 | * Draws path into the stencil buffer. The fill must be either even/odd or |
| 74 | * winding (not inverse or hairline). It will respect the HW antialias flag |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 75 | * on the GrPipelineBuilder (if possible in the 3D API). Note, we will never have an inverse |
| 76 | * fill with stencil path |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 77 | */ |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 78 | void stencilPath(const GrPipelineBuilder&, const GrPathProcessor*, const GrPath*, |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 79 | GrPathRendering::FillType); |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 80 | |
| 81 | /** |
commit-bot@chromium.org | 32184d8 | 2013-10-09 15:14:18 +0000 | [diff] [blame] | 82 | * Draws a path. Fill must not be a hairline. It will respect the HW |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 83 | * antialias flag on the GrPipelineBuilder (if possible in the 3D API). |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 84 | */ |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 85 | void drawPath(const GrPipelineBuilder&, const GrPathProcessor*, const GrPath*, |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 86 | GrPathRendering::FillType); |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 87 | |
| 88 | /** |
cdalton | 55b24af | 2014-11-25 11:00:56 -0800 | [diff] [blame] | 89 | * Draws the aggregate path from combining multiple. Note that this will not |
| 90 | * always be equivalent to back-to-back calls to drawPath(). It will respect |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 91 | * the HW antialias flag on the GrPipelineBuilder (if possible in the 3D API). |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 92 | * |
cdalton | 55b24af | 2014-11-25 11:00:56 -0800 | [diff] [blame] | 93 | * @param pathRange Source paths to draw from |
| 94 | * @param indices Array of path indices to draw |
| 95 | * @param indexType Data type of the array elements in indexBuffer |
| 96 | * @param transformValues Array of transforms for the individual paths |
| 97 | * @param transformType Type of transforms in transformBuffer |
| 98 | * @param count Number of paths to draw |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 99 | * @param fill Fill type for drawing all the paths |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 100 | */ |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 101 | void drawPaths(const GrPipelineBuilder&, |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 102 | const GrPathProcessor*, |
joshualitt | 2e3b3e3 | 2014-12-09 13:31:14 -0800 | [diff] [blame] | 103 | const GrPathRange* pathRange, |
cdalton | 55b24af | 2014-11-25 11:00:56 -0800 | [diff] [blame] | 104 | const void* indices, |
| 105 | PathIndexType indexType, |
| 106 | const float transformValues[], |
| 107 | PathTransformType transformType, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 108 | int count, |
joshualitt | 92e496f | 2014-10-31 13:56:50 -0700 | [diff] [blame] | 109 | GrPathRendering::FillType fill); |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 110 | |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 111 | /** |
bsalomon | 72e3ae4 | 2015-04-28 08:08:46 -0700 | [diff] [blame] | 112 | * Helper function for drawing rects. |
skia.committer@gmail.com | 044679e | 2013-02-15 07:16:57 +0000 | [diff] [blame] | 113 | * |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame] | 114 | * @param rect the rect to draw |
bsalomon@google.com | c781888 | 2013-03-20 19:19:53 +0000 | [diff] [blame] | 115 | * @param localRect optional rect that specifies local coords to map onto |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 116 | * rect. If nullptr then rect serves as the local coords. |
joshualitt | 8fc6c2d | 2014-12-22 15:27:05 -0800 | [diff] [blame] | 117 | * @param localMatrix Optional local matrix. The local coordinates are specified by localRect, |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 118 | * or if it is nullptr by rect. This matrix applies to the coordinate implied by |
joshualitt | 8fc6c2d | 2014-12-22 15:27:05 -0800 | [diff] [blame] | 119 | * that rectangle before it is input to GrCoordTransforms that read local |
| 120 | * coordinates |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 121 | */ |
joshualitt | d2b23e0 | 2015-08-21 10:53:34 -0700 | [diff] [blame] | 122 | void drawNonAARect(const GrPipelineBuilder& pipelineBuilder, |
| 123 | GrColor color, |
| 124 | const SkMatrix& viewMatrix, |
| 125 | const SkRect& rect); |
joshualitt | b6b513b | 2015-08-21 10:25:18 -0700 | [diff] [blame] | 126 | |
joshualitt | d2b23e0 | 2015-08-21 10:53:34 -0700 | [diff] [blame] | 127 | void drawNonAARect(const GrPipelineBuilder& pipelineBuilder, |
| 128 | GrColor color, |
| 129 | const SkMatrix& viewMatrix, |
| 130 | const SkRect& rect, |
| 131 | const SkMatrix& localMatrix); |
joshualitt | b6b513b | 2015-08-21 10:25:18 -0700 | [diff] [blame] | 132 | |
joshualitt | d2b23e0 | 2015-08-21 10:53:34 -0700 | [diff] [blame] | 133 | void drawNonAARect(const GrPipelineBuilder& pipelineBuilder, |
| 134 | GrColor color, |
| 135 | const SkMatrix& viewMatrix, |
| 136 | const SkRect& rect, |
| 137 | const SkRect& localRect); |
jvanverth@google.com | 3976825 | 2013-02-14 15:25:44 +0000 | [diff] [blame] | 138 | |
joshualitt | d2b23e0 | 2015-08-21 10:53:34 -0700 | [diff] [blame] | 139 | void drawNonAARect(const GrPipelineBuilder& ds, |
| 140 | GrColor color, |
| 141 | const SkMatrix& viewM, |
| 142 | const SkIRect& irect) { |
reed@google.com | 4469938 | 2013-10-31 17:28:30 +0000 | [diff] [blame] | 143 | SkRect rect = SkRect::Make(irect); |
joshualitt | d2b23e0 | 2015-08-21 10:53:34 -0700 | [diff] [blame] | 144 | this->drawNonAARect(ds, color, viewM, rect); |
bsalomon@google.com | cf939ae | 2012-12-13 19:59:23 +0000 | [diff] [blame] | 145 | } |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 146 | |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 147 | void drawAARect(const GrPipelineBuilder& pipelineBuilder, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 148 | GrColor color, |
| 149 | const SkMatrix& viewMatrix, |
| 150 | const SkRect& rect, |
| 151 | const SkRect& devRect); |
bsalomon@google.com | 934c570 | 2012-03-20 21:17:58 +0000 | [diff] [blame] | 152 | |
| 153 | /** |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 154 | * Clear the passed in render target. Ignores the GrPipelineBuilder and clip. Clears the whole |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 155 | * thing if rect is nullptr, otherwise just the rect. If canIgnoreRect is set then the entire |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 156 | * render target can be optionally cleared. |
bsalomon@google.com | 0b335c1 | 2011-04-25 19:17:44 +0000 | [diff] [blame] | 157 | */ |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 158 | void clear(const SkIRect* rect, |
| 159 | GrColor color, |
| 160 | bool canIgnoreRect, |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 161 | GrRenderTarget* renderTarget); |
skia.committer@gmail.com | a9493a3 | 2013-04-04 07:01:12 +0000 | [diff] [blame] | 162 | |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 163 | /** Discards the contents render target. */ |
| 164 | void discard(GrRenderTarget*); |
commit-bot@chromium.org | 28361fa | 2014-03-28 16:08:05 +0000 | [diff] [blame] | 165 | |
| 166 | /** |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 167 | * Copies a pixel rectangle from one surface to another. This call may finalize |
| 168 | * reserved vertex/index data (as though a draw call was made). The src pixels |
| 169 | * copied are specified by srcRect. They are copied to a rect of the same |
| 170 | * size in dst with top left at dstPoint. If the src rect is clipped by the |
| 171 | * src bounds then pixel values in the dst rect corresponding to area clipped |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 172 | * by the src rect are not overwritten. This method is not guaranteed to succeed |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 173 | * depending on the type of surface, configs, etc, and the backend-specific |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 174 | * limitations. |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 175 | */ |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 176 | void copySurface(GrSurface* dst, |
bsalomon | f90a02b | 2014-11-26 12:28:00 -0800 | [diff] [blame] | 177 | GrSurface* src, |
| 178 | const SkIRect& srcRect, |
| 179 | const SkIPoint& dstPoint); |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 180 | /** |
robertphillips@google.com | ff17584 | 2012-05-14 19:31:39 +0000 | [diff] [blame] | 181 | * Release any resources that are cached but not currently in use. This |
| 182 | * is intended to give an application some recourse when resources are low. |
| 183 | */ |
| 184 | virtual void purgeResources() {}; |
| 185 | |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 186 | bool programUnitTest(GrContext* owner, int maxStages); |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 187 | |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 188 | struct PipelineInfo { |
| 189 | PipelineInfo(const GrPipelineBuilder* pipelineBuilder, const GrScissorState* scissor, |
| 190 | const GrPrimitiveProcessor* primProc, |
| 191 | const SkRect* devBounds, GrDrawTarget* target); |
| 192 | |
| 193 | PipelineInfo(const GrPipelineBuilder* pipelineBuilder, const GrScissorState* scissor, |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 194 | const GrDrawBatch* batch, const SkRect* devBounds, |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 195 | GrDrawTarget* target); |
| 196 | |
| 197 | bool valid() const { return SkToBool(fArgs.fPipelineBuilder); } |
| 198 | |
| 199 | const GrPipeline::CreateArgs& pipelineCreateArgs() const { |
| 200 | SkASSERT(this->valid()); |
| 201 | return fArgs; |
| 202 | } |
| 203 | |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 204 | private: |
| 205 | GrPipeline::CreateArgs fArgs; |
| 206 | }; |
| 207 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 208 | protected: |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 209 | GrGpu* getGpu() { return fGpu; } |
| 210 | const GrGpu* getGpu() const { return fGpu; } |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 211 | |
joshualitt | 6517134 | 2014-10-09 07:25:36 -0700 | [diff] [blame] | 212 | // Makes a copy of the dst if it is necessary for the draw. Returns false if a copy is required |
| 213 | // but couldn't be made. Otherwise, returns true. This method needs to be protected because it |
| 214 | // needs to be accessed by GLPrograms to setup a correct drawstate |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 215 | bool setupDstReadIfNecessary(const GrPipelineBuilder&, |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 216 | const GrProcOptInfo& colorPOI, |
| 217 | const GrProcOptInfo& coveragePOI, |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 218 | GrXferProcessor::DstTexture*, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 219 | const SkRect* drawBounds); |
joshualitt | 6517134 | 2014-10-09 07:25:36 -0700 | [diff] [blame] | 220 | |
bsalomon | 5ea0363 | 2015-08-18 10:33:30 -0700 | [diff] [blame] | 221 | virtual void onDrawBatch(GrBatch*) = 0; |
| 222 | |
bsalomon@google.com | 02ddc8b | 2013-01-28 15:35:28 +0000 | [diff] [blame] | 223 | private: |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 224 | virtual void onReset() = 0; |
bsalomon | f90a02b | 2014-11-26 12:28:00 -0800 | [diff] [blame] | 225 | |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 226 | virtual void onFlush() = 0; |
bsalomon | f90a02b | 2014-11-26 12:28:00 -0800 | [diff] [blame] | 227 | |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 228 | virtual void onDrawPaths(const GrPathProcessor*, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 229 | const GrPathRange*, |
cdalton | 55b24af | 2014-11-25 11:00:56 -0800 | [diff] [blame] | 230 | const void* indices, |
| 231 | PathIndexType, |
| 232 | const float transformValues[], |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 233 | PathTransformType, |
cdalton | 55b24af | 2014-11-25 11:00:56 -0800 | [diff] [blame] | 234 | int count, |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 235 | const GrStencilSettings&, |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 236 | const PipelineInfo&) = 0; |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 237 | |
commit-bot@chromium.org | a8916ff | 2013-08-16 15:53:46 +0000 | [diff] [blame] | 238 | // Check to see if this set of draw commands has been sent out |
| 239 | virtual bool isIssued(uint32_t drawID) { return true; } |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 240 | void getPathStencilSettingsForFilltype(GrPathRendering::FillType, |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 241 | const GrStencilAttachment*, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 242 | GrStencilSettings*); |
joshualitt | a702415 | 2014-11-03 14:16:35 -0800 | [diff] [blame] | 243 | virtual GrClipMaskManager* clipMaskManager() = 0; |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 244 | virtual bool setupClip(const GrPipelineBuilder&, |
joshualitt | 4421a4c | 2015-07-13 09:36:41 -0700 | [diff] [blame] | 245 | GrPipelineBuilder::AutoRestoreFragmentProcessorState*, |
bsalomon | 6be6f7c | 2015-02-26 13:05:21 -0800 | [diff] [blame] | 246 | GrPipelineBuilder::AutoRestoreStencil*, |
| 247 | GrScissorState*, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 248 | const SkRect* devBounds) = 0; |
skia.committer@gmail.com | 7475811 | 2013-08-17 07:01:54 +0000 | [diff] [blame] | 249 | |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 250 | GrGpu* fGpu; |
| 251 | const GrCaps* fCaps; |
| 252 | GrResourceProvider* fResourceProvider; |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 253 | bool fFlushing; |
reed@google.com | fa35e3d | 2012-06-26 20:16:17 +0000 | [diff] [blame] | 254 | |
commit-bot@chromium.org | a4de8c2 | 2013-09-09 13:38:37 +0000 | [diff] [blame] | 255 | typedef SkRefCnt INHERITED; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 256 | }; |
| 257 | |
joshualitt | 329bf48 | 2014-10-29 12:31:28 -0700 | [diff] [blame] | 258 | /* |
| 259 | * This class is JUST for clip mask manager. Everyone else should just use draw target above. |
| 260 | */ |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 261 | class GrClipTarget : public GrDrawTarget { |
| 262 | public: |
bsalomon | edd77a1 | 2015-05-29 09:45:57 -0700 | [diff] [blame] | 263 | GrClipTarget(GrContext*); |
joshualitt | 329bf48 | 2014-10-29 12:31:28 -0700 | [diff] [blame] | 264 | |
| 265 | /* Clip mask manager needs access to the context. |
| 266 | * TODO we only need a very small subset of context in the CMM. |
| 267 | */ |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 268 | GrContext* getContext() { return fContext; } |
| 269 | const GrContext* getContext() const { return fContext; } |
joshualitt | 329bf48 | 2014-10-29 12:31:28 -0700 | [diff] [blame] | 270 | |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 271 | /** |
| 272 | * Clip Mask Manager(and no one else) needs to clear private stencil bits. |
| 273 | * ClipTarget subclass sets clip bit in the stencil buffer. The subclass |
| 274 | * is free to clear the remaining bits to zero if masked clears are more |
| 275 | * expensive than clearing all bits. |
| 276 | */ |
bsalomon | 5ea0363 | 2015-08-18 10:33:30 -0700 | [diff] [blame] | 277 | void clearStencilClip(const SkIRect&, bool insideClip, GrRenderTarget*); |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 278 | |
joshualitt | 3bdd7dc | 2014-10-31 08:27:39 -0700 | [diff] [blame] | 279 | /** |
| 280 | * Release any resources that are cached but not currently in use. This |
| 281 | * is intended to give an application some recourse when resources are low. |
| 282 | */ |
bsalomon | edd77a1 | 2015-05-29 09:45:57 -0700 | [diff] [blame] | 283 | void purgeResources() override; |
joshualitt | 3bdd7dc | 2014-10-31 08:27:39 -0700 | [diff] [blame] | 284 | |
joshualitt | 329bf48 | 2014-10-29 12:31:28 -0700 | [diff] [blame] | 285 | protected: |
bsalomon | edd77a1 | 2015-05-29 09:45:57 -0700 | [diff] [blame] | 286 | SkAutoTDelete<GrClipMaskManager> fClipMaskManager; |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 287 | GrContext* fContext; |
joshualitt | 329bf48 | 2014-10-29 12:31:28 -0700 | [diff] [blame] | 288 | |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 289 | private: |
bsalomon | edd77a1 | 2015-05-29 09:45:57 -0700 | [diff] [blame] | 290 | GrClipMaskManager* clipMaskManager() override { return fClipMaskManager; } |
joshualitt | 329bf48 | 2014-10-29 12:31:28 -0700 | [diff] [blame] | 291 | |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 292 | bool setupClip(const GrPipelineBuilder&, |
joshualitt | 4421a4c | 2015-07-13 09:36:41 -0700 | [diff] [blame] | 293 | GrPipelineBuilder::AutoRestoreFragmentProcessorState*, |
joshualitt | 5e6ba21 | 2015-07-13 07:35:05 -0700 | [diff] [blame] | 294 | GrPipelineBuilder::AutoRestoreStencil*, |
joshualitt | 5e6ba21 | 2015-07-13 07:35:05 -0700 | [diff] [blame] | 295 | GrScissorState* scissorState, |
| 296 | const SkRect* devBounds) override; |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 297 | |
joshualitt | 6db519c | 2014-10-29 08:48:18 -0700 | [diff] [blame] | 298 | typedef GrDrawTarget INHERITED; |
| 299 | }; |
| 300 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 301 | #endif |