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

Side by Side Diff: skia/ext/bitmap_platform_device_mac.cc

Issue 331283002: stop calling deprecated setConfig (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + android typo 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 | Annotate | Revision Log
« no previous file with comments | « skia/ext/analysis_canvas_unittest.cc ('k') | skia/ext/bitmap_platform_device_skia.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/bitmap_platform_device_mac.h" 5 #include "skia/ext/bitmap_platform_device_mac.h"
6 6
7 #import <ApplicationServices/ApplicationServices.h> 7 #import <ApplicationServices/ApplicationServices.h>
8 #include <time.h> 8 #include <time.h>
9 9
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 BitmapPlatformDevice* BitmapPlatformDevice::Create(CGContextRef context, 96 BitmapPlatformDevice* BitmapPlatformDevice::Create(CGContextRef context,
97 int width, 97 int width,
98 int height, 98 int height,
99 bool is_opaque) { 99 bool is_opaque) {
100 if (RasterDeviceTooBigToAllocate(width, height)) 100 if (RasterDeviceTooBigToAllocate(width, height))
101 return NULL; 101 return NULL;
102 102
103 SkBitmap bitmap; 103 SkBitmap bitmap;
104 // TODO: verify that the CG Context's pixels will have tight rowbytes or pass in the correct 104 // TODO: verify that the CG Context's pixels will have tight rowbytes or pass in the correct
105 // rowbytes for the case when context != NULL. 105 // rowbytes for the case when context != NULL.
106 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height, 0, 106 bitmap.setInfo(SkImageInfo::MakeN32(width, height, is_opaque ? kOpaque_SkAlpha Type : kPremul_SkAlphaType));
107 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
108 107
109 void* data; 108 void* data;
110 if (context) { 109 if (context) {
111 data = CGBitmapContextGetData(context); 110 data = CGBitmapContextGetData(context);
112 bitmap.setPixels(data); 111 bitmap.setPixels(data);
113 } else { 112 } else {
114 if (!bitmap.allocPixels()) 113 if (!bitmap.allocPixels())
115 return NULL; 114 return NULL;
116 data = bitmap.getPixels(); 115 data = bitmap.getPixels();
117 } 116 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 264
266 PlatformBitmap::~PlatformBitmap() { 265 PlatformBitmap::~PlatformBitmap() {
267 if (surface_) 266 if (surface_)
268 CGContextRelease(surface_); 267 CGContextRelease(surface_);
269 } 268 }
270 269
271 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { 270 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
272 if (RasterDeviceTooBigToAllocate(width, height)) 271 if (RasterDeviceTooBigToAllocate(width, height))
273 return false; 272 return false;
274 273
275 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, width * 4, 274 if (!bitmap_.allocN32Pixels(width, height, is_opaque))
276 is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); 275 return false;
277 if (!bitmap_.allocPixels())
278 return false;
279 276
280 if (!is_opaque) 277 if (!is_opaque)
281 bitmap_.eraseColor(0); 278 bitmap_.eraseColor(0);
282 279
283 surface_ = CGContextForData(bitmap_.getPixels(), bitmap_.width(), 280 surface_ = CGContextForData(bitmap_.getPixels(), bitmap_.width(),
284 bitmap_.height()); 281 bitmap_.height());
285 return true; 282 return true;
286 } 283 }
287 284
288 } // namespace skia 285 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/analysis_canvas_unittest.cc ('k') | skia/ext/bitmap_platform_device_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698