robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | |
| 8 | #ifndef GrDrawContext_DEFINED |
| 9 | #define GrDrawContext_DEFINED |
| 10 | |
| 11 | #include "GrColor.h" |
csmartdalton | ecbc12b | 2016-06-08 10:08:43 -0700 | [diff] [blame] | 12 | #include "GrPaint.h" |
robertphillips | 7bceedc | 2015-12-01 12:51:26 -0800 | [diff] [blame] | 13 | #include "GrRenderTarget.h" |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 14 | #include "SkRefCnt.h" |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 15 | #include "SkRegion.h" |
robertphillips | fcf7829 | 2015-06-19 11:49:52 -0700 | [diff] [blame] | 16 | #include "SkSurfaceProps.h" |
csmartdalton | a7f2964 | 2016-07-07 08:49:11 -0700 | [diff] [blame] | 17 | #include "../private/GrInstancedPipelineInfo.h" |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 18 | #include "../private/GrSingleOwner.h" |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 19 | |
joshualitt | 8e84a1e | 2016-02-16 11:09:25 -0800 | [diff] [blame] | 20 | class GrAtlasTextContext; |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 21 | class GrAuditTrail; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 22 | class GrClip; |
| 23 | class GrContext; |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 24 | class GrDrawBatch; |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 25 | class GrDrawContextPriv; |
cdalton | 8ff8d24 | 2015-12-08 10:20:32 -0800 | [diff] [blame] | 26 | class GrDrawPathBatchBase; |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 27 | class GrDrawingManager; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 28 | class GrDrawTarget; |
| 29 | class GrPaint; |
| 30 | class GrPathProcessor; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 31 | class GrPipelineBuilder; |
| 32 | class GrRenderTarget; |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 33 | class GrStyle; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 34 | class GrSurface; |
robertphillips | 4430239 | 2016-07-08 14:43:03 -0700 | [diff] [blame] | 35 | struct GrUserStencilSettings; |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 36 | class SkDrawFilter; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 37 | struct SkIPoint; |
| 38 | struct SkIRect; |
| 39 | class SkMatrix; |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 40 | class SkPaint; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 41 | class SkPath; |
| 42 | struct SkPoint; |
| 43 | struct SkRect; |
| 44 | class SkRRect; |
jvanverth | 31ff762 | 2015-08-07 10:09:28 -0700 | [diff] [blame] | 45 | struct SkRSXform; |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 46 | class SkTextBlob; |
robertphillips | 2895eeb | 2016-07-21 12:04:08 -0700 | [diff] [blame^] | 47 | struct GrUserStencilSettings; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | * A helper object to orchestrate draws |
| 51 | */ |
| 52 | class SK_API GrDrawContext : public SkRefCnt { |
| 53 | public: |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 54 | ~GrDrawContext() override; |
| 55 | |
bsalomon | b8fea97 | 2016-02-16 07:34:17 -0800 | [diff] [blame] | 56 | bool copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 57 | |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 58 | // TODO: it is odd that we need both the SkPaint in the following 3 methods. |
| 59 | // We should extract the text parameters from SkPaint and pass them separately |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 60 | // akin to GrStyle (GrTextInfo?) |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 61 | virtual void drawText(const GrClip&, const GrPaint&, const SkPaint&, |
| 62 | const SkMatrix& viewMatrix, const char text[], size_t byteLength, |
| 63 | SkScalar x, SkScalar y, const SkIRect& clipBounds); |
| 64 | virtual void drawPosText(const GrClip&, const GrPaint&, const SkPaint&, |
| 65 | const SkMatrix& viewMatrix, const char text[], size_t byteLength, |
| 66 | const SkScalar pos[], int scalarsPerPosition, |
| 67 | const SkPoint& offset, const SkIRect& clipBounds); |
| 68 | virtual void drawTextBlob(const GrClip&, const SkPaint&, |
| 69 | const SkMatrix& viewMatrix, const SkTextBlob*, |
| 70 | SkScalar x, SkScalar y, |
| 71 | SkDrawFilter*, const SkIRect& clipBounds); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 72 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 73 | /** |
| 74 | * Provides a perfomance hint that the render target's contents are allowed |
| 75 | * to become undefined. |
| 76 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 77 | void discard(); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 78 | |
| 79 | /** |
| 80 | * Clear the entire or rect of the render target, ignoring any clips. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 81 | * @param rect the rect to clear or the whole thing if rect is NULL. |
| 82 | * @param color the color to clear to. |
| 83 | * @param canIgnoreRect allows partial clears to be converted to whole |
| 84 | * clears on platforms for which that is cheap |
| 85 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 86 | void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 87 | |
| 88 | /** |
| 89 | * Draw everywhere (respecting the clip) with the paint. |
| 90 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 91 | void drawPaint(const GrClip&, const GrPaint&, const SkMatrix& viewMatrix); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 92 | |
| 93 | /** |
| 94 | * Draw the rect using a paint. |
| 95 | * @param paint describes how to color pixels. |
| 96 | * @param viewMatrix transformation matrix |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 97 | * @param style The style to apply. Null means fill. Currently path effects are not |
| 98 | * allowed. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 99 | * The rects coords are used to access the paint (through texture matrix) |
| 100 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 101 | void drawRect(const GrClip&, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 102 | const GrPaint& paint, |
| 103 | const SkMatrix& viewMatrix, |
| 104 | const SkRect&, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 105 | const GrStyle* style = nullptr); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 106 | |
| 107 | /** |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 108 | * Maps a rectangle of shader coordinates to a rectangle and fills that rectangle. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 109 | * |
| 110 | * @param paint describes how to color pixels. |
| 111 | * @param viewMatrix transformation matrix which applies to rectToDraw |
| 112 | * @param rectToDraw the rectangle to draw |
| 113 | * @param localRect the rectangle of shader coordinates applied to rectToDraw |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 114 | */ |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 115 | void fillRectToRect(const GrClip&, |
| 116 | const GrPaint& paint, |
| 117 | const SkMatrix& viewMatrix, |
| 118 | const SkRect& rectToDraw, |
| 119 | const SkRect& localRect); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 120 | |
| 121 | /** |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 122 | * Fills a rect with a paint and a localMatrix. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 123 | */ |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 124 | void fillRectWithLocalMatrix(const GrClip& clip, |
| 125 | const GrPaint& paint, |
| 126 | const SkMatrix& viewMatrix, |
| 127 | const SkRect& rect, |
| 128 | const SkMatrix& localMatrix); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 129 | |
| 130 | /** |
| 131 | * Draw a roundrect using a paint. |
| 132 | * |
| 133 | * @param paint describes how to color pixels. |
| 134 | * @param viewMatrix transformation matrix |
| 135 | * @param rrect the roundrect to draw |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 136 | * @param style style to apply to the rrect. Currently path effects are not allowed. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 137 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 138 | void drawRRect(const GrClip&, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 139 | const GrPaint&, |
| 140 | const SkMatrix& viewMatrix, |
| 141 | const SkRRect& rrect, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 142 | const GrStyle& style); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 143 | |
| 144 | /** |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 145 | * Shortcut for drawing an SkPath consisting of nested rrects using a paint. |
| 146 | * Does not support stroking. The result is undefined if outer does not contain |
| 147 | * inner. |
| 148 | * |
| 149 | * @param paint describes how to color pixels. |
| 150 | * @param viewMatrix transformation matrix |
| 151 | * @param outer the outer roundrect |
| 152 | * @param inner the inner roundrect |
| 153 | */ |
| 154 | void drawDRRect(const GrClip&, |
| 155 | const GrPaint&, |
| 156 | const SkMatrix& viewMatrix, |
| 157 | const SkRRect& outer, |
| 158 | const SkRRect& inner); |
| 159 | |
| 160 | /** |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 161 | * Draws a path. |
| 162 | * |
| 163 | * @param paint describes how to color pixels. |
| 164 | * @param viewMatrix transformation matrix |
| 165 | * @param path the path to draw |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 166 | * @param style style to apply to the path. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 167 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 168 | void drawPath(const GrClip&, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 169 | const GrPaint&, |
| 170 | const SkMatrix& viewMatrix, |
| 171 | const SkPath&, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 172 | const GrStyle& style); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 173 | |
| 174 | /** |
| 175 | * Draws vertices with a paint. |
| 176 | * |
| 177 | * @param paint describes how to color pixels. |
| 178 | * @param viewMatrix transformation matrix |
| 179 | * @param primitiveType primitives type to draw. |
| 180 | * @param vertexCount number of vertices. |
| 181 | * @param positions array of vertex positions, required. |
| 182 | * @param texCoords optional array of texture coordinates used |
| 183 | * to access the paint. |
| 184 | * @param colors optional array of per-vertex colors, supercedes |
| 185 | * the paint's color field. |
| 186 | * @param indices optional array of indices. If NULL vertices |
| 187 | * are drawn non-indexed. |
| 188 | * @param indexCount if indices is non-null then this is the |
| 189 | * number of indices. |
| 190 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 191 | void drawVertices(const GrClip&, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 192 | const GrPaint& paint, |
| 193 | const SkMatrix& viewMatrix, |
| 194 | GrPrimitiveType primitiveType, |
| 195 | int vertexCount, |
| 196 | const SkPoint positions[], |
| 197 | const SkPoint texs[], |
| 198 | const GrColor colors[], |
| 199 | const uint16_t indices[], |
| 200 | int indexCount); |
| 201 | |
| 202 | /** |
jvanverth | 31ff762 | 2015-08-07 10:09:28 -0700 | [diff] [blame] | 203 | * Draws textured sprites from an atlas with a paint. |
| 204 | * |
| 205 | * @param paint describes how to color pixels. |
| 206 | * @param viewMatrix transformation matrix |
| 207 | * @param spriteCount number of sprites. |
| 208 | * @param xform array of compressed transformation data, required. |
| 209 | * @param texRect array of texture rectangles used to access the paint. |
| 210 | * @param colors optional array of per-sprite colors, supercedes |
| 211 | * the paint's color field. |
| 212 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 213 | void drawAtlas(const GrClip&, |
jvanverth | 31ff762 | 2015-08-07 10:09:28 -0700 | [diff] [blame] | 214 | const GrPaint& paint, |
| 215 | const SkMatrix& viewMatrix, |
| 216 | int spriteCount, |
| 217 | const SkRSXform xform[], |
| 218 | const SkRect texRect[], |
| 219 | const SkColor colors[]); |
| 220 | |
| 221 | /** |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 222 | * Draws an oval. |
| 223 | * |
| 224 | * @param paint describes how to color pixels. |
| 225 | * @param viewMatrix transformation matrix |
| 226 | * @param oval the bounding rect of the oval. |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 227 | * @param style style to apply to the oval. Currently path effects are not allowed. |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 228 | */ |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 229 | void drawOval(const GrClip&, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 230 | const GrPaint& paint, |
| 231 | const SkMatrix& viewMatrix, |
| 232 | const SkRect& oval, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 233 | const GrStyle& style); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 234 | |
joshualitt | 33a5fce | 2015-11-18 13:28:51 -0800 | [diff] [blame] | 235 | /** |
| 236 | * Draw the image stretched differentially to fit into dst. |
| 237 | * center is a rect within the image, and logically divides the image |
| 238 | * into 9 sections (3x3). For example, if the middle pixel of a [5x5] |
| 239 | * image is the "center", then the center-rect should be [2, 2, 3, 3]. |
| 240 | * |
| 241 | * If the dst is >= the image size, then... |
| 242 | * - The 4 corners are not stretched at all. |
| 243 | * - The sides are stretched in only one axis. |
| 244 | * - The center is stretched in both axes. |
| 245 | * Else, for each axis where dst < image, |
| 246 | * - The corners shrink proportionally |
| 247 | * - The sides (along the shrink axis) and center are not drawn |
| 248 | */ |
| 249 | void drawImageNine(const GrClip&, |
| 250 | const GrPaint& paint, |
| 251 | const SkMatrix& viewMatrix, |
| 252 | int imageWidth, |
| 253 | int imageHeight, |
| 254 | const SkIRect& center, |
| 255 | const SkRect& dst); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 256 | |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 257 | bool isStencilBufferMultisampled() const { |
| 258 | return fRenderTarget->isStencilBufferMultisampled(); |
| 259 | } |
robertphillips | 55fdccc | 2016-06-06 06:16:20 -0700 | [diff] [blame] | 260 | bool isUnifiedMultisampled() const { return fRenderTarget->isUnifiedMultisampled(); } |
robertphillips | 82ec6e5 | 2016-05-19 14:01:05 -0700 | [diff] [blame] | 261 | bool hasMixedSamples() const { return fRenderTarget->hasMixedSamples(); } |
| 262 | |
csmartdalton | ecbc12b | 2016-06-08 10:08:43 -0700 | [diff] [blame] | 263 | bool mustUseHWAA(const GrPaint& paint) const { |
robertphillips | 2895eeb | 2016-07-21 12:04:08 -0700 | [diff] [blame^] | 264 | return paint.isAntiAlias() && |
| 265 | (fRenderTarget->isUnifiedMultisampled() || fRenderTarget->hasMixedSamples()); |
csmartdalton | ecbc12b | 2016-06-08 10:08:43 -0700 | [diff] [blame] | 266 | } |
| 267 | |
robertphillips | e576874 | 2016-05-13 11:20:46 -0700 | [diff] [blame] | 268 | const GrSurfaceDesc& desc() const { return fRenderTarget->desc(); } |
robertphillips | 7bceedc | 2015-12-01 12:51:26 -0800 | [diff] [blame] | 269 | int width() const { return fRenderTarget->width(); } |
| 270 | int height() const { return fRenderTarget->height(); } |
robertphillips | ca6eafc | 2016-05-17 09:57:46 -0700 | [diff] [blame] | 271 | GrPixelConfig config() const { return fRenderTarget->config(); } |
robertphillips | 7bceedc | 2015-12-01 12:51:26 -0800 | [diff] [blame] | 272 | int numColorSamples() const { return fRenderTarget->numColorSamples(); } |
brianosman | b461d34 | 2016-04-13 13:10:14 -0700 | [diff] [blame] | 273 | bool isGammaCorrect() const { return fSurfaceProps.isGammaCorrect(); } |
robertphillips | ca6eafc | 2016-05-17 09:57:46 -0700 | [diff] [blame] | 274 | const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } |
robertphillips | 7bceedc | 2015-12-01 12:51:26 -0800 | [diff] [blame] | 275 | |
robertphillips | 7761d61 | 2016-05-16 09:14:53 -0700 | [diff] [blame] | 276 | bool wasAbandoned() const; |
| 277 | |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 278 | GrRenderTarget* accessRenderTarget() { return fRenderTarget.get(); } |
| 279 | |
| 280 | sk_sp<GrRenderTarget> renderTarget() { return fRenderTarget; } |
| 281 | |
| 282 | sk_sp<GrTexture> asTexture() { return sk_ref_sp(fRenderTarget->asTexture()); } |
robertphillips | 433625e | 2015-12-04 06:58:16 -0800 | [diff] [blame] | 283 | |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 284 | // Provides access to functions that aren't part of the public API. |
| 285 | GrDrawContextPriv drawContextPriv(); |
| 286 | const GrDrawContextPriv drawContextPriv() const; |
joshualitt | f5883a6 | 2016-01-13 07:47:38 -0800 | [diff] [blame] | 287 | |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 288 | GrAuditTrail* auditTrail() { return fAuditTrail; } |
| 289 | |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 290 | protected: |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 291 | GrDrawContext(GrContext*, GrDrawingManager*, sk_sp<GrRenderTarget>, |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 292 | const SkSurfaceProps* surfaceProps, GrAuditTrail*, GrSingleOwner*); |
| 293 | |
| 294 | GrDrawingManager* drawingManager() { return fDrawingManager; } |
robertphillips | ca6eafc | 2016-05-17 09:57:46 -0700 | [diff] [blame] | 295 | |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 296 | SkDEBUGCODE(GrSingleOwner* singleOwner() { return fSingleOwner; }) |
| 297 | SkDEBUGCODE(void validate() const;) |
| 298 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 299 | private: |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 300 | friend class GrAtlasTextBlob; // for access to drawBatch |
cdalton | 193d9cf | 2016-05-12 11:52:02 -0700 | [diff] [blame] | 301 | friend class GrStencilAndCoverTextContext; // for access to drawBatch |
robertphillips | 55fdccc | 2016-06-06 06:16:20 -0700 | [diff] [blame] | 302 | |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 303 | friend class GrDrawingManager; // for ctor |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 304 | friend class GrDrawContextPriv; |
robertphillips | 87f15c8 | 2016-05-20 11:14:33 -0700 | [diff] [blame] | 305 | friend class GrTestTarget; // for access to getDrawTarget |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 306 | friend class GrSWMaskHelper; // for access to drawBatch |
| 307 | friend class GrClipMaskManager; // for access to drawBatch |
| 308 | |
| 309 | // All the path renderers currently make their own batches |
| 310 | friend class GrSoftwarePathRenderer; // for access to drawBatch |
| 311 | friend class GrAAConvexPathRenderer; // for access to drawBatch |
| 312 | friend class GrDashLinePathRenderer; // for access to drawBatch |
| 313 | friend class GrAAHairLinePathRenderer; // for access to drawBatch |
| 314 | friend class GrAALinearizingConvexPathRenderer; // for access to drawBatch |
| 315 | friend class GrAADistanceFieldPathRenderer; // for access to drawBatch |
| 316 | friend class GrDefaultPathRenderer; // for access to drawBatch |
| 317 | friend class GrPLSPathRenderer; // for access to drawBatch |
| 318 | friend class GrMSAAPathRenderer; // for access to drawBatch |
| 319 | friend class GrStencilAndCoverPathRenderer; // for access to drawBatch |
| 320 | friend class GrTessellatingPathRenderer; // for access to drawBatch |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 321 | |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 322 | bool drawFilledDRRect(const GrClip& clip, |
| 323 | const GrPaint& paint, |
| 324 | const SkMatrix& viewMatrix, |
| 325 | const SkRRect& origOuter, |
| 326 | const SkRRect& origInner); |
| 327 | |
robertphillips | 4430239 | 2016-07-08 14:43:03 -0700 | [diff] [blame] | 328 | bool drawFilledRect(const GrClip& clip, |
| 329 | const GrPaint& paint, |
| 330 | const SkMatrix& viewMatrix, |
| 331 | const SkRect& rect, |
| 332 | const GrUserStencilSettings* ss); |
| 333 | |
| 334 | void drawNonAAFilledRect(const GrClip&, |
| 335 | const GrPaint&, |
| 336 | const SkMatrix& viewMatrix, |
| 337 | const SkRect& rect, |
| 338 | const SkRect* localRect, |
| 339 | const SkMatrix* localMatrix, |
| 340 | const GrUserStencilSettings* ss); |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 341 | |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 342 | void internalDrawPath(const GrClip& clip, |
| 343 | const GrPaint& paint, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 344 | const SkMatrix& viewMatrix, |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 345 | const SkPath& path, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 346 | const GrStyle& style); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 347 | |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 348 | // This entry point allows the GrTextContext-derived classes to add their batches to |
| 349 | // the drawTarget. |
robertphillips | 2895eeb | 2016-07-21 12:04:08 -0700 | [diff] [blame^] | 350 | void drawBatch(const GrPaint&, const GrClip&, const GrUserStencilSettings&, GrDrawBatch* batch, |
| 351 | GrDrawFace = GrDrawFace::kBoth); |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 352 | |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 353 | GrDrawTarget* getDrawTarget(); |
| 354 | |
joshualitt | 8db8678 | 2016-02-17 05:40:00 -0800 | [diff] [blame] | 355 | GrDrawingManager* fDrawingManager; |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 356 | sk_sp<GrRenderTarget> fRenderTarget; |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 357 | |
| 358 | // In MDB-mode the drawTarget can be closed by some other drawContext that has picked |
| 359 | // it up. For this reason, the drawTarget should only ever be accessed via 'getDrawTarget'. |
joshualitt | 8db8678 | 2016-02-17 05:40:00 -0800 | [diff] [blame] | 360 | GrDrawTarget* fDrawTarget; |
| 361 | SkAutoTDelete<GrAtlasTextContext> fAtlasTextContext; |
| 362 | GrContext* fContext; |
csmartdalton | a7f2964 | 2016-07-07 08:49:11 -0700 | [diff] [blame] | 363 | GrInstancedPipelineInfo fInstancedPipelineInfo; |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 364 | |
joshualitt | 8db8678 | 2016-02-17 05:40:00 -0800 | [diff] [blame] | 365 | SkSurfaceProps fSurfaceProps; |
| 366 | GrAuditTrail* fAuditTrail; |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 367 | |
| 368 | // In debug builds we guard against improper thread handling |
joshualitt | 6d0872d | 2016-01-11 08:27:48 -0800 | [diff] [blame] | 369 | SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;) |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 370 | }; |
| 371 | |
| 372 | #endif |