| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "GrDrawState.h" | 8 #include "GrDrawState.h" |
| 9 #include "GrPaint.h" | 9 #include "GrPaint.h" |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 // Enable the clip bit | 53 // Enable the clip bit |
| 54 this->enableState(GrDrawState::kClip_StateBit); | 54 this->enableState(GrDrawState::kClip_StateBit); |
| 55 | 55 |
| 56 this->setColor(paint.getColor()); | 56 this->setColor(paint.getColor()); |
| 57 this->setCoverage4(paint.getCoverage()); | 57 this->setCoverage4(paint.getCoverage()); |
| 58 this->setState(GrDrawState::kDither_StateBit, paint.isDither()); | 58 this->setState(GrDrawState::kDither_StateBit, paint.isDither()); |
| 59 this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias()); | 59 this->setState(GrDrawState::kHWAntialias_StateBit, paint.isAntiAlias()); |
| 60 | 60 |
| 61 this->setBlendFunc(paint.getSrcBlendCoeff(), paint.getDstBlendCoeff()); | 61 this->setBlendFunc(paint.getSrcBlendCoeff(), paint.getDstBlendCoeff()); |
| 62 this->setColorFilter(paint.getColorFilterColor(), paint.getColorFilterMode()
); | |
| 63 this->setCoverage(paint.getCoverage()); | 62 this->setCoverage(paint.getCoverage()); |
| 64 } | 63 } |
| 65 | 64 |
| 66 //////////////////////////////////////////////////////////////////////////////// | 65 //////////////////////////////////////////////////////////////////////////////// |
| 67 | 66 |
| 68 static size_t vertex_size(const GrVertexAttrib* attribs, int count) { | 67 static size_t vertex_size(const GrVertexAttrib* attribs, int count) { |
| 69 // this works as long as we're 4 byte-aligned | 68 // this works as long as we're 4 byte-aligned |
| 70 #ifdef SK_DEBUG | 69 #ifdef SK_DEBUG |
| 71 uint32_t overlapCheck = 0; | 70 uint32_t overlapCheck = 0; |
| 72 #endif | 71 #endif |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 validComponentFlags = kRGBA_GrColorComponentFlags; | 211 validComponentFlags = kRGBA_GrColorComponentFlags; |
| 213 color = this->getColor(); | 212 color = this->getColor(); |
| 214 } | 213 } |
| 215 | 214 |
| 216 // Run through the color stages | 215 // Run through the color stages |
| 217 for (int s = 0; s < fColorStages.count(); ++s) { | 216 for (int s = 0; s < fColorStages.count(); ++s) { |
| 218 const GrEffectRef* effect = fColorStages[s].getEffect(); | 217 const GrEffectRef* effect = fColorStages[s].getEffect(); |
| 219 (*effect)->getConstantColorComponents(&color, &validComponentFlags); | 218 (*effect)->getConstantColorComponents(&color, &validComponentFlags); |
| 220 } | 219 } |
| 221 | 220 |
| 222 // Check if the color filter could introduce an alpha. | |
| 223 // We could skip the above work when this is true, but it is rare and the ri
ght fix is to make | |
| 224 // the color filter a GrEffect and implement getConstantColorComponents() fo
r it. | |
| 225 if (SkXfermode::kDst_Mode != this->getColorFilterMode()) { | |
| 226 validComponentFlags = 0; | |
| 227 } | |
| 228 | |
| 229 // Check whether coverage is treated as color. If so we run through the cove
rage computation. | 221 // Check whether coverage is treated as color. If so we run through the cove
rage computation. |
| 230 if (this->isCoverageDrawing()) { | 222 if (this->isCoverageDrawing()) { |
| 231 GrColor coverageColor = this->getCoverage(); | 223 GrColor coverageColor = this->getCoverage(); |
| 232 GrColor oldColor = color; | 224 GrColor oldColor = color; |
| 233 color = 0; | 225 color = 0; |
| 234 for (int c = 0; c < 4; ++c) { | 226 for (int c = 0; c < 4; ++c) { |
| 235 if (validComponentFlags & (1 << c)) { | 227 if (validComponentFlags & (1 << c)) { |
| 236 U8CPU a = (oldColor >> (c * 8)) & 0xff; | 228 U8CPU a = (oldColor >> (c * 8)) & 0xff; |
| 237 U8CPU b = (coverageColor >> (c * 8)) & 0xff; | 229 U8CPU b = (coverageColor >> (c * 8)) & 0xff; |
| 238 color |= (SkMulDiv255Round(a, b) << (c * 8)); | 230 color |= (SkMulDiv255Round(a, b) << (c * 8)); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 fDrawState->fColorStages[s].saveCoordChange(&fSavedCoordChanges[i]); | 467 fDrawState->fColorStages[s].saveCoordChange(&fSavedCoordChanges[i]); |
| 476 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix); | 468 fDrawState->fColorStages[s].localCoordChange(coordChangeMatrix); |
| 477 } | 469 } |
| 478 | 470 |
| 479 int numCoverageStages = fDrawState->numCoverageStages(); | 471 int numCoverageStages = fDrawState->numCoverageStages(); |
| 480 for (int s = 0; s < numCoverageStages; ++s, ++i) { | 472 for (int s = 0; s < numCoverageStages; ++s, ++i) { |
| 481 fDrawState->fCoverageStages[s].saveCoordChange(&fSavedCoordChanges[i]); | 473 fDrawState->fCoverageStages[s].saveCoordChange(&fSavedCoordChanges[i]); |
| 482 fDrawState->fCoverageStages[s].localCoordChange(coordChangeMatrix); | 474 fDrawState->fCoverageStages[s].localCoordChange(coordChangeMatrix); |
| 483 } | 475 } |
| 484 } | 476 } |
| OLD | NEW |