| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 "SkAtomics.h" | 8 #include "SkAtomics.h" |
| 9 #include "SkBitmapProcShader.h" | 9 #include "SkBitmapProcShader.h" |
| 10 #include "SkColorShader.h" | 10 #include "SkColorShader.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 bool SkShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&,
const SkMatrix*, | 217 bool SkShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&,
const SkMatrix*, |
| 218 GrColor*, GrProcessorDataManager*, | 218 GrColor*, GrProcessorDataManager*, |
| 219 GrFragmentProcessor**) const { | 219 GrFragmentProcessor**) const { |
| 220 return false; | 220 return false; |
| 221 } | 221 } |
| 222 | 222 |
| 223 SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const { | 223 SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const { |
| 224 return NULL; | 224 return NULL; |
| 225 } | 225 } |
| 226 | 226 |
| 227 SkShader* SkShader::CreateEmptyShader() { | 227 SkShader* SkShader::CreateEmptyShader() { return new SkEmptyShader; } |
| 228 return SkNEW(SkEmptyShader); | |
| 229 } | |
| 230 | 228 |
| 231 SkShader* SkShader::CreateColorShader(SkColor color) { | 229 SkShader* SkShader::CreateColorShader(SkColor color) { return new SkColorShader(
color); } |
| 232 return SkNEW_ARGS(SkColorShader, (color)); | |
| 233 } | |
| 234 | 230 |
| 235 SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMo
de tmy, | 231 SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMo
de tmy, |
| 236 const SkMatrix* localMatrix) { | 232 const SkMatrix* localMatrix) { |
| 237 return SkCreateBitmapShader(src, tmx, tmy, localMatrix, NULL); | 233 return SkCreateBitmapShader(src, tmx, tmy, localMatrix, NULL); |
| 238 } | 234 } |
| 239 | 235 |
| 240 SkShader* SkShader::CreatePictureShader(const SkPicture* src, TileMode tmx, Tile
Mode tmy, | 236 SkShader* SkShader::CreatePictureShader(const SkPicture* src, TileMode tmx, Tile
Mode tmy, |
| 241 const SkMatrix* localMatrix, const SkRec
t* tile) { | 237 const SkMatrix* localMatrix, const SkRec
t* tile) { |
| 242 return SkPictureShader::Create(src, tmx, tmy, localMatrix, tile); | 238 return SkPictureShader::Create(src, tmx, tmy, localMatrix, tile); |
| 243 } | 239 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 257 | 253 |
| 258 SkColorShader::SkColorShader(SkColor c) | 254 SkColorShader::SkColorShader(SkColor c) |
| 259 : fColor(c) { | 255 : fColor(c) { |
| 260 } | 256 } |
| 261 | 257 |
| 262 bool SkColorShader::isOpaque() const { | 258 bool SkColorShader::isOpaque() const { |
| 263 return SkColorGetA(fColor) == 255; | 259 return SkColorGetA(fColor) == 255; |
| 264 } | 260 } |
| 265 | 261 |
| 266 SkFlattenable* SkColorShader::CreateProc(SkReadBuffer& buffer) { | 262 SkFlattenable* SkColorShader::CreateProc(SkReadBuffer& buffer) { |
| 267 return SkNEW_ARGS(SkColorShader, (buffer.readColor())); | 263 return new SkColorShader(buffer.readColor()); |
| 268 } | 264 } |
| 269 | 265 |
| 270 void SkColorShader::flatten(SkWriteBuffer& buffer) const { | 266 void SkColorShader::flatten(SkWriteBuffer& buffer) const { |
| 271 buffer.writeColor(fColor); | 267 buffer.writeColor(fColor); |
| 272 } | 268 } |
| 273 | 269 |
| 274 uint32_t SkColorShader::ColorShaderContext::getFlags() const { | 270 uint32_t SkColorShader::ColorShaderContext::getFlags() const { |
| 275 return fFlags; | 271 return fFlags; |
| 276 } | 272 } |
| 277 | 273 |
| 278 uint8_t SkColorShader::ColorShaderContext::getSpan16Alpha() const { | 274 uint8_t SkColorShader::ColorShaderContext::getSpan16Alpha() const { |
| 279 return SkGetPackedA32(fPMColor); | 275 return SkGetPackedA32(fPMColor); |
| 280 } | 276 } |
| 281 | 277 |
| 282 SkShader::Context* SkColorShader::onCreateContext(const ContextRec& rec, void* s
torage) const { | 278 SkShader::Context* SkColorShader::onCreateContext(const ContextRec& rec, void* s
torage) const { |
| 283 return SkNEW_PLACEMENT_ARGS(storage, ColorShaderContext, (*this, rec)); | 279 return new (storage) ColorShaderContext(*this, rec); |
| 284 } | 280 } |
| 285 | 281 |
| 286 SkColorShader::ColorShaderContext::ColorShaderContext(const SkColorShader& shade
r, | 282 SkColorShader::ColorShaderContext::ColorShaderContext(const SkColorShader& shade
r, |
| 287 const ContextRec& rec) | 283 const ContextRec& rec) |
| 288 : INHERITED(shader, rec) | 284 : INHERITED(shader, rec) |
| 289 { | 285 { |
| 290 SkColor color = shader.fColor; | 286 SkColor color = shader.fColor; |
| 291 unsigned a = SkAlphaMul(SkColorGetA(color), SkAlpha255To256(rec.fPaint->getA
lpha())); | 287 unsigned a = SkAlphaMul(SkColorGetA(color), SkAlpha255To256(rec.fPaint->getA
lpha())); |
| 292 | 288 |
| 293 unsigned r = SkColorGetR(color); | 289 unsigned r = SkColorGetR(color); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 #include "SkEmptyShader.h" | 380 #include "SkEmptyShader.h" |
| 385 | 381 |
| 386 void SkEmptyShader::toString(SkString* str) const { | 382 void SkEmptyShader::toString(SkString* str) const { |
| 387 str->append("SkEmptyShader: ("); | 383 str->append("SkEmptyShader: ("); |
| 388 | 384 |
| 389 this->INHERITED::toString(str); | 385 this->INHERITED::toString(str); |
| 390 | 386 |
| 391 str->append(")"); | 387 str->append(")"); |
| 392 } | 388 } |
| 393 #endif | 389 #endif |
| OLD | NEW |