Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
|
bsalomon
2015/05/22 20:33:58
does this file need to be in include/gpu for imple
robertphillips
2015/05/26 16:12:59
Done. :(
| |
| 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 GrDawContext_DEFINED | |
| 9 #define GrDrawContext_DEFINED | |
| 10 | |
| 11 #include "GrColor.h" | |
| 12 #include "SkRefCnt.h" | |
| 13 #include "GrDrawTarget.h" // TODO: remove this | |
| 14 | |
| 15 class GrAARectRenderer; | |
|
bsalomon
2015/05/22 20:33:58
need all this?
robertphillips
2015/05/26 16:12:59
Done.
| |
| 16 class GrBatch; | |
| 17 class GrContext; | |
| 18 class GrClip; | |
| 19 class GrDrawTarget; | |
| 20 class GrOvalRenderer; | |
|
bsalomon
2015/05/22 20:33:58
or this?
robertphillips
2015/05/26 16:12:59
Done.
| |
| 21 class GrPaint; | |
| 22 class GrPathProcessor; | |
| 23 class GrPathRange; | |
| 24 class GrPipelineBuilder; | |
| 25 class GrRenderTarget; | |
| 26 class GrStrokeInfo; | |
| 27 class GrSurface; | |
| 28 struct SkIPoint; | |
| 29 struct SkIRect; | |
| 30 class SkMatrix; | |
| 31 class SkPath; | |
| 32 struct SkPoint; | |
| 33 struct SkRect; | |
| 34 class SkRRect; | |
| 35 | |
| 36 /* | |
| 37 * A helper object to orchestrate draws | |
| 38 */ | |
| 39 class GrDrawContext : public SkRefCnt { | |
| 40 public: | |
| 41 SK_DECLARE_INST_COUNT(GrDrawContext) | |
| 42 | |
| 43 void copySurface(GrRenderTarget* dst, GrSurface* src, | |
| 44 const SkIRect& srcRect, const SkIPoint& dstPoint); | |
| 45 | |
| 46 // drawText and drawPaths are thanks to the GrAtlasTextContext and the | |
| 47 // GrStencilAndCoverTextContext respectively | |
| 48 // TODO: remove these two | |
| 49 void drawText(GrPipelineBuilder* pipelineBuilder, GrBatch* batch); | |
|
bsalomon
2015/05/22 20:33:58
e-gads! pipelinebuilders have escaped the zoo!
robertphillips
2015/05/26 16:12:59
Short term only.
| |
| 50 | |
| 51 void drawPaths(GrPipelineBuilder* pipelineBuilder, | |
| 52 const GrPathProcessor* pathProc, | |
| 53 const GrPathRange* pathRange, | |
| 54 const void* indices, | |
| 55 GrDrawTarget::PathIndexType indexType, | |
| 56 const float transformValues[], | |
| 57 GrDrawTarget::PathTransformType transformType, | |
| 58 int count, | |
| 59 GrPathRendering::FillType fill); | |
| 60 | |
| 61 /** | |
| 62 * Provides a perfomance hint that the render target's contents are allowed | |
| 63 * to become undefined. | |
| 64 */ | |
| 65 void discard(GrRenderTarget*); | |
| 66 | |
| 67 /** | |
| 68 * Clear the entire or rect of the render target, ignoring any clips. | |
| 69 * @param target The render target to clear. | |
| 70 * @param rect the rect to clear or the whole thing if rect is NULL. | |
| 71 * @param color the color to clear to. | |
| 72 * @param canIgnoreRect allows partial clears to be converted to whole | |
| 73 * clears on platforms for which that is cheap | |
| 74 */ | |
| 75 void clear(GrRenderTarget*, const SkIRect* rect, GrColor color, bool canIgno reRect); | |
| 76 | |
| 77 /** | |
| 78 * Draw everywhere (respecting the clip) with the paint. | |
| 79 */ | |
| 80 void drawPaint(GrRenderTarget*, const GrClip&, const GrPaint&, const SkMatri x& viewMatrix); | |
| 81 | |
| 82 /** | |
| 83 * Draw the rect using a paint. | |
| 84 * @param paint describes how to color pixels. | |
| 85 * @param viewMatrix transformation matrix | |
| 86 * @param strokeInfo the stroke information (width, join, cap), and. | |
| 87 * the dash information (intervals, count, phase). | |
| 88 * If strokeInfo == NULL, then the rect is filled. | |
| 89 * Otherwise, if stroke width == 0, then the stroke | |
| 90 * is always a single pixel thick, else the rect is | |
| 91 * mitered/beveled stroked based on stroke width. | |
| 92 * The rects coords are used to access the paint (through texture matrix) | |
| 93 */ | |
| 94 void drawRect(GrRenderTarget*, | |
| 95 const GrClip&, | |
| 96 const GrPaint& paint, | |
| 97 const SkMatrix& viewMatrix, | |
| 98 const SkRect&, | |
| 99 const GrStrokeInfo* strokeInfo = NULL); | |
| 100 | |
| 101 /** | |
| 102 * Maps a rectangle of shader coordinates to a rectangle and draws that rect angle | |
| 103 * | |
| 104 * @param paint describes how to color pixels. | |
| 105 * @param viewMatrix transformation matrix which applies to rectToDraw | |
| 106 * @param rectToDraw the rectangle to draw | |
| 107 * @param localRect the rectangle of shader coordinates applied to rectT oDraw | |
| 108 * @param localMatrix an optional matrix to transform the shader coordinat es before applying | |
| 109 * to rectToDraw | |
| 110 */ | |
| 111 void drawNonAARectToRect(GrRenderTarget*, | |
| 112 const GrClip&, | |
| 113 const GrPaint& paint, | |
| 114 const SkMatrix& viewMatrix, | |
| 115 const SkRect& rectToDraw, | |
| 116 const SkRect& localRect, | |
| 117 const SkMatrix* localMatrix = NULL); | |
| 118 | |
| 119 /** | |
| 120 * Draws a non-AA rect with paint and a localMatrix | |
| 121 */ | |
| 122 void drawNonAARectWithLocalMatrix(GrRenderTarget* rt, | |
| 123 const GrClip& clip, | |
| 124 const GrPaint& paint, | |
| 125 const SkMatrix& viewMatrix, | |
| 126 const SkRect& rect, | |
| 127 const SkMatrix& localMatrix) { | |
| 128 this->drawNonAARectToRect(rt, clip, paint, viewMatrix, rect, rect, &loca lMatrix); | |
| 129 } | |
| 130 | |
| 131 /** | |
| 132 * Draw a roundrect using a paint. | |
| 133 * | |
| 134 * @param paint describes how to color pixels. | |
| 135 * @param viewMatrix transformation matrix | |
| 136 * @param rrect the roundrect to draw | |
| 137 * @param strokeInfo the stroke information (width, join, cap) and | |
| 138 * the dash information (intervals, count, phase). | |
| 139 */ | |
| 140 void drawRRect(GrRenderTarget*, | |
| 141 const GrClip&, | |
| 142 const GrPaint&, | |
| 143 const SkMatrix& viewMatrix, | |
| 144 const SkRRect& rrect, | |
| 145 const GrStrokeInfo&); | |
| 146 | |
| 147 /** | |
| 148 * Shortcut for drawing an SkPath consisting of nested rrects using a paint . | |
| 149 * Does not support stroking. The result is undefined if outer does not con tain | |
| 150 * inner. | |
| 151 * | |
| 152 * @param paint describes how to color pixels. | |
| 153 * @param viewMatrix transformation matrix | |
| 154 * @param outer the outer roundrect | |
| 155 * @param inner the inner roundrect | |
| 156 */ | |
| 157 void drawDRRect(GrRenderTarget*, | |
| 158 const GrClip&, | |
| 159 const GrPaint&, | |
| 160 const SkMatrix& viewMatrix, | |
| 161 const SkRRect& outer, | |
| 162 const SkRRect& inner); | |
| 163 | |
| 164 | |
| 165 /** | |
| 166 * Draws a path. | |
| 167 * | |
| 168 * @param paint describes how to color pixels. | |
| 169 * @param viewMatrix transformation matrix | |
| 170 * @param path the path to draw | |
| 171 * @param strokeInfo the stroke information (width, join, cap) and | |
| 172 * the dash information (intervals, count, phase). | |
| 173 */ | |
| 174 void drawPath(GrRenderTarget*, | |
| 175 const GrClip&, | |
| 176 const GrPaint&, | |
| 177 const SkMatrix& viewMatrix, | |
| 178 const SkPath&, | |
| 179 const GrStrokeInfo&); | |
| 180 | |
| 181 /** | |
| 182 * Draws vertices with a paint. | |
| 183 * | |
| 184 * @param paint describes how to color pixels. | |
| 185 * @param viewMatrix transformation matrix | |
| 186 * @param primitiveType primitives type to draw. | |
| 187 * @param vertexCount number of vertices. | |
| 188 * @param positions array of vertex positions, required. | |
| 189 * @param texCoords optional array of texture coordinates used | |
| 190 * to access the paint. | |
| 191 * @param colors optional array of per-vertex colors, supercedes | |
| 192 * the paint's color field. | |
| 193 * @param indices optional array of indices. If NULL vertices | |
| 194 * are drawn non-indexed. | |
| 195 * @param indexCount if indices is non-null then this is the | |
| 196 * number of indices. | |
| 197 */ | |
| 198 void drawVertices(GrRenderTarget*, | |
| 199 const GrClip&, | |
| 200 const GrPaint& paint, | |
| 201 const SkMatrix& viewMatrix, | |
| 202 GrPrimitiveType primitiveType, | |
| 203 int vertexCount, | |
| 204 const SkPoint positions[], | |
| 205 const SkPoint texs[], | |
| 206 const GrColor colors[], | |
| 207 const uint16_t indices[], | |
| 208 int indexCount); | |
| 209 | |
| 210 /** | |
| 211 * Draws an oval. | |
| 212 * | |
| 213 * @param paint describes how to color pixels. | |
| 214 * @param viewMatrix transformation matrix | |
| 215 * @param oval the bounding rect of the oval. | |
| 216 * @param strokeInfo the stroke information (width, join, cap) and | |
| 217 * the dash information (intervals, count, phase). | |
| 218 */ | |
| 219 void drawOval(GrRenderTarget*, | |
| 220 const GrClip&, | |
| 221 const GrPaint& paint, | |
| 222 const SkMatrix& viewMatrix, | |
| 223 const SkRect& oval, | |
| 224 const GrStrokeInfo& strokeInfo); | |
| 225 | |
| 226 | |
| 227 private: | |
| 228 friend class GrContext; // for ctor | |
| 229 | |
| 230 GrDrawContext(GrContext* context, GrDrawTarget* drawTarget); | |
| 231 | |
| 232 // Sets the paint. Returns true on success; false on failure. | |
| 233 bool prepareToDraw(GrPipelineBuilder*, | |
| 234 GrRenderTarget* rt, | |
| 235 const GrClip&, | |
| 236 const GrPaint* paint); | |
| 237 | |
| 238 // A simpler version of the above which just returns true on success; false on failure. | |
| 239 // Clip is *NOT* set | |
| 240 bool prepareToDraw(GrRenderTarget* rt); | |
| 241 | |
| 242 void internalDrawPath(GrDrawTarget*, | |
| 243 GrPipelineBuilder*, | |
| 244 const SkMatrix& viewMatrix, | |
| 245 GrColor, | |
| 246 bool useAA, | |
| 247 const SkPath&, | |
| 248 const GrStrokeInfo&); | |
| 249 | |
| 250 GrContext* fContext; // owning context -> no ref | |
| 251 SkAutoTUnref<GrDrawTarget> fDrawTarget; | |
| 252 }; | |
| 253 | |
| 254 #endif | |
| OLD | NEW |