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

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

Issue 522873005: Move MakeDivByTextureWHMatrix to GrCoordTransform (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | include/gpu/GrEffect.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 2013 Google Inc. 2 * Copyright 2013 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 GrCoordTransform_DEFINED 8 #ifndef GrCoordTransform_DEFINED
9 #define GrCoordTransform_DEFINED 9 #define GrCoordTransform_DEFINED
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 * coord convention. 57 * coord convention.
58 */ 58 */
59 GrCoordTransform(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture * texture = NULL) { 59 GrCoordTransform(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture * texture = NULL) {
60 SkDEBUGCODE(fInEffect = false); 60 SkDEBUGCODE(fInEffect = false);
61 this->reset(sourceCoords, m, texture); 61 this->reset(sourceCoords, m, texture);
62 } 62 }
63 63
64 void reset(GrCoordSet sourceCoords, const GrTexture* texture) { 64 void reset(GrCoordSet sourceCoords, const GrTexture* texture) {
65 SkASSERT(!fInEffect); 65 SkASSERT(!fInEffect);
66 SkASSERT(NULL != texture); 66 SkASSERT(NULL != texture);
67 this->reset(sourceCoords, GrEffect::MakeDivByTextureWHMatrix(texture), t exture); 67 this->reset(sourceCoords, MakeDivByTextureWHMatrix(texture), texture);
68 } 68 }
69 69
70 void reset(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture* text ure = NULL) { 70 void reset(GrCoordSet sourceCoords, const SkMatrix& m, const GrTexture* text ure = NULL) {
71 SkASSERT(!fInEffect); 71 SkASSERT(!fInEffect);
72 fSourceCoords = sourceCoords; 72 fSourceCoords = sourceCoords;
73 fMatrix = m; 73 fMatrix = m;
74 fReverseY = NULL != texture && kBottomLeft_GrSurfaceOrigin == texture->o rigin(); 74 fReverseY = NULL != texture && kBottomLeft_GrSurfaceOrigin == texture->o rigin();
75 } 75 }
76 76
77 GrCoordTransform& operator= (const GrCoordTransform& other) { 77 GrCoordTransform& operator= (const GrCoordTransform& other) {
(...skipping 16 matching lines...) Expand all
94 bool operator== (const GrCoordTransform& other) const { 94 bool operator== (const GrCoordTransform& other) const {
95 return fSourceCoords == other.fSourceCoords && 95 return fSourceCoords == other.fSourceCoords &&
96 fMatrix.cheapEqualTo(other.fMatrix) && 96 fMatrix.cheapEqualTo(other.fMatrix) &&
97 fReverseY == other.fReverseY; 97 fReverseY == other.fReverseY;
98 } 98 }
99 99
100 GrCoordSet sourceCoords() const { return fSourceCoords; } 100 GrCoordSet sourceCoords() const { return fSourceCoords; }
101 const SkMatrix& getMatrix() const { return fMatrix; } 101 const SkMatrix& getMatrix() const { return fMatrix; }
102 bool reverseY() const { return fReverseY; } 102 bool reverseY() const { return fReverseY; }
103 103
104 /** Useful for effects that want to insert a texture matrix that is implied by the texture
105 dimensions */
106 static inline SkMatrix MakeDivByTextureWHMatrix(const GrTexture* texture) {
107 SkASSERT(NULL != texture);
108 SkMatrix mat;
109 mat.setIDiv(texture->width(), texture->height());
110 return mat;
111 }
112
104 private: 113 private:
105 GrCoordSet fSourceCoords; 114 GrCoordSet fSourceCoords;
106 SkMatrix fMatrix; 115 SkMatrix fMatrix;
107 bool fReverseY; 116 bool fReverseY;
108 117
109 typedef SkNoncopyable INHERITED; 118 typedef SkNoncopyable INHERITED;
110 119
111 #ifdef SK_DEBUG 120 #ifdef SK_DEBUG
112 public: 121 public:
113 void setInEffect() const { fInEffect = true; } 122 void setInEffect() const { fInEffect = true; }
114 private: 123 private:
115 mutable bool fInEffect; 124 mutable bool fInEffect;
116 #endif 125 #endif
117 }; 126 };
118 127
119 #endif 128 #endif
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698