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

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

Issue 22850006: Replace uses of GrAssert by SkASSERT. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years, 4 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/GrConfig.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 * 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 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 class AutoMatrix : GrNoncopyable { 671 class AutoMatrix : GrNoncopyable {
672 public: 672 public:
673 AutoMatrix() : fContext(NULL) {} 673 AutoMatrix() : fContext(NULL) {}
674 674
675 ~AutoMatrix() { this->restore(); } 675 ~AutoMatrix() { this->restore(); }
676 676
677 /** 677 /**
678 * Initializes by pre-concat'ing the context's current matrix with the p reConcat param. 678 * Initializes by pre-concat'ing the context's current matrix with the p reConcat param.
679 */ 679 */
680 void setPreConcat(GrContext* context, const SkMatrix& preConcat, GrPaint * paint = NULL) { 680 void setPreConcat(GrContext* context, const SkMatrix& preConcat, GrPaint * paint = NULL) {
681 GrAssert(NULL != context); 681 SkASSERT(NULL != context);
682 682
683 this->restore(); 683 this->restore();
684 684
685 fContext = context; 685 fContext = context;
686 fMatrix = context->getMatrix(); 686 fMatrix = context->getMatrix();
687 this->preConcat(preConcat, paint); 687 this->preConcat(preConcat, paint);
688 } 688 }
689 689
690 /** 690 /**
691 * 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
692 * update a paint but the matrix cannot be inverted. 692 * update a paint but the matrix cannot be inverted.
693 */ 693 */
694 bool setIdentity(GrContext* context, GrPaint* paint = NULL) { 694 bool setIdentity(GrContext* context, GrPaint* paint = NULL) {
695 GrAssert(NULL != context); 695 SkASSERT(NULL != context);
696 696
697 this->restore(); 697 this->restore();
698 698
699 if (NULL != paint) { 699 if (NULL != paint) {
700 if (!paint->localCoordChangeInverse(context->getMatrix())) { 700 if (!paint->localCoordChangeInverse(context->getMatrix())) {
701 return false; 701 return false;
702 } 702 }
703 } 703 }
704 fMatrix = context->getMatrix(); 704 fMatrix = context->getMatrix();
705 fContext = context; 705 fContext = context;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 public: 765 public:
766 // This enum exists to require a caller of the constructor to acknowledg e that the clip will 766 // This enum exists to require a caller of the constructor to acknowledg e that the clip will
767 // initially be wide open. It also could be extended if there are other desirable initial 767 // initially be wide open. It also could be extended if there are other desirable initial
768 // clip states. 768 // clip states.
769 enum InitialClip { 769 enum InitialClip {
770 kWideOpen_InitialClip, 770 kWideOpen_InitialClip,
771 }; 771 };
772 772
773 AutoClip(GrContext* context, InitialClip initialState) 773 AutoClip(GrContext* context, InitialClip initialState)
774 : fContext(context) { 774 : fContext(context) {
775 GrAssert(kWideOpen_InitialClip == initialState); 775 SkASSERT(kWideOpen_InitialClip == initialState);
776 fNewClipData.fClipStack = &fNewClipStack; 776 fNewClipData.fClipStack = &fNewClipStack;
777 777
778 fOldClip = context->getClip(); 778 fOldClip = context->getClip();
779 context->setClip(&fNewClipData); 779 context->setClip(&fNewClipData);
780 } 780 }
781 781
782 AutoClip(GrContext* context, const SkRect& newClipRect) 782 AutoClip(GrContext* context, const SkRect& newClipRect)
783 : fContext(context) 783 : fContext(context)
784 , fNewClipStack(newClipRect) { 784 , fNewClipStack(newClipRect) {
785 fNewClipData.fClipStack = &fNewClipStack; 785 fNewClipData.fClipStack = &fNewClipStack;
(...skipping 15 matching lines...) Expand all
801 GrClipData fNewClipData; 801 GrClipData fNewClipData;
802 }; 802 };
803 803
804 class AutoWideOpenIdentityDraw { 804 class AutoWideOpenIdentityDraw {
805 public: 805 public:
806 AutoWideOpenIdentityDraw(GrContext* ctx, GrRenderTarget* rt) 806 AutoWideOpenIdentityDraw(GrContext* ctx, GrRenderTarget* rt)
807 : fAutoClip(ctx, AutoClip::kWideOpen_InitialClip) 807 : fAutoClip(ctx, AutoClip::kWideOpen_InitialClip)
808 , fAutoRT(ctx, rt) { 808 , fAutoRT(ctx, rt) {
809 fAutoMatrix.setIdentity(ctx); 809 fAutoMatrix.setIdentity(ctx);
810 // should never fail with no paint param. 810 // should never fail with no paint param.
811 GrAssert(fAutoMatrix.succeeded()); 811 SkASSERT(fAutoMatrix.succeeded());
812 } 812 }
813 813
814 private: 814 private:
815 AutoClip fAutoClip; 815 AutoClip fAutoClip;
816 AutoRenderTarget fAutoRT; 816 AutoRenderTarget fAutoRT;
817 AutoMatrix fAutoMatrix; 817 AutoMatrix fAutoMatrix;
818 }; 818 };
819 819
820 /////////////////////////////////////////////////////////////////////////// 820 ///////////////////////////////////////////////////////////////////////////
821 // Functions intended for internal use only. 821 // Functions intended for internal use only.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 if (NULL == fTexture) { 980 if (NULL == fTexture) {
981 return NULL; 981 return NULL;
982 } 982 }
983 GrTexture* texture = fTexture; 983 GrTexture* texture = fTexture;
984 fTexture = NULL; 984 fTexture = NULL;
985 985
986 // This GrAutoScratchTexture has a ref from lockAndRefScratchTexture, wh ich we give up now. 986 // This GrAutoScratchTexture has a ref from lockAndRefScratchTexture, wh ich we give up now.
987 // The cache also has a ref which we are lending to the caller of detach (). When the caller 987 // The cache also has a ref which we are lending to the caller of detach (). When the caller
988 // lets go of the ref and the ref count goes to 0 internal_dispose will see this flag is 988 // lets go of the ref and the ref count goes to 0 internal_dispose will see this flag is
989 // set and re-ref the texture, thereby restoring the cache's ref. 989 // set and re-ref the texture, thereby restoring the cache's ref.
990 GrAssert(texture->getRefCnt() > 1); 990 SkASSERT(texture->getRefCnt() > 1);
991 texture->setFlag((GrTextureFlags) GrTexture::kReturnToCache_FlagBit); 991 texture->setFlag((GrTextureFlags) GrTexture::kReturnToCache_FlagBit);
992 texture->unref(); 992 texture->unref();
993 GrAssert(NULL != texture->getCacheEntry()); 993 SkASSERT(NULL != texture->getCacheEntry());
994 994
995 return texture; 995 return texture;
996 } 996 }
997 997
998 GrTexture* set(GrContext* context, 998 GrTexture* set(GrContext* context,
999 const GrTextureDesc& desc, 999 const GrTextureDesc& desc,
1000 GrContext::ScratchTexMatch match = GrContext::kApprox_Scratch TexMatch) { 1000 GrContext::ScratchTexMatch match = GrContext::kApprox_Scratch TexMatch) {
1001 this->reset(); 1001 this->reset();
1002 1002
1003 fContext = context; 1003 fContext = context;
1004 if (NULL != fContext) { 1004 if (NULL != fContext) {
1005 fTexture = fContext->lockAndRefScratchTexture(desc, match); 1005 fTexture = fContext->lockAndRefScratchTexture(desc, match);
1006 if (NULL == fTexture) { 1006 if (NULL == fTexture) {
1007 fContext = NULL; 1007 fContext = NULL;
1008 } 1008 }
1009 return fTexture; 1009 return fTexture;
1010 } else { 1010 } else {
1011 return NULL; 1011 return NULL;
1012 } 1012 }
1013 } 1013 }
1014 1014
1015 GrTexture* texture() { return fTexture; } 1015 GrTexture* texture() { return fTexture; }
1016 1016
1017 private: 1017 private:
1018 GrContext* fContext; 1018 GrContext* fContext;
1019 GrTexture* fTexture; 1019 GrTexture* fTexture;
1020 }; 1020 };
1021 1021
1022 #endif 1022 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrConfig.h ('k') | include/gpu/GrDrawEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698