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

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

Issue 3590011: Update use of SkCanvas and SkDevice to match change in Skia (Closed)
Patch Set: Bump deps again to bring in fix for memory leak Created 10 years, 2 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/platform_canvas_linux.cc ('k') | skia/ext/platform_canvas_win.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/platform_canvas.h" 5 #include "skia/ext/platform_canvas.h"
6 6
7 #include "skia/ext/bitmap_platform_device_mac.h" 7 #include "skia/ext/bitmap_platform_device_mac.h"
8 #include "third_party/skia/include/core/SkTypes.h" 8 #include "third_party/skia/include/core/SkTypes.h"
9 9
10 namespace skia { 10 namespace skia {
11 11
12 PlatformCanvas::PlatformCanvas() : SkCanvas() {
13 }
14
15 PlatformCanvas::PlatformCanvas(int width, int height, bool is_opaque) 12 PlatformCanvas::PlatformCanvas(int width, int height, bool is_opaque)
16 : SkCanvas() { 13 : SkCanvas(SkNEW(SkBitmapPlatformDeviceFactory)) {
17 initialize(width, height, is_opaque); 14 initialize(width, height, is_opaque);
18 } 15 }
19 16
20 PlatformCanvas::PlatformCanvas(int width, 17 PlatformCanvas::PlatformCanvas(int width,
21 int height, 18 int height,
22 bool is_opaque, 19 bool is_opaque,
23 CGContextRef context) 20 CGContextRef context)
24 : SkCanvas() { 21 : SkCanvas(SkNEW(SkBitmapPlatformDeviceFactory)) {
25 initialize(width, height, is_opaque); 22 initialize(width, height, is_opaque);
26 } 23 }
27 24
28 PlatformCanvas::PlatformCanvas(int width, 25 PlatformCanvas::PlatformCanvas(int width,
29 int height, 26 int height,
30 bool is_opaque, 27 bool is_opaque,
31 uint8_t* data) 28 uint8_t* data)
32 : SkCanvas() { 29 : SkCanvas(SkNEW(SkBitmapPlatformDeviceFactory)) {
33 initialize(width, height, is_opaque, data); 30 initialize(width, height, is_opaque, data);
34 } 31 }
35 32
36 PlatformCanvas::~PlatformCanvas() { 33 PlatformCanvas::~PlatformCanvas() {
37 } 34 }
38 35
39 bool PlatformCanvas::initialize(int width, 36 bool PlatformCanvas::initialize(int width,
40 int height, 37 int height,
41 bool is_opaque, 38 bool is_opaque,
42 uint8_t* data) { 39 uint8_t* data) {
43 SkDevice* device = BitmapPlatformDevice::CreateWithData(data, width, height, 40 SkDevice* device = BitmapPlatformDevice::CreateWithData(data, width, height,
44 is_opaque); 41 is_opaque);
45 if (!device) 42 if (!device)
46 return false; 43 return false;
47 44
48 setDevice(device); 45 setDevice(device);
49 device->unref(); // Was created with refcount 1, and setDevice also refs. 46 device->unref(); // Was created with refcount 1, and setDevice also refs.
50 return true; 47 return true;
51 } 48 }
52 49
53 CGContextRef PlatformCanvas::beginPlatformPaint() { 50 CGContextRef PlatformCanvas::beginPlatformPaint() {
54 return getTopPlatformDevice().GetBitmapContext(); 51 return getTopPlatformDevice().GetBitmapContext();
55 } 52 }
56 53
57 void PlatformCanvas::endPlatformPaint() { 54 void PlatformCanvas::endPlatformPaint() {
58 // Flushing will be done in onAccessBitmap. 55 // Flushing will be done in onAccessBitmap.
59 } 56 }
60 57
61 SkDevice* PlatformCanvas::createDevice(SkBitmap::Config config,
62 int width,
63 int height,
64 bool is_opaque, bool isForLayer) {
65 SkASSERT(config == SkBitmap::kARGB_8888_Config);
66 return BitmapPlatformDevice::Create(NULL, width, height, is_opaque);
67 }
68
69 } // namespace skia 58 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/platform_canvas_linux.cc ('k') | skia/ext/platform_canvas_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698