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