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

Side by Side Diff: src/images/SkImageEncoder_argb.cpp

Issue 51033004: add SK_ATTR_DEPRECATED -- will need to disable for chrome, since it triggers a warning (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageDecoder_libwebp.cpp ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "SkImageEncoder.h" 8 #include "SkImageEncoder.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 case SkBitmap::kARGB_4444_Config: 80 case SkBitmap::kARGB_4444_Config:
81 return ARGB_4444_To_ARGB; 81 return ARGB_4444_To_ARGB;
82 case SkBitmap::kIndex8_Config: 82 case SkBitmap::kIndex8_Config:
83 return Index8_To_ARGB; 83 return Index8_To_ARGB;
84 default: 84 default:
85 return NULL; 85 return NULL;
86 } 86 }
87 } 87 }
88 88
89 bool SkARGBImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap, int ) { 89 bool SkARGBImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap, int ) {
90 const SkBitmap::Config config = bitmap.getConfig(); 90 const SkBitmap::Config config = bitmap.config();
91 const ScanlineImporter scanline_import = ChooseImporter(config); 91 const ScanlineImporter scanline_import = ChooseImporter(config);
92 if (NULL == scanline_import) { 92 if (NULL == scanline_import) {
93 return false; 93 return false;
94 } 94 }
95 95
96 SkAutoLockPixels alp(bitmap); 96 SkAutoLockPixels alp(bitmap);
97 const uint8_t* src = (uint8_t*)bitmap.getPixels(); 97 const uint8_t* src = (uint8_t*)bitmap.getPixels();
98 if (NULL == bitmap.getPixels()) { 98 if (NULL == bitmap.getPixels()) {
99 return false; 99 return false;
100 } 100 }
101 101
102 SkAutoLockColors ctLocker; 102 SkAutoLockColors ctLocker;
103 const SkPMColor* colors = ctLocker.lockColors(bitmap); 103 const SkPMColor* colors = ctLocker.lockColors(bitmap);
104 104
105 const int argbStride = bitmap.width() * 4; 105 const int argbStride = bitmap.width() * 4;
106 SkAutoTDeleteArray<uint8_t> ada(new uint8_t[argbStride]); 106 SkAutoTDeleteArray<uint8_t> ada(new uint8_t[argbStride]);
107 uint8_t* argb = ada.get(); 107 uint8_t* argb = ada.get();
108 for (int y = 0; y < bitmap.height(); ++y) { 108 for (int y = 0; y < bitmap.height(); ++y) {
109 scanline_import(src + y * bitmap.rowBytes(), argb, bitmap.width(), color s); 109 scanline_import(src + y * bitmap.rowBytes(), argb, bitmap.width(), color s);
110 stream->write(argb, argbStride); 110 stream->write(argb, argbStride);
111 } 111 }
112 112
113 return true; 113 return true;
114 } 114 }
115 115
116 116
117 /////////////////////////////////////////////////////////////////////////////// 117 ///////////////////////////////////////////////////////////////////////////////
118 DEFINE_ENCODER_CREATOR(ARGBImageEncoder); 118 DEFINE_ENCODER_CREATOR(ARGBImageEncoder);
119 /////////////////////////////////////////////////////////////////////////////// 119 ///////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libwebp.cpp ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698