| 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 "SkSmallAllocator.h" | 8 #include "SkSmallAllocator.h" |
| 9 #include "SkSpriteBlitter.h" | 9 #include "SkSpriteBlitter.h" |
| 10 | 10 |
| 11 SkSpriteBlitter::SkSpriteBlitter(const SkPixmap& source) : fSource(source) {} | 11 SkSpriteBlitter::SkSpriteBlitter(const SkPixmap& source) : fSource(source) {} |
| 12 | 12 |
| 13 void SkSpriteBlitter::setup(const SkBitmap& device, int left, int top, const SkP
aint& paint) { | 13 void SkSpriteBlitter::setup(const SkPixmap& dst, int left, int top, const SkPain
t& paint) { |
| 14 fDevice = &device; | 14 fDst = dst; |
| 15 fLeft = left; | 15 fLeft = left; |
| 16 fTop = top; | 16 fTop = top; |
| 17 fPaint = &paint; | 17 fPaint = &paint; |
| 18 } | 18 } |
| 19 | 19 |
| 20 #ifdef SK_DEBUG | 20 #ifdef SK_DEBUG |
| 21 void SkSpriteBlitter::blitH(int x, int y, int width) { | 21 void SkSpriteBlitter::blitH(int x, int y, int width) { |
| 22 SkDEBUGFAIL("how did we get here?"); | 22 SkDEBUGFAIL("how did we get here?"); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void SkSpriteBlitter::blitAntiH(int x, int y, const SkAlpha antialias[], | 25 void SkSpriteBlitter::blitAntiH(int x, int y, const SkAlpha antialias[], |
| 26 const int16_t runs[]) { | 26 const int16_t runs[]) { |
| 27 SkDEBUGFAIL("how did we get here?"); | 27 SkDEBUGFAIL("how did we get here?"); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void SkSpriteBlitter::blitV(int x, int y, int height, SkAlpha alpha) { | 30 void SkSpriteBlitter::blitV(int x, int y, int height, SkAlpha alpha) { |
| 31 SkDEBUGFAIL("how did we get here?"); | 31 SkDEBUGFAIL("how did we get here?"); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void SkSpriteBlitter::blitMask(const SkMask&, const SkIRect& clip) { | 34 void SkSpriteBlitter::blitMask(const SkMask&, const SkIRect& clip) { |
| 35 SkDEBUGFAIL("how did we get here?"); | 35 SkDEBUGFAIL("how did we get here?"); |
| 36 } | 36 } |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 /////////////////////////////////////////////////////////////////////////////// | 39 /////////////////////////////////////////////////////////////////////////////// |
| 40 | 40 |
| 41 // returning null means the caller will call SkBlitter::Choose() and | 41 // returning null means the caller will call SkBlitter::Choose() and |
| 42 // have wrapped the source bitmap inside a shader | 42 // have wrapped the source bitmap inside a shader |
| 43 SkBlitter* SkBlitter::ChooseSprite(const SkBitmap& device, const SkPaint& paint, | 43 SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint, |
| 44 const SkPixmap& source, int left, int top, SkTBlitterAllocator* allocato
r) { | 44 const SkPixmap& source, int left, int top, SkTBlitterAllocator* allocato
r) { |
| 45 /* We currently ignore antialiasing and filtertype, meaning we will take ou
r | 45 /* We currently ignore antialiasing and filtertype, meaning we will take ou
r |
| 46 special blitters regardless of these settings. Ignoring filtertype seems
fine | 46 special blitters regardless of these settings. Ignoring filtertype seems
fine |
| 47 since by definition there is no scale in the matrix. Ignoring antialiasi
ng is | 47 since by definition there is no scale in the matrix. Ignoring antialiasi
ng is |
| 48 a bit of a hack, since we "could" pass in the fractional left/top for th
e bitmap, | 48 a bit of a hack, since we "could" pass in the fractional left/top for th
e bitmap, |
| 49 and respect that by blending the edges of the bitmap against the device.
To support | 49 and respect that by blending the edges of the bitmap against the device.
To support |
| 50 this we could either add more special blitters here, or detect antialias
ing in the | 50 this we could either add more special blitters here, or detect antialias
ing in the |
| 51 paint and return null if it is set, forcing the client to take the slow
shader case | 51 paint and return null if it is set, forcing the client to take the slow
shader case |
| 52 (which does respect soft edges). | 52 (which does respect soft edges). |
| 53 */ | 53 */ |
| 54 SkASSERT(allocator != NULL); | 54 SkASSERT(allocator != NULL); |
| 55 | 55 |
| 56 SkSpriteBlitter* blitter; | 56 SkSpriteBlitter* blitter; |
| 57 | 57 |
| 58 switch (device.colorType()) { | 58 switch (dst.colorType()) { |
| 59 case kRGB_565_SkColorType: | 59 case kRGB_565_SkColorType: |
| 60 blitter = SkSpriteBlitter::ChooseD16(source, paint, allocator); | 60 blitter = SkSpriteBlitter::ChooseD16(source, paint, allocator); |
| 61 break; | 61 break; |
| 62 case kN32_SkColorType: | 62 case kN32_SkColorType: |
| 63 blitter = SkSpriteBlitter::ChooseD32(source, paint, allocator); | 63 blitter = SkSpriteBlitter::ChooseD32(source, paint, allocator); |
| 64 break; | 64 break; |
| 65 default: | 65 default: |
| 66 blitter = NULL; | 66 blitter = NULL; |
| 67 break; | 67 break; |
| 68 } | 68 } |
| 69 | 69 |
| 70 if (blitter) { | 70 if (blitter) { |
| 71 blitter->setup(device, left, top, paint); | 71 blitter->setup(dst, left, top, paint); |
| 72 } | 72 } |
| 73 return blitter; | 73 return blitter; |
| 74 } | 74 } |
| OLD | NEW |