OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #include "SkSpriteBlitter.h" | 8 #include "SkSpriteBlitter.h" |
| 9 #include "SkStackAllocator.h" |
11 | 10 |
12 SkSpriteBlitter::SkSpriteBlitter(const SkBitmap& source) | 11 SkSpriteBlitter::SkSpriteBlitter(const SkBitmap& source) |
13 : fSource(&source) { | 12 : fSource(&source) { |
14 fSource->lockPixels(); | 13 fSource->lockPixels(); |
15 } | 14 } |
16 | 15 |
17 SkSpriteBlitter::~SkSpriteBlitter() { | 16 SkSpriteBlitter::~SkSpriteBlitter() { |
18 fSource->unlockPixels(); | 17 fSource->unlockPixels(); |
19 } | 18 } |
20 | 19 |
(...skipping 21 matching lines...) Expand all Loading... |
42 | 41 |
43 void SkSpriteBlitter::blitMask(const SkMask&, const SkIRect& clip) { | 42 void SkSpriteBlitter::blitMask(const SkMask&, const SkIRect& clip) { |
44 SkDEBUGFAIL("how did we get here?"); | 43 SkDEBUGFAIL("how did we get here?"); |
45 } | 44 } |
46 #endif | 45 #endif |
47 | 46 |
48 /////////////////////////////////////////////////////////////////////////////// | 47 /////////////////////////////////////////////////////////////////////////////// |
49 | 48 |
50 // returning null means the caller will call SkBlitter::Choose() and | 49 // returning null means the caller will call SkBlitter::Choose() and |
51 // have wrapped the source bitmap inside a shader | 50 // have wrapped the source bitmap inside a shader |
52 SkBlitter* SkBlitter::ChooseSprite( const SkBitmap& device, | 51 SkBlitter* SkBlitter::ChooseSprite(const SkBitmap& device, const SkPaint& paint, |
53 const SkPaint& paint, | 52 const SkBitmap& source, int left, int top, |
54 const SkBitmap& source, | 53 SkStackAllocator<kBlitterStorageByteCount>* allocator) { |
55 int left, int top, | |
56 void* storage, size_t storageSize) { | |
57 /* We currently ignore antialiasing and filtertype, meaning we will take ou
r | 54 /* We currently ignore antialiasing and filtertype, meaning we will take ou
r |
58 special blitters regardless of these settings. Ignoring filtertype seems
fine | 55 special blitters regardless of these settings. Ignoring filtertype seems
fine |
59 since by definition there is no scale in the matrix. Ignoring antialiasi
ng is | 56 since by definition there is no scale in the matrix. Ignoring antialiasi
ng is |
60 a bit of a hack, since we "could" pass in the fractional left/top for th
e bitmap, | 57 a bit of a hack, since we "could" pass in the fractional left/top for th
e bitmap, |
61 and respect that by blending the edges of the bitmap against the device.
To support | 58 and respect that by blending the edges of the bitmap against the device.
To support |
62 this we could either add more special blitters here, or detect antialias
ing in the | 59 this we could either add more special blitters here, or detect antialias
ing in the |
63 paint and return null if it is set, forcing the client to take the slow
shader case | 60 paint and return null if it is set, forcing the client to take the slow
shader case |
64 (which does respect soft edges). | 61 (which does respect soft edges). |
65 */ | 62 */ |
| 63 SkASSERT(allocator != NULL); |
66 | 64 |
67 SkSpriteBlitter* blitter; | 65 SkSpriteBlitter* blitter; |
68 | 66 |
69 switch (device.colorType()) { | 67 switch (device.colorType()) { |
70 case kRGB_565_SkColorType: | 68 case kRGB_565_SkColorType: |
71 blitter = SkSpriteBlitter::ChooseD16(source, paint, storage, | 69 blitter = SkSpriteBlitter::ChooseD16(source, paint, allocator); |
72 storageSize); | |
73 break; | 70 break; |
74 case kPMColor_SkColorType: | 71 case kPMColor_SkColorType: |
75 blitter = SkSpriteBlitter::ChooseD32(source, paint, storage, | 72 blitter = SkSpriteBlitter::ChooseD32(source, paint, allocator); |
76 storageSize); | |
77 break; | 73 break; |
78 default: | 74 default: |
79 blitter = NULL; | 75 blitter = NULL; |
80 break; | 76 break; |
81 } | 77 } |
82 | 78 |
83 if (blitter) { | 79 if (blitter) { |
84 blitter->setup(device, left, top, paint); | 80 blitter->setup(device, left, top, paint); |
85 } | 81 } |
86 return blitter; | 82 return blitter; |
87 } | 83 } |
OLD | NEW |