OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 GrContext_DEFINED | 8 #ifndef GrContext_DEFINED |
9 #define GrContext_DEFINED | 9 #define GrContext_DEFINED |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 class GrOvalRenderer; | 32 class GrOvalRenderer; |
33 class GrPath; | 33 class GrPath; |
34 class GrPathRenderer; | 34 class GrPathRenderer; |
35 class GrResourceEntry; | 35 class GrResourceEntry; |
36 class GrResourceCache; | 36 class GrResourceCache; |
37 class GrStencilBuffer; | 37 class GrStencilBuffer; |
38 class GrTestTarget; | 38 class GrTestTarget; |
39 class GrTextureParams; | 39 class GrTextureParams; |
40 class GrVertexBuffer; | 40 class GrVertexBuffer; |
41 class GrVertexBufferAllocPool; | 41 class GrVertexBufferAllocPool; |
| 42 class GrStrokeInfo; |
42 class GrSoftwarePathRenderer; | 43 class GrSoftwarePathRenderer; |
43 class SkStrokeRec; | 44 class SkStrokeRec; |
44 | 45 |
45 class SK_API GrContext : public SkRefCnt { | 46 class SK_API GrContext : public SkRefCnt { |
46 public: | 47 public: |
47 SK_DECLARE_INST_COUNT(GrContext) | 48 SK_DECLARE_INST_COUNT(GrContext) |
48 | 49 |
49 /** | 50 /** |
50 * Creates a GrContext for a backend context. | 51 * Creates a GrContext for a backend context. |
51 */ | 52 */ |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 GrRenderTarget* target = NULL); | 446 GrRenderTarget* target = NULL); |
446 | 447 |
447 /** | 448 /** |
448 * Draw everywhere (respecting the clip) with the paint. | 449 * Draw everywhere (respecting the clip) with the paint. |
449 */ | 450 */ |
450 void drawPaint(const GrPaint& paint); | 451 void drawPaint(const GrPaint& paint); |
451 | 452 |
452 /** | 453 /** |
453 * Draw the rect using a paint. | 454 * Draw the rect using a paint. |
454 * @param paint describes how to color pixels. | 455 * @param paint describes how to color pixels. |
455 * @param stroke the stroke information (width, join, cap). | 456 * @param strokeInfo the stroke information (width, join, cap), and. |
456 * If stroke == NULL, then the rect is filled. | 457 * the dash information (intervals, count, phase). |
| 458 * If strokeInfo == NULL, then the rect is filled. |
457 * Otherwise, if stroke width == 0, then the stroke | 459 * Otherwise, if stroke width == 0, then the stroke |
458 * is always a single pixel thick, else the rect is | 460 * is always a single pixel thick, else the rect is |
459 * mitered/beveled stroked based on stroke width. | 461 * mitered/beveled stroked based on stroke width. |
| 462 * If the stroke is dashed the rect is sent to drawPath
. |
460 * @param matrix Optional matrix applied to the rect. Applied before | 463 * @param matrix Optional matrix applied to the rect. Applied before |
461 * context's matrix or the paint's matrix. | 464 * context's matrix or the paint's matrix. |
462 * The rects coords are used to access the paint (through texture matrix) | 465 * The rects coords are used to access the paint (through texture matrix) |
463 */ | 466 */ |
464 void drawRect(const GrPaint& paint, | 467 void drawRect(const GrPaint& paint, |
465 const SkRect&, | 468 const SkRect&, |
466 const SkStrokeRec* stroke = NULL, | 469 const GrStrokeInfo* strokeInfo = NULL, |
467 const SkMatrix* matrix = NULL); | 470 const SkMatrix* matrix = NULL); |
468 | 471 |
469 /** | 472 /** |
470 * Maps a rect of local coordinates onto the a rect of destination | 473 * Maps a rect of local coordinates onto the a rect of destination |
471 * coordinates. Each rect can optionally be transformed. The localRect | 474 * coordinates. Each rect can optionally be transformed. The localRect |
472 * is stretched over the dstRect. The dstRect is transformed by the | 475 * is stretched over the dstRect. The dstRect is transformed by the |
473 * context's matrix. Additional optional matrices for both rects can be | 476 * context's matrix. Additional optional matrices for both rects can be |
474 * provided by parameters. | 477 * provided by parameters. |
475 * | 478 * |
476 * @param paint describes how to color pixels. | 479 * @param paint describes how to color pixels. |
477 * @param dstRect the destination rect to draw. | 480 * @param dstRect the destination rect to draw. |
478 * @param localRect rect of local coordinates to be mapped onto dstRect | 481 * @param localRect rect of local coordinates to be mapped onto dstRect |
479 * @param dstMatrix Optional matrix to transform dstRect. Applied before
context's matrix. | 482 * @param dstMatrix Optional matrix to transform dstRect. Applied before
context's matrix. |
480 * @param localMatrix Optional matrix to transform localRect. | 483 * @param localMatrix Optional matrix to transform localRect. |
481 */ | 484 */ |
482 void drawRectToRect(const GrPaint& paint, | 485 void drawRectToRect(const GrPaint& paint, |
483 const SkRect& dstRect, | 486 const SkRect& dstRect, |
484 const SkRect& localRect, | 487 const SkRect& localRect, |
485 const SkMatrix* dstMatrix = NULL, | 488 const SkMatrix* dstMatrix = NULL, |
486 const SkMatrix* localMatrix = NULL); | 489 const SkMatrix* localMatrix = NULL); |
487 | 490 |
488 /** | 491 /** |
489 * Draw a roundrect using a paint. | 492 * Draw a roundrect using a paint. |
490 * | 493 * |
491 * @param paint describes how to color pixels. | 494 * @param paint describes how to color pixels. |
492 * @param rrect the roundrect to draw | 495 * @param rrect the roundrect to draw |
493 * @param stroke the stroke information (width, join, cap) | 496 * @param strokeInfo the stroke information (width, join, cap) and |
| 497 * the dash information (intervals, count, phase). |
494 */ | 498 */ |
495 void drawRRect(const GrPaint& paint, const SkRRect& rrect, const SkStrokeRec
& stroke); | 499 void drawRRect(const GrPaint& paint, const SkRRect& rrect, const GrStrokeInf
o& strokeInfo); |
496 | 500 |
497 /** | 501 /** |
498 * Shortcut for drawing an SkPath consisting of nested rrects using a paint
. | 502 * Shortcut for drawing an SkPath consisting of nested rrects using a paint
. |
499 * Does not support stroking. The result is undefined if outer does not con
tain | 503 * Does not support stroking. The result is undefined if outer does not con
tain |
500 * inner. | 504 * inner. |
501 * | 505 * |
502 * @param paint describes how to color pixels. | 506 * @param paint describes how to color pixels. |
503 * @param outer the outer roundrect | 507 * @param outer the outer roundrect |
504 * @param inner the inner roundrect | 508 * @param inner the inner roundrect |
505 */ | 509 */ |
506 void drawDRRect(const GrPaint& paint, const SkRRect& outer, const SkRRect& i
nner); | 510 void drawDRRect(const GrPaint& paint, const SkRRect& outer, const SkRRect& i
nner); |
507 | 511 |
508 | 512 |
509 /** | 513 /** |
510 * Draws a path. | 514 * Draws a path. |
511 * | 515 * |
512 * @param paint describes how to color pixels. | 516 * @param paint describes how to color pixels. |
513 * @param path the path to draw | 517 * @param path the path to draw |
514 * @param stroke the stroke information (width, join, cap) | 518 * @param strokeInfo the stroke information (width, join, cap) and |
| 519 * the dash information (intervals, count, phase). |
515 */ | 520 */ |
516 void drawPath(const GrPaint& paint, const SkPath& path, const SkStrokeRec& s
troke); | 521 void drawPath(const GrPaint& paint, const SkPath& path, const GrStrokeInfo&
strokeInfo); |
517 | 522 |
518 /** | 523 /** |
519 * Draws vertices with a paint. | 524 * Draws vertices with a paint. |
520 * | 525 * |
521 * @param paint describes how to color pixels. | 526 * @param paint describes how to color pixels. |
522 * @param primitiveType primitives type to draw. | 527 * @param primitiveType primitives type to draw. |
523 * @param vertexCount number of vertices. | 528 * @param vertexCount number of vertices. |
524 * @param positions array of vertex positions, required. | 529 * @param positions array of vertex positions, required. |
525 * @param texCoords optional array of texture coordinates used | 530 * @param texCoords optional array of texture coordinates used |
526 * to access the paint. | 531 * to access the paint. |
(...skipping 11 matching lines...) Expand all Loading... |
538 const SkPoint texs[], | 543 const SkPoint texs[], |
539 const GrColor colors[], | 544 const GrColor colors[], |
540 const uint16_t indices[], | 545 const uint16_t indices[], |
541 int indexCount); | 546 int indexCount); |
542 | 547 |
543 /** | 548 /** |
544 * Draws an oval. | 549 * Draws an oval. |
545 * | 550 * |
546 * @param paint describes how to color pixels. | 551 * @param paint describes how to color pixels. |
547 * @param oval the bounding rect of the oval. | 552 * @param oval the bounding rect of the oval. |
548 * @param stroke the stroke information (width, style) | 553 * @param strokeInfo the stroke information (width, join, cap) and |
| 554 * the dash information (intervals, count, phase). |
549 */ | 555 */ |
550 void drawOval(const GrPaint& paint, | 556 void drawOval(const GrPaint& paint, |
551 const SkRect& oval, | 557 const SkRect& oval, |
552 const SkStrokeRec& stroke); | 558 const GrStrokeInfo& strokeInfo); |
553 | 559 |
554 /////////////////////////////////////////////////////////////////////////// | 560 /////////////////////////////////////////////////////////////////////////// |
555 // Misc. | 561 // Misc. |
556 | 562 |
557 /** | 563 /** |
558 * Flags that affect flush() behavior. | 564 * Flags that affect flush() behavior. |
559 */ | 565 */ |
560 enum FlushBits { | 566 enum FlushBits { |
561 /** | 567 /** |
562 * A client may reach a point where it has partially rendered a frame | 568 * A client may reach a point where it has partially rendered a frame |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 | 994 |
989 void setupDrawBuffer(); | 995 void setupDrawBuffer(); |
990 | 996 |
991 class AutoRestoreEffects; | 997 class AutoRestoreEffects; |
992 class AutoCheckFlush; | 998 class AutoCheckFlush; |
993 /// Sets the paint and returns the target to draw into. The paint can be NUL
L in which case the | 999 /// Sets the paint and returns the target to draw into. The paint can be NUL
L in which case the |
994 /// draw state is left unmodified. | 1000 /// draw state is left unmodified. |
995 GrDrawTarget* prepareToDraw(const GrPaint*, BufferedDraw, AutoRestoreEffects
*, AutoCheckFlush*); | 1001 GrDrawTarget* prepareToDraw(const GrPaint*, BufferedDraw, AutoRestoreEffects
*, AutoCheckFlush*); |
996 | 1002 |
997 void internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath& path, | 1003 void internalDrawPath(GrDrawTarget* target, bool useAA, const SkPath& path, |
998 const SkStrokeRec& stroke); | 1004 const GrStrokeInfo& stroke); |
999 | 1005 |
1000 GrTexture* createResizedTexture(const GrTextureDesc& desc, | 1006 GrTexture* createResizedTexture(const GrTextureDesc& desc, |
1001 const GrCacheID& cacheID, | 1007 const GrCacheID& cacheID, |
1002 const void* srcData, | 1008 const void* srcData, |
1003 size_t rowBytes, | 1009 size_t rowBytes, |
1004 bool filter); | 1010 bool filter); |
1005 | 1011 |
1006 // Needed so GrTexture's returnToCache helper function can call | 1012 // Needed so GrTexture's returnToCache helper function can call |
1007 // addExistingTextureToCache | 1013 // addExistingTextureToCache |
1008 friend class GrTexture; | 1014 friend class GrTexture; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 } | 1128 } |
1123 | 1129 |
1124 GrTexture* texture() { return fTexture; } | 1130 GrTexture* texture() { return fTexture; } |
1125 | 1131 |
1126 private: | 1132 private: |
1127 GrContext* fContext; | 1133 GrContext* fContext; |
1128 GrTexture* fTexture; | 1134 GrTexture* fTexture; |
1129 }; | 1135 }; |
1130 | 1136 |
1131 #endif | 1137 #endif |
OLD | NEW |