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

Side by Side Diff: tools/picture_utils.cpp

Issue 338493005: stop using SkBitmap::Config (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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 unified diff | Download patch
OLDNEW
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 "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
11 #include "SkImageEncoder.h" 11 #include "SkImageEncoder.h"
12 #include "SkOSFile.h" 12 #include "SkOSFile.h"
13 #include "SkPicture.h" 13 #include "SkPicture.h"
14 #include "SkStream.h" 14 #include "SkStream.h"
15 #include "SkString.h" 15 #include "SkString.h"
16 16
17 namespace sk_tools { 17 namespace sk_tools {
18 void force_all_opaque(const SkBitmap& bitmap) { 18 void force_all_opaque(const SkBitmap& bitmap) {
19 SkASSERT(NULL == bitmap.getTexture()); 19 SkASSERT(NULL == bitmap.getTexture());
20 SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config()); 20 SkASSERT(kN32_SkColorType == bitmap.colorType());
21 if (NULL != bitmap.getTexture() || SkBitmap::kARGB_8888_Config == bitmap .config()) { 21 if (NULL != bitmap.getTexture() || kN32_SkColorType == bitmap.colorType( )) {
22 return; 22 return;
23 } 23 }
24 24
25 SkAutoLockPixels lock(bitmap); 25 SkAutoLockPixels lock(bitmap);
26 for (int y = 0; y < bitmap.height(); y++) { 26 for (int y = 0; y < bitmap.height(); y++) {
27 for (int x = 0; x < bitmap.width(); x++) { 27 for (int x = 0; x < bitmap.width(); x++) {
28 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); 28 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT);
29 } 29 }
30 } 30 }
31 } 31 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 SkString fullPath = SkOSPath::SkPathJoin(partialPath.c_str(), baseName.c _str()); 63 SkString fullPath = SkOSPath::SkPathJoin(partialPath.c_str(), baseName.c _str());
64 if (SkImageEncoder::EncodeFile(fullPath.c_str(), bm, SkImageEncoder::kPN G_Type, 100)) { 64 if (SkImageEncoder::EncodeFile(fullPath.c_str(), bm, SkImageEncoder::kPN G_Type, 100)) {
65 return true; 65 return true;
66 } else { 66 } else {
67 SkDebugf("Failed to write the bitmap to %s.\n", fullPath.c_str()); 67 SkDebugf("Failed to write the bitmap to %s.\n", fullPath.c_str());
68 return false; 68 return false;
69 } 69 }
70 } 70 }
71 71
72 } // namespace sk_tools 72 } // namespace sk_tools
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698