| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrDrawContext_DEFINED | 8 #ifndef GrDrawContext_DEFINED |
| 9 #define GrDrawContext_DEFINED | 9 #define GrDrawContext_DEFINED |
| 10 | 10 |
| 11 #include "GrColor.h" | 11 #include "GrColor.h" |
| 12 #include "SkRefCnt.h" | 12 #include "SkRefCnt.h" |
| 13 | 13 |
| 14 class GrBatch; | 14 class GrBatch; |
| 15 class GrClip; | 15 class GrClip; |
| 16 class GrContext; | 16 class GrContext; |
| 17 class GrDrawTarget; | 17 class GrDrawTarget; |
| 18 class GrPaint; | 18 class GrPaint; |
| 19 class GrPathProcessor; | 19 class GrPathProcessor; |
| 20 class GrPathRange; | 20 class GrPathRange; |
| 21 class GrPipelineBuilder; | 21 class GrPipelineBuilder; |
| 22 class GrRenderTarget; | 22 class GrRenderTarget; |
| 23 class GrStrokeInfo; | 23 class GrStrokeInfo; |
| 24 class GrSurface; | 24 class GrSurface; |
| 25 class GrTextContext; | |
| 26 struct SkDeviceProperties; | |
| 27 class SkDrawFilter; | |
| 28 struct SkIPoint; | 25 struct SkIPoint; |
| 29 struct SkIRect; | 26 struct SkIRect; |
| 30 class SkMatrix; | 27 class SkMatrix; |
| 31 class SkPaint; | |
| 32 class SkPath; | 28 class SkPath; |
| 33 struct SkPoint; | 29 struct SkPoint; |
| 34 struct SkRect; | 30 struct SkRect; |
| 35 class SkRRect; | 31 class SkRRect; |
| 36 class SkTextBlob; | 32 |
| 37 | 33 |
| 38 /* | 34 /* |
| 39 * A helper object to orchestrate draws | 35 * A helper object to orchestrate draws |
| 40 */ | 36 */ |
| 41 class SK_API GrDrawContext : public SkRefCnt { | 37 class SK_API GrDrawContext : public SkRefCnt { |
| 42 public: | 38 public: |
| 43 SK_DECLARE_INST_COUNT(GrDrawContext) | 39 SK_DECLARE_INST_COUNT(GrDrawContext) |
| 44 | 40 |
| 45 ~GrDrawContext() override; | |
| 46 | |
| 47 void copySurface(GrRenderTarget* dst, GrSurface* src, | 41 void copySurface(GrRenderTarget* dst, GrSurface* src, |
| 48 const SkIRect& srcRect, const SkIPoint& dstPoint); | 42 const SkIRect& srcRect, const SkIPoint& dstPoint); |
| 49 | 43 |
| 50 // TODO: it is odd that we need both the SkPaint in the following 3 methods. | 44 // drawText and drawPaths are thanks to the GrAtlasTextContext and the |
| 51 // We should extract the text parameters from SkPaint and pass them separate
ly | 45 // GrStencilAndCoverTextContext respectively |
| 52 // akin to GrStrokeInfo (GrTextInfo?) | 46 // TODO: remove these two |
| 53 void drawText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPaint
&, | 47 void drawText(GrPipelineBuilder* pipelineBuilder, GrBatch* batch); |
| 54 const SkMatrix& viewMatrix, const char text[], size_t byteLeng
th, | |
| 55 SkScalar x, SkScalar y, const SkIRect& clipBounds); | |
| 56 void drawPosText(GrRenderTarget*, const GrClip&, const GrPaint&, const SkPai
nt&, | |
| 57 const SkMatrix& viewMatrix, const char text[], size_t byteL
ength, | |
| 58 const SkScalar pos[], int scalarsPerPosition, | |
| 59 const SkPoint& offset, const SkIRect& clipBounds); | |
| 60 void drawTextBlob(GrRenderTarget*, const GrClip&, const SkPaint&, | |
| 61 const SkMatrix& viewMatrix, const SkTextBlob*, | |
| 62 SkScalar x, SkScalar y, | |
| 63 SkDrawFilter*, const SkIRect& clipBounds); | |
| 64 | 48 |
| 65 // drawPaths is thanks to GrStencilAndCoverTextContext | |
| 66 // TODO: remove | |
| 67 void drawPaths(GrPipelineBuilder* pipelineBuilder, | 49 void drawPaths(GrPipelineBuilder* pipelineBuilder, |
| 68 const GrPathProcessor* pathProc, | 50 const GrPathProcessor* pathProc, |
| 69 const GrPathRange* pathRange, | 51 const GrPathRange* pathRange, |
| 70 const void* indices, | 52 const void* indices, |
| 71 int /*GrDrawTarget::PathIndexType*/ indexType, | 53 int /*GrDrawTarget::PathIndexType*/ indexType, |
| 72 const float transformValues[], | 54 const float transformValues[], |
| 73 int /*GrDrawTarget::PathTransformType*/ transformType, | 55 int /*GrDrawTarget::PathTransformType*/ transformType, |
| 74 int count, | 56 int count, |
| 75 int /*GrPathRendering::FillType*/ fill); | 57 int /*GrPathRendering::FillType*/ fill); |
| 76 | 58 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 */ | 216 */ |
| 235 void drawOval(GrRenderTarget*, | 217 void drawOval(GrRenderTarget*, |
| 236 const GrClip&, | 218 const GrClip&, |
| 237 const GrPaint& paint, | 219 const GrPaint& paint, |
| 238 const SkMatrix& viewMatrix, | 220 const SkMatrix& viewMatrix, |
| 239 const SkRect& oval, | 221 const SkRect& oval, |
| 240 const GrStrokeInfo& strokeInfo); | 222 const GrStrokeInfo& strokeInfo); |
| 241 | 223 |
| 242 | 224 |
| 243 private: | 225 private: |
| 244 friend class GrAtlasTextContext; // for access to drawBatch | |
| 245 friend class GrContext; // for ctor | 226 friend class GrContext; // for ctor |
| 246 | 227 |
| 247 GrDrawContext(GrContext*, GrDrawTarget*, const SkDeviceProperties&, bool use
DFT); | 228 GrDrawContext(GrContext* context, GrDrawTarget* drawTarget); |
| 229 ~GrDrawContext() override; |
| 248 | 230 |
| 249 // Sets the paint. Returns true on success; false on failure. | 231 // Sets the paint. Returns true on success; false on failure. |
| 250 bool prepareToDraw(GrPipelineBuilder*, | 232 bool prepareToDraw(GrPipelineBuilder*, |
| 251 GrRenderTarget* rt, | 233 GrRenderTarget* rt, |
| 252 const GrClip&, | 234 const GrClip&, |
| 253 const GrPaint* paint); | 235 const GrPaint* paint); |
| 254 GrTextContext* createTextContext(GrRenderTarget*, const SkDeviceProperties&,
bool useDFT); | |
| 255 | 236 |
| 256 // A simpler version of the above which just returns true on success; false
on failure. | 237 // A simpler version of the above which just returns true on success; false
on failure. |
| 257 // Clip is *NOT* set | 238 // Clip is *NOT* set |
| 258 bool prepareToDraw(GrRenderTarget* rt); | 239 bool prepareToDraw(GrRenderTarget* rt); |
| 259 | 240 |
| 260 void internalDrawPath(GrDrawTarget*, | 241 void internalDrawPath(GrDrawTarget*, |
| 261 GrPipelineBuilder*, | 242 GrPipelineBuilder*, |
| 262 const SkMatrix& viewMatrix, | 243 const SkMatrix& viewMatrix, |
| 263 GrColor, | 244 GrColor, |
| 264 bool useAA, | 245 bool useAA, |
| 265 const SkPath&, | 246 const SkPath&, |
| 266 const GrStrokeInfo&); | 247 const GrStrokeInfo&); |
| 267 | 248 |
| 268 // This entry point allows the GrTextContext-derived classes to add their ba
tches to | 249 GrContext* fContext; // owning context -> no ref |
| 269 // the drawTarget. | 250 GrDrawTarget* fDrawTarget; |
| 270 void drawBatch(GrPipelineBuilder* pipelineBuilder, GrBatch* batch); | |
| 271 | |
| 272 GrContext* fContext; // owning context -> no ref | |
| 273 GrDrawTarget* fDrawTarget; | |
| 274 GrTextContext* fTextContext; // lazily created | |
| 275 | |
| 276 SkDeviceProperties* fDevProps; // ptr b.c. SkDeviceProperties isn't publi
c | |
| 277 bool fUseDFT; | |
| 278 }; | 251 }; |
| 279 | 252 |
| 280 #endif | 253 #endif |
| OLD | NEW |