| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 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 | 8 |
| 9 | 9 |
| 10 #include "SkBitmapSampler.h" | 10 #include "SkBitmapSampler.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 283 |
| 284 private: | 284 private: |
| 285 const SkFilterProc* fProcTable; | 285 const SkFilterProc* fProcTable; |
| 286 SkPMColor fColor; | 286 SkPMColor fColor; |
| 287 }; | 287 }; |
| 288 | 288 |
| 289 class A8_NoFilter_Sampler : public SkBitmapSampler { | 289 class A8_NoFilter_Sampler : public SkBitmapSampler { |
| 290 public: | 290 public: |
| 291 A8_NoFilter_Sampler(const SkBitmap& bm, SkShader::TileMode tmx, SkShader::Ti
leMode tmy) | 291 A8_NoFilter_Sampler(const SkBitmap& bm, SkShader::TileMode tmx, SkShader::Ti
leMode tmy) |
| 292 : SkBitmapSampler(bm, false, tmx, tmy) | 292 : SkBitmapSampler(bm, false, tmx, tmy) |
| 293 , fProcTable(NULL) | |
| 294 { | 293 { |
| 295 } | 294 } |
| 296 | 295 |
| 297 virtual void setPaint(const SkPaint& paint) | 296 virtual void setPaint(const SkPaint& paint) |
| 298 { | 297 { |
| 299 fColor = SkPreMultiplyColor(paint.getColor()); | 298 fColor = SkPreMultiplyColor(paint.getColor()); |
| 300 } | 299 } |
| 301 | 300 |
| 302 virtual SkPMColor sample(SkFixed x, SkFixed y) const | 301 virtual SkPMColor sample(SkFixed x, SkFixed y) const |
| 303 { | 302 { |
| 304 int ix = SkFixedFloor(x); | 303 int ix = SkFixedFloor(x); |
| 305 int iy = SkFixedFloor(y); | 304 int iy = SkFixedFloor(y); |
| 306 | 305 |
| 307 int alpha = *fBitmap.getAddr8(fTileProcX(ix, fMaxX), fTileProcY(iy, fMax
Y)); | 306 int alpha = *fBitmap.getAddr8(fTileProcX(ix, fMaxX), fTileProcY(iy, fMax
Y)); |
| 308 return SkAlphaMulQ(fColor, SkAlpha255To256(alpha)); | 307 return SkAlphaMulQ(fColor, SkAlpha255To256(alpha)); |
| 309 } | 308 } |
| 310 | 309 |
| 311 private: | 310 private: |
| 312 const SkFilterProc* fProcTable; | |
| 313 SkPMColor fColor; | 311 SkPMColor fColor; |
| 314 }; | 312 }; |
| 315 | 313 |
| 316 /////////////////////////////////////////////////////////////////////////////// | 314 /////////////////////////////////////////////////////////////////////////////// |
| 317 /////////////////////////////////////////////////////////////////////////////// | 315 /////////////////////////////////////////////////////////////////////////////// |
| 318 | 316 |
| 319 SkBitmapSampler* SkBitmapSampler::Create(const SkBitmap& bm, bool doFilter, | 317 SkBitmapSampler* SkBitmapSampler::Create(const SkBitmap& bm, bool doFilter, |
| 320 SkShader::TileMode tmx, | 318 SkShader::TileMode tmx, |
| 321 SkShader::TileMode tmy) | 319 SkShader::TileMode tmy) |
| 322 { | 320 { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 return SkNEW_ARGS(A8_Bilinear_Sampler, (bm, tmx, tmy)); | 405 return SkNEW_ARGS(A8_Bilinear_Sampler, (bm, tmx, tmy)); |
| 408 else | 406 else |
| 409 return SkNEW_ARGS(A8_NoFilter_Sampler, (bm, tmx, tmy)); | 407 return SkNEW_ARGS(A8_NoFilter_Sampler, (bm, tmx, tmy)); |
| 410 break; | 408 break; |
| 411 | 409 |
| 412 default: | 410 default: |
| 413 SkDEBUGFAIL("unknown device"); | 411 SkDEBUGFAIL("unknown device"); |
| 414 } | 412 } |
| 415 return SkNEW_ARGS(SkNullBitmapSampler, (bm, doFilter, tmx, tmy)); | 413 return SkNEW_ARGS(SkNullBitmapSampler, (bm, doFilter, tmx, tmy)); |
| 416 } | 414 } |
| OLD | NEW |