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

Side by Side Diff: skia/ext/skia_utils_ios.mm

Issue 363933002: setConfig is deprecated, use setInfo or allocPixels instead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « skia/ext/pixel_ref_utils_unittest.cc ('k') | skia/ext/vector_platform_device_emf_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "skia/ext/skia_utils_ios.h" 5 #include "skia/ext/skia_utils_ios.h"
6 6
7 #import <ImageIO/ImageIO.h> 7 #import <ImageIO/ImageIO.h>
8 #import <UIKit/UIKit.h> 8 #import <UIKit/UIKit.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/mac/scoped_cftyperef.h" 11 #include "base/mac/scoped_cftyperef.h"
12 #include "third_party/skia/include/utils/mac/SkCGUtils.h" 12 #include "third_party/skia/include/utils/mac/SkCGUtils.h"
13 13
14 namespace gfx { 14 namespace gfx {
15 15
16 SkBitmap CGImageToSkBitmap(CGImageRef image, CGSize size, bool is_opaque) { 16 SkBitmap CGImageToSkBitmap(CGImageRef image, CGSize size, bool is_opaque) {
17 SkBitmap bitmap; 17 SkBitmap bitmap;
18 if (!image) 18 if (!image)
19 return bitmap; 19 return bitmap;
20 20
21 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 21 if (!bitmap.allocN32Pixels(size.width, size.height, is_opaque))
22 size.width,
23 size.height,
24 0,
25 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
26
27 if (!bitmap.allocPixels())
28 return bitmap; 22 return bitmap;
29 23
30 void* data = bitmap.getPixels(); 24 void* data = bitmap.getPixels();
31 25
32 // Allocate a bitmap context with 4 components per pixel (BGRA). Apple 26 // Allocate a bitmap context with 4 components per pixel (BGRA). Apple
33 // recommends these flags for improved CG performance. 27 // recommends these flags for improved CG performance.
34 #define HAS_ARGB_SHIFTS(a, r, g, b) \ 28 #define HAS_ARGB_SHIFTS(a, r, g, b) \
35 (SK_A32_SHIFT == (a) && SK_R32_SHIFT == (r) \ 29 (SK_A32_SHIFT == (a) && SK_R32_SHIFT == (r) \
36 && SK_G32_SHIFT == (g) && SK_B32_SHIFT == (b)) 30 && SK_G32_SHIFT == (g) && SK_B32_SHIFT == (b))
37 #if defined(SK_CPU_LENDIAN) && HAS_ARGB_SHIFTS(24, 16, 8, 0) 31 #if defined(SK_CPU_LENDIAN) && HAS_ARGB_SHIFTS(24, 16, 8, 0)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 if (!bitmap.empty()) 92 if (!bitmap.empty())
99 frames.push_back(bitmap); 93 frames.push_back(bitmap);
100 } 94 }
101 95
102 DLOG_IF(WARNING, frames.size() != count) << "Only decoded " << frames.size() 96 DLOG_IF(WARNING, frames.size() != count) << "Only decoded " << frames.size()
103 << " frames for " << count << " expected."; 97 << " frames for " << count << " expected.";
104 return frames; 98 return frames;
105 } 99 }
106 100
107 } // namespace gfx 101 } // namespace gfx
OLDNEW
« no previous file with comments | « skia/ext/pixel_ref_utils_unittest.cc ('k') | skia/ext/vector_platform_device_emf_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698