Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: include/gpu/GrContext.h

Issue 12531015: Adds local coords to GrEffect system. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/gpu/GrBackendEffectFactory.h ('k') | include/gpu/GrDrawEffect.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef GrContext_DEFINED 10 #ifndef GrContext_DEFINED
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 * @param matrix Optional matrix applied to the rect. Applied before 383 * @param matrix Optional matrix applied to the rect. Applied before
384 * context's matrix or the paint's matrix. 384 * context's matrix or the paint's matrix.
385 * The rects coords are used to access the paint (through texture matrix) 385 * The rects coords are used to access the paint (through texture matrix)
386 */ 386 */
387 void drawRect(const GrPaint& paint, 387 void drawRect(const GrPaint& paint,
388 const GrRect&, 388 const GrRect&,
389 SkScalar strokeWidth = -1, 389 SkScalar strokeWidth = -1,
390 const SkMatrix* matrix = NULL); 390 const SkMatrix* matrix = NULL);
391 391
392 /** 392 /**
393 * Maps a rect of paint coordinates onto the a rect of destination 393 * Maps a rect of local coordinates onto the a rect of destination
394 * coordinates. Each rect can optionally be transformed. The srcRect 394 * coordinates. Each rect can optionally be transformed. The localRect
395 * is stretched over the dstRect. The dstRect is transformed by the 395 * is stretched over the dstRect. The dstRect is transformed by the
396 * context's matrix and the srcRect is transformed by the paint's matrix. 396 * context's matrix. Additional optional matrices for both rects can be
397 * Additional optional matrices can be provided by parameters. 397 * provided by parameters.
398 * 398 *
399 * @param paint describes how to color pixels. 399 * @param paint describes how to color pixels.
400 * @param dstRect the destination rect to draw. 400 * @param dstRect the destination rect to draw.
401 * @param srcRect rect of paint coordinates to be mapped onto dstRect 401 * @param localRect rect of local coordinates to be mapped onto dstRect
402 * @param dstMatrix Optional matrix to transform dstRect. Applied before 402 * @param dstMatrix Optional matrix to transform dstRect. Applied before context's matrix.
403 * context's matrix. 403 * @param localMatrix Optional matrix to transform localRect.
404 * @param srcMatrix Optional matrix to transform srcRect Applied before
405 * paint's matrix.
406 */ 404 */
407 void drawRectToRect(const GrPaint& paint, 405 void drawRectToRect(const GrPaint& paint,
408 const GrRect& dstRect, 406 const GrRect& dstRect,
409 const GrRect& srcRect, 407 const GrRect& localRect,
410 const SkMatrix* dstMatrix = NULL, 408 const SkMatrix* dstMatrix = NULL,
411 const SkMatrix* srcMatrix = NULL); 409 const SkMatrix* localMatrix = NULL);
412 410
413 /** 411 /**
414 * Draws a path. 412 * Draws a path.
415 * 413 *
416 * @param paint describes how to color pixels. 414 * @param paint describes how to color pixels.
417 * @param path the path to draw 415 * @param path the path to draw
418 * @param stroke the stroke information (width, join, cap) 416 * @param stroke the stroke information (width, join, cap)
419 */ 417 */
420 void drawPath(const GrPaint& paint, const SkPath& path, const SkStrokeRec& s troke); 418 void drawPath(const GrPaint& paint, const SkPath& path, const SkStrokeRec& s troke);
421 419
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 /** 690 /**
693 * Sets the context's matrix to identity. Returns false if the inverse m atrix is required to 691 * Sets the context's matrix to identity. Returns false if the inverse m atrix is required to
694 * update a paint but the matrix cannot be inverted. 692 * update a paint but the matrix cannot be inverted.
695 */ 693 */
696 bool setIdentity(GrContext* context, GrPaint* paint = NULL) { 694 bool setIdentity(GrContext* context, GrPaint* paint = NULL) {
697 GrAssert(NULL != context); 695 GrAssert(NULL != context);
698 696
699 this->restore(); 697 this->restore();
700 698
701 if (NULL != paint) { 699 if (NULL != paint) {
702 if (!paint->sourceCoordChangeByInverse(context->getMatrix())) { 700 if (!paint->localCoordChangeInverse(context->getMatrix())) {
703 return false; 701 return false;
704 } 702 }
705 } 703 }
706 fMatrix = context->getMatrix(); 704 fMatrix = context->getMatrix();
707 fContext = context; 705 fContext = context;
708 context->setIdentityMatrix(); 706 context->setIdentityMatrix();
709 return true; 707 return true;
710 } 708 }
711 709
712 /** 710 /**
(...skipping 17 matching lines...) Expand all
730 728
731 /** 729 /**
732 * If this has been initialized then the context's matrix will be furthe r updated by 730 * If this has been initialized then the context's matrix will be furthe r updated by
733 * pre-concat'ing the preConcat param. The matrix that will be restored remains unchanged. 731 * pre-concat'ing the preConcat param. The matrix that will be restored remains unchanged.
734 * The paint is assumed to be relative to the context's matrix at the ti me this call is 732 * The paint is assumed to be relative to the context's matrix at the ti me this call is
735 * made, not the matrix at the time AutoMatrix was first initialized. In other words, this 733 * made, not the matrix at the time AutoMatrix was first initialized. In other words, this
736 * performs an incremental update of the paint. 734 * performs an incremental update of the paint.
737 */ 735 */
738 void preConcat(const SkMatrix& preConcat, GrPaint* paint = NULL) { 736 void preConcat(const SkMatrix& preConcat, GrPaint* paint = NULL) {
739 if (NULL != paint) { 737 if (NULL != paint) {
740 paint->sourceCoordChange(preConcat); 738 paint->localCoordChange(preConcat);
741 } 739 }
742 fContext->concatMatrix(preConcat); 740 fContext->concatMatrix(preConcat);
743 } 741 }
744 742
745 /** 743 /**
746 * Returns false if never initialized or the inverse matrix was required to update a paint 744 * Returns false if never initialized or the inverse matrix was required to update a paint
747 * but the matrix could not be inverted. 745 * but the matrix could not be inverted.
748 */ 746 */
749 bool succeeded() const { return NULL != fContext; } 747 bool succeeded() const { return NULL != fContext; }
750 748
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 } 1001 }
1004 1002
1005 GrTexture* texture() { return fTexture; } 1003 GrTexture* texture() { return fTexture; }
1006 1004
1007 private: 1005 private:
1008 GrContext* fContext; 1006 GrContext* fContext;
1009 GrTexture* fTexture; 1007 GrTexture* fTexture;
1010 }; 1008 };
1011 1009
1012 #endif 1010 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrBackendEffectFactory.h ('k') | include/gpu/GrDrawEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698