| 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 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 */ | 45 */ |
| 46 class SK_API GrDrawContext : public SkRefCnt { | 46 class SK_API GrDrawContext : public SkRefCnt { |
| 47 public: | 47 public: |
| 48 ~GrDrawContext() override; | 48 ~GrDrawContext() override; |
| 49 | 49 |
| 50 bool copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dst
Point); | 50 bool copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dst
Point); |
| 51 | 51 |
| 52 // TODO: it is odd that we need both the SkPaint in the following 3 methods. | 52 // TODO: it is odd that we need both the SkPaint in the following 3 methods. |
| 53 // We should extract the text parameters from SkPaint and pass them separate
ly | 53 // We should extract the text parameters from SkPaint and pass them separate
ly |
| 54 // akin to GrStrokeInfo (GrTextInfo?) | 54 // akin to GrStrokeInfo (GrTextInfo?) |
| 55 void drawText(const GrClip&, const GrPaint&, const SkPaint&, | 55 virtual void drawText(const GrClip&, const GrPaint&, const SkPaint&, |
| 56 const SkMatrix& viewMatrix, const char text[], size_t byteLeng
th, | 56 const SkMatrix& viewMatrix, const char text[], size_t
byteLength, |
| 57 SkScalar x, SkScalar y, const SkIRect& clipBounds); | 57 SkScalar x, SkScalar y, const SkIRect& clipBounds); |
| 58 void drawPosText(const GrClip&, const GrPaint&, const SkPaint&, | 58 virtual void drawPosText(const GrClip&, const GrPaint&, const SkPaint&, |
| 59 const SkMatrix& viewMatrix, const char text[], size_t byteL
ength, | 59 const SkMatrix& viewMatrix, const char text[], size
_t byteLength, |
| 60 const SkScalar pos[], int scalarsPerPosition, | 60 const SkScalar pos[], int scalarsPerPosition, |
| 61 const SkPoint& offset, const SkIRect& clipBounds); | 61 const SkPoint& offset, const SkIRect& clipBounds); |
| 62 void drawTextBlob(const GrClip&, const SkPaint&, | 62 virtual void drawTextBlob(const GrClip&, const SkPaint&, |
| 63 const SkMatrix& viewMatrix, const SkTextBlob*, | 63 const SkMatrix& viewMatrix, const SkTextBlob*, |
| 64 SkScalar x, SkScalar y, | 64 SkScalar x, SkScalar y, |
| 65 SkDrawFilter*, const SkIRect& clipBounds); | 65 SkDrawFilter*, const SkIRect& clipBounds); |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * Provides a perfomance hint that the render target's contents are allowed | 68 * Provides a perfomance hint that the render target's contents are allowed |
| 69 * to become undefined. | 69 * to become undefined. |
| 70 */ | 70 */ |
| 71 void discard(); | 71 void discard(); |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * Clear the entire or rect of the render target, ignoring any clips. | 74 * Clear the entire or rect of the render target, ignoring any clips. |
| 75 * @param rect the rect to clear or the whole thing if rect is NULL. | 75 * @param rect the rect to clear or the whole thing if rect is NULL. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 int width() const { return fRenderTarget->width(); } | 275 int width() const { return fRenderTarget->width(); } |
| 276 int height() const { return fRenderTarget->height(); } | 276 int height() const { return fRenderTarget->height(); } |
| 277 int numColorSamples() const { return fRenderTarget->numColorSamples(); } | 277 int numColorSamples() const { return fRenderTarget->numColorSamples(); } |
| 278 | 278 |
| 279 GrRenderTarget* accessRenderTarget() { return fRenderTarget; } | 279 GrRenderTarget* accessRenderTarget() { return fRenderTarget; } |
| 280 | 280 |
| 281 ////////////////////////////////////////////////////////////////////////////
/////////////////// | 281 ////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 282 // Functions intended for internal use only. | 282 // Functions intended for internal use only. |
| 283 void internal_drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBatc
h* batch); | 283 void internal_drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBatc
h* batch); |
| 284 | 284 |
| 285 protected: |
| 286 GrDrawContext(GrContext*, GrDrawingManager*, GrRenderTarget*, |
| 287 const SkSurfaceProps* surfaceProps, GrAuditTrail*, GrSingleOwn
er*); |
| 288 |
| 289 GrDrawingManager* drawingManager() { return fDrawingManager; } |
| 290 GrAuditTrail* auditTrail() { return fAuditTrail; } |
| 291 const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } |
| 292 |
| 293 SkDEBUGCODE(GrSingleOwner* singleOwner() { return fSingleOwner; }) |
| 294 SkDEBUGCODE(void validate() const;) |
| 295 |
| 285 private: | 296 private: |
| 286 friend class GrAtlasTextBlob; // for access to drawBatch | 297 friend class GrAtlasTextBlob; // for access to drawBatch |
| 287 friend class GrDrawingManager; // for ctor | 298 friend class GrDrawingManager; // for ctor |
| 288 | 299 |
| 289 SkDEBUGCODE(void validate() const;) | |
| 290 | |
| 291 GrDrawContext(GrContext*, GrDrawingManager*, GrRenderTarget*, | |
| 292 const SkSurfaceProps* surfaceProps, GrAuditTrail*, GrSingleOwn
er*); | |
| 293 | |
| 294 void internalDrawPath(GrPipelineBuilder*, | 300 void internalDrawPath(GrPipelineBuilder*, |
| 295 const SkMatrix& viewMatrix, | 301 const SkMatrix& viewMatrix, |
| 296 GrColor, | 302 GrColor, |
| 297 bool useAA, | 303 bool useAA, |
| 298 const SkPath&, | 304 const SkPath&, |
| 299 const GrStrokeInfo&); | 305 const GrStrokeInfo&); |
| 300 | 306 |
| 301 // This entry point allows the GrTextContext-derived classes to add their ba
tches to | 307 // This entry point allows the GrTextContext-derived classes to add their ba
tches to |
| 302 // the drawTarget. | 308 // the drawTarget. |
| 303 void drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* batch); | 309 void drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* batch); |
| 304 | 310 |
| 305 GrDrawTarget* getDrawTarget(); | 311 GrDrawTarget* getDrawTarget(); |
| 306 | 312 |
| 307 GrDrawingManager* fDrawingManager; | 313 GrDrawingManager* fDrawingManager; |
| 308 GrRenderTarget* fRenderTarget; | 314 GrRenderTarget* fRenderTarget; |
| 309 | 315 |
| 310 // In MDB-mode the drawTarget can be closed by some other drawContext that h
as picked | 316 // In MDB-mode the drawTarget can be closed by some other drawContext that h
as picked |
| 311 // it up. For this reason, the drawTarget should only ever be accessed via '
getDrawTarget'. | 317 // it up. For this reason, the drawTarget should only ever be accessed via '
getDrawTarget'. |
| 312 GrDrawTarget* fDrawTarget; | 318 GrDrawTarget* fDrawTarget; |
| 313 GrTextContext* fTextContext; // lazily gotten from GrContext::DrawingMana
ger | 319 GrTextContext* fAtlasTextContext; // lazily gotten from GrContext::Drawin
gManager |
| 314 GrContext* fContext; | 320 GrContext* fContext; |
| 315 | 321 |
| 316 SkSurfaceProps fSurfaceProps; | 322 SkSurfaceProps fSurfaceProps; |
| 317 GrAuditTrail* fAuditTrail; | 323 GrAuditTrail* fAuditTrail; |
| 318 | 324 |
| 319 // In debug builds we guard against improper thread handling | 325 // In debug builds we guard against improper thread handling |
| 320 SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;) | 326 SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;) |
| 321 }; | 327 }; |
| 322 | 328 |
| 323 #endif | 329 #endif |
| OLD | NEW |