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

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

Issue 1530743002: Fix UB function problems for shaders and mask. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix 16-bit masks Created 5 years 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
« no previous file with comments | « include/core/SkShader.h ('k') | src/core/SkBitmapProcState.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "SkBitmapProcShader.h" 8 #include "SkBitmapProcShader.h"
9 #include "SkBitmapProcState.h" 9 #include "SkBitmapProcState.h"
10 #include "SkBitmapProvider.h" 10 #include "SkBitmapProvider.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 #define TEST_BUFFER_EXTRA 32 167 #define TEST_BUFFER_EXTRA 32
168 #define TEST_PATTERN 0x88888888 168 #define TEST_PATTERN 0x88888888
169 #else 169 #else
170 #define TEST_BUFFER_EXTRA 0 170 #define TEST_BUFFER_EXTRA 0
171 #endif 171 #endif
172 172
173 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan(int x, int y, SkPMCo lor dstC[], 173 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan(int x, int y, SkPMCo lor dstC[],
174 int count) { 174 int count) {
175 const SkBitmapProcState& state = *fState; 175 const SkBitmapProcState& state = *fState;
176 if (state.getShaderProc32()) { 176 if (state.getShaderProc32()) {
177 state.getShaderProc32()(state, x, y, dstC, count); 177 state.getShaderProc32()(&state, x, y, dstC, count);
178 return; 178 return;
179 } 179 }
180 180
181 uint32_t buffer[BUF_MAX + TEST_BUFFER_EXTRA]; 181 uint32_t buffer[BUF_MAX + TEST_BUFFER_EXTRA];
182 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); 182 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc();
183 SkBitmapProcState::SampleProc32 sproc = state.getSampleProc32(); 183 SkBitmapProcState::SampleProc32 sproc = state.getSampleProc32();
184 int max = state.maxCountForBufferSize(sizeof(buffer[0]) * BUF_MAX); 184 int max = state.maxCountForBufferSize(sizeof(buffer[0]) * BUF_MAX);
185 185
186 SkASSERT(state.fPixmap.addr()); 186 SkASSERT(state.fPixmap.addr());
187 187
(...skipping 30 matching lines...) Expand all
218 *ctx = fState; 218 *ctx = fState;
219 return (ShadeProc)fState->getShaderProc32(); 219 return (ShadeProc)fState->getShaderProc32();
220 } 220 }
221 return nullptr; 221 return nullptr;
222 } 222 }
223 223
224 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan16(int x, int y, uint 16_t dstC[], 224 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan16(int x, int y, uint 16_t dstC[],
225 int count) { 225 int count) {
226 const SkBitmapProcState& state = *fState; 226 const SkBitmapProcState& state = *fState;
227 if (state.getShaderProc16()) { 227 if (state.getShaderProc16()) {
228 state.getShaderProc16()(state, x, y, dstC, count); 228 state.getShaderProc16()(&state, x, y, dstC, count);
229 return; 229 return;
230 } 230 }
231 231
232 uint32_t buffer[BUF_MAX]; 232 uint32_t buffer[BUF_MAX];
233 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); 233 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc();
234 SkBitmapProcState::SampleProc16 sproc = state.getSampleProc16(); 234 SkBitmapProcState::SampleProc16 sproc = state.getSampleProc16();
235 int max = state.maxCountForBufferSize(sizeof(buffer)); 235 int max = state.maxCountForBufferSize(sizeof(buffer));
236 236
237 SkASSERT(state.fPixmap.addr()); 237 SkASSERT(state.fPixmap.addr());
238 238
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); 407 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params));
408 } 408 }
409 409
410 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) { 410 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) {
411 return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner); 411 return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner);
412 } 412 }
413 return GrFragmentProcessor::MulOutputByInputAlpha(inner); 413 return GrFragmentProcessor::MulOutputByInputAlpha(inner);
414 } 414 }
415 415
416 #endif 416 #endif
OLDNEW
« no previous file with comments | « include/core/SkShader.h ('k') | src/core/SkBitmapProcState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698