OLD | NEW |
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 bool needsSwizzle = srcInfo.bytesPerPixel() == 4 && srcInfo.colorType() != k
N32_SkColorType; | 198 bool needsSwizzle = srcInfo.bytesPerPixel() == 4 && srcInfo.colorType() != k
N32_SkColorType; |
199 return SkShader::ContextRec::kPM4f_DstType == rec.fPreferredDstType | 199 return SkShader::ContextRec::kPM4f_DstType == rec.fPreferredDstType |
200 || needsPremul || needsSwizzle; | 200 || needsPremul || needsSwizzle; |
201 } | 201 } |
202 | 202 |
203 size_t SkBitmapProcLegacyShader::ContextSize(const ContextRec& rec, const SkImag
eInfo& srcInfo) { | 203 size_t SkBitmapProcLegacyShader::ContextSize(const ContextRec& rec, const SkImag
eInfo& srcInfo) { |
204 size_t size0 = sizeof(BitmapProcShaderContext) + sizeof(SkBitmapProcState); | 204 size_t size0 = sizeof(BitmapProcShaderContext) + sizeof(SkBitmapProcState); |
205 size_t size1 = sizeof(LinearPipelineContext) + sizeof(SkBitmapProcInfo); | 205 size_t size1 = sizeof(LinearPipelineContext) + sizeof(SkBitmapProcInfo); |
206 size_t s = SkTMax(size0, size1); | 206 size_t s = SkTMax(size0, size1); |
207 return s; | 207 return s; |
208 return SkTMax(size0, size1); | |
209 } | 208 } |
210 | 209 |
211 SkShader::Context* SkBitmapProcLegacyShader::MakeContext(const SkShader& shader, | 210 SkShader::Context* SkBitmapProcLegacyShader::MakeContext(const SkShader& shader, |
212 TileMode tmx, TileMode tmy, | 211 TileMode tmx, TileMode tmy, |
213 const SkBitmapProvider& provi
der, | 212 const SkBitmapProvider& provi
der, |
214 const ContextRec& rec, void*
storage) { | 213 const ContextRec& rec, void*
storage) { |
215 SkMatrix totalInverse; | 214 SkMatrix totalInverse; |
216 // Do this first, so we know the matrix can be inverted. | 215 // Do this first, so we know the matrix can be inverted. |
217 if (!shader.computeTotalInverse(rec, &totalInverse)) { | 216 if (!shader.computeTotalInverse(rec, &totalInverse)) { |
218 return nullptr; | 217 return nullptr; |
(...skipping 16 matching lines...) Expand all Loading... |
235 void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext); | 234 void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext); |
236 SkBitmapProcState* state = new (stateStorage) SkBitmapProcState(provider
, tmx, tmy, | 235 SkBitmapProcState* state = new (stateStorage) SkBitmapProcState(provider
, tmx, tmy, |
237 treatmen
t); | 236 treatmen
t); |
238 if (!state->setup(totalInverse, *rec.fPaint)) { | 237 if (!state->setup(totalInverse, *rec.fPaint)) { |
239 state->~SkBitmapProcState(); | 238 state->~SkBitmapProcState(); |
240 return nullptr; | 239 return nullptr; |
241 } | 240 } |
242 return new (storage) BitmapProcShaderContext(shader, rec, state); | 241 return new (storage) BitmapProcShaderContext(shader, rec, state); |
243 } | 242 } |
244 } | 243 } |
OLD | NEW |