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