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

Side by Side Diff: src/core/SkBitmapProcShader.cpp

Issue 267923005: remove unneeded SkShader::validContext (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkColorPriv.h" 8 #include "SkColorPriv.h"
9 #include "SkReadBuffer.h" 9 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h" 10 #include "SkWriteBuffer.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if (kIndex_8_SkColorType == bm.colorType()) { 90 if (kIndex_8_SkColorType == bm.colorType()) {
91 // ugh, I have to lock-pixels to inspect the colortable 91 // ugh, I have to lock-pixels to inspect the colortable
92 SkAutoLockPixels alp(bm); 92 SkAutoLockPixels alp(bm);
93 if (!bm.getColorTable()) { 93 if (!bm.getColorTable()) {
94 return false; 94 return false;
95 } 95 }
96 } 96 }
97 return true; 97 return true;
98 } 98 }
99 99
100 bool SkBitmapProcShader::validInternal(const ContextRec& rec, SkMatrix* totalInv erse, 100 SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, vo id* storage) const {
101 SkBitmapProcState* state) const { 101 void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext);
102 SkBitmapProcState* state = SkNEW_PLACEMENT(stateStorage, SkBitmapProcState);
103
102 if (!fRawBitmap.getTexture() && !valid_for_drawing(fRawBitmap)) { 104 if (!fRawBitmap.getTexture() && !valid_for_drawing(fRawBitmap)) {
103 return false; 105 return NULL;
scroggo 2014/05/05 14:01:19 Don't we need to call SkBitmapProcState's destruct
reed1 2014/05/05 15:10:01 Rearranged to fix this.
104 } 106 }
105 107
106 // Make sure we can use totalInverse as a cache. 108 // Make sure we can use totalInverse as a cache.
scroggo 2014/05/05 14:01:19 This comment no longer applies.
reed1 2014/05/05 15:10:01 Done.
107 SkMatrix totalInverseLocal; 109 SkMatrix totalInverse;
108 if (NULL == totalInverse) { 110 // Do this first, so we know the matrix can be inverted.
109 totalInverse = &totalInverseLocal; 111 if (!this->computeTotalInverse(rec, &totalInverse)) {
112 return NULL;
110 } 113 }
111 114
112 // Do this first, so we know the matrix can be inverted.
113 if (!this->INHERITED::validContext(rec, totalInverse)) {
114 return false;
115 }
116
117 SkASSERT(state); 115 SkASSERT(state);
118 state->fTileModeX = fTileModeX; 116 state->fTileModeX = fTileModeX;
119 state->fTileModeY = fTileModeY; 117 state->fTileModeY = fTileModeY;
120 state->fOrigBitmap = fRawBitmap; 118 state->fOrigBitmap = fRawBitmap;
121 return state->chooseProcs(*totalInverse, *rec.fPaint); 119 if (!state->chooseProcs(totalInverse, *rec.fPaint)) {
122 }
123
124 bool SkBitmapProcShader::validContext(const ContextRec& rec, SkMatrix* totalInve rse) const {
125 SkBitmapProcState state;
126 return this->validInternal(rec, totalInverse, &state);
127 }
128
129 SkShader::Context* SkBitmapProcShader::createContext(const ContextRec& rec, void * storage) const {
130 void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext);
131 SkBitmapProcState* state = SkNEW_PLACEMENT(stateStorage, SkBitmapProcState);
132 if (!this->validInternal(rec, NULL, state)) {
133 state->~SkBitmapProcState(); 120 state->~SkBitmapProcState();
134 return NULL; 121 return NULL;
135 } 122 }
136 123
137 return SkNEW_PLACEMENT_ARGS(storage, BitmapProcShaderContext, (*this, rec, s tate)); 124 return SkNEW_PLACEMENT_ARGS(storage, BitmapProcShaderContext, (*this, rec, s tate));
138 } 125 }
139 126
140 size_t SkBitmapProcShader::contextSize() const { 127 size_t SkBitmapProcShader::contextSize() const {
141 // The SkBitmapProcState is stored outside of the context object, with the c ontext holding 128 // The SkBitmapProcState is stored outside of the context object, with the c ontext holding
142 // a pointer to it. 129 // a pointer to it.
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 GrEffectRef* effect = NULL; 465 GrEffectRef* effect = NULL;
479 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) { 466 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) {
480 effect = GrBicubicEffect::Create(texture, matrix, tm); 467 effect = GrBicubicEffect::Create(texture, matrix, tm);
481 } else { 468 } else {
482 effect = GrSimpleTextureEffect::Create(texture, matrix, params); 469 effect = GrSimpleTextureEffect::Create(texture, matrix, params);
483 } 470 }
484 GrUnlockAndUnrefCachedBitmapTexture(texture); 471 GrUnlockAndUnrefCachedBitmapTexture(texture);
485 return effect; 472 return effect;
486 } 473 }
487 #endif 474 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698