OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "picture_utils.h" | 8 #include "picture_utils.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
11 #include "SkPicture.h" | 11 #include "SkPicture.h" |
12 #include "SkString.h" | 12 #include "SkString.h" |
13 #include "SkStream.h" | 13 #include "SkStream.h" |
14 | 14 |
15 namespace sk_tools { | 15 namespace sk_tools { |
16 void force_all_opaque(const SkBitmap& bitmap) { | 16 void force_all_opaque(const SkBitmap& bitmap) { |
17 SkASSERT(NULL == bitmap.getTexture()); | 17 SkASSERT(NULL == bitmap.getTexture()); |
18 SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config()); | 18 if (NULL != bitmap.getTexture()) { |
19 if (NULL != bitmap.getTexture() || SkBitmap::kARGB_8888_Config == bitmap .config()) { | |
20 return; | 19 return; |
21 } | 20 } |
22 | 21 |
23 SkAutoLockPixels lock(bitmap); | 22 SkBitmap bitmap8888; |
24 for (int y = 0; y < bitmap.height(); y++) { | 23 const SkBitmap* bmPtr; |
25 for (int x = 0; x < bitmap.width(); x++) { | 24 if (SkBitmap::kARGB_8888_Config == bitmap.config()) { |
epoger
2013/04/19 21:35:16
Do non-8888 configs even allow for alpha channel v
scroggo
2013/04/19 22:12:01
I think kIndex8 does. And we can get kIndex8 from
| |
26 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); | 25 bmPtr = &bitmap; |
26 } else { | |
27 bitmap.copyTo(&bitmap8888, SkBitmap::kARGB_8888_Config); | |
28 bmPtr = &bitmap8888; | |
epoger
2013/04/19 21:35:16
In this case, are this method's modifications even
scroggo
2013/04/19 22:12:01
D'oh! No the modifications are not :(
scroggo
2013/04/22 22:10:15
Rather than modify this function further, so it wi
| |
29 } | |
30 | |
31 SkAutoLockPixels lock(*bmPtr); | |
32 for (int y = 0; y < bmPtr->height(); y++) { | |
33 for (int x = 0; x < bmPtr->width(); x++) { | |
34 *bmPtr->getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); | |
27 } | 35 } |
28 } | 36 } |
29 } | 37 } |
30 | 38 |
31 void make_filepath(SkString* path, const SkString& dir, const SkString& name ) { | 39 void make_filepath(SkString* path, const SkString& dir, const SkString& name ) { |
32 size_t len = dir.size(); | 40 size_t len = dir.size(); |
33 path->set(dir); | 41 path->set(dir); |
34 if (0 < len && '/' != dir[len - 1]) { | 42 if (0 < len && '/' != dir[len - 1]) { |
35 path->append("/"); | 43 path->append("/"); |
36 } | 44 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 SkString skString(string); | 92 SkString skString(string); |
85 return skString.endsWith("%"); | 93 return skString.endsWith("%"); |
86 } | 94 } |
87 | 95 |
88 void setup_bitmap(SkBitmap* bitmap, int width, int height) { | 96 void setup_bitmap(SkBitmap* bitmap, int width, int height) { |
89 bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); | 97 bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); |
90 bitmap->allocPixels(); | 98 bitmap->allocPixels(); |
91 bitmap->eraseColor(SK_ColorTRANSPARENT); | 99 bitmap->eraseColor(SK_ColorTRANSPARENT); |
92 } | 100 } |
93 } | 101 } |
OLD | NEW |