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

Unified Diff: src/core/SkBitmapProcShader.cpp

Issue 264843006: create struct to hold all the params passed around for shader::context (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address review comments 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/core/SkBitmapProcShader.h ('k') | src/core/SkBlitter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapProcShader.cpp
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index 44bdc6d348e7f3af6505bceb87f3f38a22812c8b..46cf7db136d93e8bd2391d134d17e009a666c706 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -97,10 +97,7 @@ static bool valid_for_drawing(const SkBitmap& bm) {
return true;
}
-bool SkBitmapProcShader::validInternal(const SkBitmap& device,
- const SkPaint& paint,
- const SkMatrix& matrix,
- SkMatrix* totalInverse,
+bool SkBitmapProcShader::validInternal(const ContextRec& rec, SkMatrix* totalInverse,
SkBitmapProcState* state) const {
if (!fRawBitmap.getTexture() && !valid_for_drawing(fRawBitmap)) {
return false;
@@ -113,7 +110,7 @@ bool SkBitmapProcShader::validInternal(const SkBitmap& device,
}
// Do this first, so we know the matrix can be inverted.
- if (!this->INHERITED::validContext(device, paint, matrix, totalInverse)) {
+ if (!this->INHERITED::validContext(rec, totalInverse)) {
return false;
}
@@ -121,28 +118,23 @@ bool SkBitmapProcShader::validInternal(const SkBitmap& device,
state->fTileModeX = fTileModeX;
state->fTileModeY = fTileModeY;
state->fOrigBitmap = fRawBitmap;
- return state->chooseProcs(*totalInverse, paint);
+ return state->chooseProcs(*totalInverse, *rec.fPaint);
}
-bool SkBitmapProcShader::validContext(const SkBitmap& device,
- const SkPaint& paint,
- const SkMatrix& matrix,
- SkMatrix* totalInverse) const {
+bool SkBitmapProcShader::validContext(const ContextRec& rec, SkMatrix* totalInverse) const {
SkBitmapProcState state;
- return this->validInternal(device, paint, matrix, totalInverse, &state);
+ return this->validInternal(rec, totalInverse, &state);
}
-SkShader::Context* SkBitmapProcShader::createContext(const SkBitmap& device, const SkPaint& paint,
- const SkMatrix& matrix, void* storage) const {
+SkShader::Context* SkBitmapProcShader::createContext(const ContextRec& rec, void* storage) const {
void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext);
SkBitmapProcState* state = SkNEW_PLACEMENT(stateStorage, SkBitmapProcState);
- if (!this->validInternal(device, paint, matrix, NULL, state)) {
+ if (!this->validInternal(rec, NULL, state)) {
state->~SkBitmapProcState();
return NULL;
}
- return SkNEW_PLACEMENT_ARGS(storage, BitmapProcShaderContext,
- (*this, device, paint, matrix, state));
+ return SkNEW_PLACEMENT_ARGS(storage, BitmapProcShaderContext, (*this, rec, state));
}
size_t SkBitmapProcShader::contextSize() const {
@@ -152,9 +144,8 @@ size_t SkBitmapProcShader::contextSize() const {
}
SkBitmapProcShader::BitmapProcShaderContext::BitmapProcShaderContext(
- const SkBitmapProcShader& shader, const SkBitmap& device,
- const SkPaint& paint, const SkMatrix& matrix, SkBitmapProcState* state)
- : INHERITED(shader, device, paint, matrix)
+ const SkBitmapProcShader& shader, const ContextRec& rec, SkBitmapProcState* state)
+ : INHERITED(shader, rec)
, fState(state)
{
const SkBitmap& bitmap = *fState->fBitmap;
@@ -182,7 +173,7 @@ SkBitmapProcShader::BitmapProcShaderContext::BitmapProcShaderContext(
break;
}
- if (paint.isDither() && bitmap.colorType() != kRGB_565_SkColorType) {
+ if (rec.fPaint->isDither() && bitmap.colorType() != kRGB_565_SkColorType) {
// gradients can auto-dither in their 16bit sampler, but we don't so
// we clear the flag here.
flags &= ~kHasSpan16_Flag;
« no previous file with comments | « src/core/SkBitmapProcShader.h ('k') | src/core/SkBlitter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698