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