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

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

Issue 11138024: Simplify platform_canvas.h by recognizing that PlatformCanvas does not actually extend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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
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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice( 249 SkDevice* BitmapPlatformDevice::onCreateCompatibleDevice(
250 SkBitmap::Config config, int width, int height, bool isOpaque, 250 SkBitmap::Config config, int width, int height, bool isOpaque,
251 Usage /*usage*/) { 251 Usage /*usage*/) {
252 SkASSERT(config == SkBitmap::kARGB_8888_Config); 252 SkASSERT(config == SkBitmap::kARGB_8888_Config);
253 SkDevice* bitmap_device = BitmapPlatformDevice::CreateAndClear(width, height, 253 SkDevice* bitmap_device = BitmapPlatformDevice::CreateAndClear(width, height,
254 isOpaque); 254 isOpaque);
255 return bitmap_device; 255 return bitmap_device;
256 } 256 }
257 257
258 // PlatformCanvas impl
259
260 SkCanvas* CreatePlatformCanvas(CGContextRef ctx, int width, int height,
261 bool is_opaque, OnFailureType failureType) {
262 SkDevice* dev = BitmapPlatformDevice::Create(ctx, width, height, is_opaque);
263 return CreateCanvas(dev, failureType);
264 }
265
266 SkCanvas* CreatePlatformCanvas(int width, int height, bool is_opaque,
267 uint8_t* data, OnFailureType failureType) {
268 SkDevice* dev = BitmapPlatformDevice::CreateWithData(data, width, height,
269 is_opaque);
270 return CreateCanvas(dev, failureType);
271 }
272
258 // Port of PlatformBitmap to mac 273 // Port of PlatformBitmap to mac
259 274
260 PlatformBitmap::~PlatformBitmap() { 275 PlatformBitmap::~PlatformBitmap() {
261 if (surface_) 276 if (surface_)
262 CGContextRelease(surface_); 277 CGContextRelease(surface_);
263 } 278 }
264 279
265 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) { 280 bool PlatformBitmap::Allocate(int width, int height, bool is_opaque) {
266 if (RasterDeviceTooBigToAllocate(width, height)) 281 if (RasterDeviceTooBigToAllocate(width, height))
267 return false; 282 return false;
268 283
269 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, width * 4); 284 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width, height, width * 4);
270 if (!bitmap_.allocPixels()) 285 if (!bitmap_.allocPixels())
271 return false; 286 return false;
272 287
273 if (!is_opaque) 288 if (!is_opaque)
274 bitmap_.eraseColor(0); 289 bitmap_.eraseColor(0);
275 bitmap_.setIsOpaque(is_opaque); 290 bitmap_.setIsOpaque(is_opaque);
276 291
277 surface_ = CGContextForData(bitmap_.getPixels(), bitmap_.width(), 292 surface_ = CGContextForData(bitmap_.getPixels(), bitmap_.width(),
278 bitmap_.height()); 293 bitmap_.height());
279 return true; 294 return true;
280 } 295 }
281 296
282 } // namespace skia 297 } // namespace skia
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698