aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-20 13:37:06 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-20 13:37:06 +0000
commite3d3216fe17b6afb2e613271b5246a2766e12df6 (patch)
treeb5e9b1a72df637677148dd91262d793000ff594c /include/gpu
parent426aebc8502654642bebfdda22af8acdae84cf05 (diff)
Remove stage masks
Review URL: http://codereview.appspot.com/6422047/ git-svn-id: http://skia.googlecode.com/svn/trunk@4688 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/gpu')
-rw-r--r--include/gpu/GrContext.h9
-rw-r--r--include/gpu/GrPaint.h89
2 files changed, 45 insertions, 53 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index f905825db2..18abd4eba1 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -809,15 +809,6 @@ private:
// only have to functions necessary for clients.
friend class GrAtlas;
- // computes vertex layout bits based on the paint. If paint expresses
- // a texture for a stage, the stage coords will be bound to postitions
- // unless hasTexCoords[s]==true in which case stage s's input coords
- // are bound to tex coord index s. hasTexCoords == NULL is a shortcut
- // for an array where all the values are false.
- static int PaintStageVertexLayoutBits(
- const GrPaint& paint,
- const bool hasTexCoords[GrPaint::kTotalStages]);
-
// Needed so GrTexture's returnToCache helper function can call
// addExistingTextureToCache
friend class GrTexture;
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index fc2fce5875..4eb2f2d750 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -102,14 +102,55 @@ public:
(NULL != fMaskSamplers[i].getCustomStage());
}
- // pre-concats sampler matrices for non-NULL textures and masks
- void preConcatActiveSamplerMatrices(const GrMatrix& matrix) {
+ bool hasMask() const {
+ for (int i = 0; i < kMaxMasks; ++i) {
+ if (this->isMaskStageEnabled(i)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool hasTexture() const {
for (int i = 0; i < kMaxTextures; ++i) {
- fTextureSamplers[i].preConcatMatrix(matrix);
+ if (this->isTextureStageEnabled(i)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool hasTextureOrMask() const { return this->hasTexture() || this->hasMask(); }
+
+ /**
+ * Preconcats the matrix of all samplers in the mask with the inverse of a
+ * matrix. If the matrix inverse cannot be computed (and there is at least
+ * one enabled stage) then false is returned.
+ */
+ bool preConcatSamplerMatricesWithInverse(const GrMatrix& matrix) {
+ GrMatrix inv;
+ bool computed = false;
+ for (int i = 0; i < kMaxTextures; ++i) {
+ if (this->isTextureStageEnabled(i)) {
+ if (!computed && !matrix.invert(&inv)) {
+ return false;
+ } else {
+ computed = true;
+ }
+ fTextureSamplers[i].preConcatMatrix(inv);
+ }
}
for (int i = 0; i < kMaxMasks; ++i) {
- fMaskSamplers[i].preConcatMatrix(matrix);
+ if (this->isMaskStageEnabled(i)) {
+ if (!computed && !matrix.invert(&inv)) {
+ return false;
+ } else {
+ computed = true;
+ }
+ fMaskSamplers[i].preConcatMatrix(inv);
+ }
}
+ return true;
}
// uninitialized
@@ -189,46 +230,6 @@ public:
fColorMatrixEnabled = false;
}
- bool hasTexture() const {
- return 0 != this->getActiveTextureStageMask();
- }
-
- bool hasMask() const {
- return 0 != this->getActiveMaskStageMask();
- }
-
- bool hasTextureOrMask() const {
- return this->hasTexture() || this->hasMask();
- }
-
- // helpers for GrContext, GrTextContext
- int getActiveTextureStageMask() const {
- int mask = 0;
- for (int i = 0; i < kMaxTextures; ++i) {
- if ((NULL != fTextures[i]) ||
- (NULL != fTextureSamplers[i].getCustomStage())) {
- mask |= 1 << (i + kFirstTextureStage);
- }
- }
- return mask;
- }
-
- int getActiveMaskStageMask() const {
- int mask = 0;
- for (int i = 0; i < kMaxMasks; ++i) {
- if ((NULL != fMaskTextures[i]) ||
- (NULL != fMaskSamplers[i].getCustomStage())) {
- mask |= 1 << (i + kFirstMaskStage);
- }
- }
- return mask;
- }
-
- int getActiveStageMask() const {
- return this->getActiveTextureStageMask() |
- this->getActiveMaskStageMask();
- }
-
// internal use
// GrPaint's textures and masks map to the first N stages
// of GrDrawTarget in that order (textures followed by masks)