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

Unified Diff: src/effects/SkTransparentShader.cpp

Issue 249643002: Revert of Extract most of the mutable state of SkShader into a separate Context object. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/SkPerlinNoiseShader.cpp ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkTransparentShader.cpp
diff --git a/src/effects/SkTransparentShader.cpp b/src/effects/SkTransparentShader.cpp
index 0997e620137024e512dd2d3b33237efc5a8f5742..bd8b99a3c06e1aa1d3fb632d286619e750c33d69 100644
--- a/src/effects/SkTransparentShader.cpp
+++ b/src/effects/SkTransparentShader.cpp
@@ -11,40 +11,26 @@
#include "SkColorPriv.h"
#include "SkString.h"
-SkShader::Context* SkTransparentShader::createContext(const SkBitmap& device,
- const SkPaint& paint,
- const SkMatrix& matrix,
- void* storage) const {
- if (!this->validContext(device, paint, matrix)) {
- return NULL;
- }
+bool SkTransparentShader::setContext(const SkBitmap& device,
+ const SkPaint& paint,
+ const SkMatrix& matrix) {
+ fDevice = &device;
+ fAlpha = paint.getAlpha();
- return SkNEW_PLACEMENT_ARGS(storage, TransparentShaderContext, (*this, device, paint, matrix));
+ return this->INHERITED::setContext(device, paint, matrix);
}
-size_t SkTransparentShader::contextSize() const {
- return sizeof(TransparentShaderContext);
-}
-
-SkTransparentShader::TransparentShaderContext::TransparentShaderContext(
- const SkTransparentShader& shader, const SkBitmap& device,
- const SkPaint& paint, const SkMatrix& matrix)
- : INHERITED(shader, device, paint, matrix)
- , fDevice(&device) {}
-
-SkTransparentShader::TransparentShaderContext::~TransparentShaderContext() {}
-
-uint32_t SkTransparentShader::TransparentShaderContext::getFlags() const {
+uint32_t SkTransparentShader::getFlags() {
uint32_t flags = this->INHERITED::getFlags();
switch (fDevice->colorType()) {
case kRGB_565_SkColorType:
flags |= kHasSpan16_Flag;
- if (this->getPaintAlpha() == 255)
+ if (fAlpha == 255)
flags |= kOpaqueAlpha_Flag;
break;
case kN32_SkColorType:
- if (this->getPaintAlpha() == 255 && fDevice->isOpaque())
+ if (fAlpha == 255 && fDevice->isOpaque())
flags |= kOpaqueAlpha_Flag;
break;
default:
@@ -53,9 +39,8 @@
return flags;
}
-void SkTransparentShader::TransparentShaderContext::shadeSpan(int x, int y, SkPMColor span[],
- int count) {
- unsigned scale = SkAlpha255To256(this->getPaintAlpha());
+void SkTransparentShader::shadeSpan(int x, int y, SkPMColor span[], int count) {
+ unsigned scale = SkAlpha255To256(fAlpha);
switch (fDevice->colorType()) {
case kN32_SkColorType:
@@ -78,7 +63,7 @@
span[i] = SkPixel16ToPixel32(src[i]);
}
} else {
- unsigned alpha = this->getPaintAlpha();
+ unsigned alpha = fAlpha;
for (int i = count - 1; i >= 0; --i) {
uint16_t c = src[i];
unsigned r = SkPacked16ToR32(c);
@@ -112,8 +97,7 @@
}
}
-void SkTransparentShader::TransparentShaderContext::shadeSpan16(int x, int y, uint16_t span[],
- int count) {
+void SkTransparentShader::shadeSpan16(int x, int y, uint16_t span[], int count) {
SkASSERT(fDevice->colorType() == kRGB_565_SkColorType);
uint16_t* src = fDevice->getAddr16(x, y);
« no previous file with comments | « src/effects/SkPerlinNoiseShader.cpp ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698