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

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

Issue 556463002: Revert of tryAllocPixels returns bool, allocPixels requires success (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « skia/ext/bitmap_platform_device_skia.cc ('k') | skia/ext/skia_utils_mac.mm » ('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 if (!bitmap.tryAllocN32Pixels(size.width, size.height, is_opaque)) 21 if (!bitmap.allocN32Pixels(size.width, size.height, is_opaque))
22 return bitmap; 22 return bitmap;
23 23
24 void* data = bitmap.getPixels(); 24 void* data = bitmap.getPixels();
25 25
26 // Allocate a bitmap context with 4 components per pixel (BGRA). Apple 26 // Allocate a bitmap context with 4 components per pixel (BGRA). Apple
27 // recommends these flags for improved CG performance. 27 // recommends these flags for improved CG performance.
28 #define HAS_ARGB_SHIFTS(a, r, g, b) \ 28 #define HAS_ARGB_SHIFTS(a, r, g, b) \
29 (SK_A32_SHIFT == (a) && SK_R32_SHIFT == (r) \ 29 (SK_A32_SHIFT == (a) && SK_R32_SHIFT == (r) \
30 && SK_G32_SHIFT == (g) && SK_B32_SHIFT == (b)) 30 && SK_G32_SHIFT == (g) && SK_B32_SHIFT == (b))
31 #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
92 if (!bitmap.empty()) 92 if (!bitmap.empty())
93 frames.push_back(bitmap); 93 frames.push_back(bitmap);
94 } 94 }
95 95
96 DLOG_IF(WARNING, frames.size() != count) << "Only decoded " << frames.size() 96 DLOG_IF(WARNING, frames.size() != count) << "Only decoded " << frames.size()
97 << " frames for " << count << " expected."; 97 << " frames for " << count << " expected.";
98 return frames; 98 return frames;
99 } 99 }
100 100
101 } // namespace gfx 101 } // namespace gfx
OLDNEW
« no previous file with comments | « skia/ext/bitmap_platform_device_skia.cc ('k') | skia/ext/skia_utils_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698