Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: tools/picture_utils.cpp

Issue 14363003: Updates to skimage tool to use it for testing. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Change getFormatName to use a switch statement. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/picture_utils.cpp
diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp
index 7a5e156fb23173aa2e3a31bb3d46cd20451363f6..3dee665d11372213a4ff57b10f4fa0b3f4cdb190 100644
--- a/tools/picture_utils.cpp
+++ b/tools/picture_utils.cpp
@@ -15,15 +15,23 @@
namespace sk_tools {
void force_all_opaque(const SkBitmap& bitmap) {
SkASSERT(NULL == bitmap.getTexture());
- SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config());
- if (NULL != bitmap.getTexture() || SkBitmap::kARGB_8888_Config == bitmap.config()) {
+ if (NULL != bitmap.getTexture()) {
return;
}
- SkAutoLockPixels lock(bitmap);
- for (int y = 0; y < bitmap.height(); y++) {
- for (int x = 0; x < bitmap.width(); x++) {
- *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT);
+ SkBitmap bitmap8888;
+ const SkBitmap* bmPtr;
+ if (SkBitmap::kARGB_8888_Config == bitmap.config()) {
+ bmPtr = &bitmap;
+ } else {
+ bitmap.copyTo(&bitmap8888, SkBitmap::kARGB_8888_Config);
+ bmPtr = &bitmap8888;
+ }
+
+ SkAutoLockPixels lock(*bmPtr);
+ for (int y = 0; y < bmPtr->height(); y++) {
+ for (int x = 0; x < bmPtr->width(); x++) {
+ *bmPtr->getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT);
}
}
}
« no previous file with comments | « src/ports/SkImageDecoder_WIC.cpp ('k') | tools/skimage_main.cpp » ('j') | tools/skimage_main.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698