OLD | NEW |
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 { |
(...skipping 22 matching lines...) Expand all Loading... |
33 initialize(width, height, is_opaque, data); | 33 initialize(width, height, is_opaque, data); |
34 } | 34 } |
35 | 35 |
36 PlatformCanvas::~PlatformCanvas() { | 36 PlatformCanvas::~PlatformCanvas() { |
37 } | 37 } |
38 | 38 |
39 bool PlatformCanvas::initialize(int width, | 39 bool PlatformCanvas::initialize(int width, |
40 int height, | 40 int height, |
41 bool is_opaque, | 41 bool is_opaque, |
42 uint8_t* data) { | 42 uint8_t* data) { |
43 SkDevice* device = BitmapPlatformDevice::Create(NULL, width, height, | 43 SkDevice* device = BitmapPlatformDevice::CreateWithData(data, width, height, |
44 is_opaque); | 44 is_opaque); |
45 if (!device) | 45 if (!device) |
46 return false; | 46 return false; |
47 | 47 |
48 setDevice(device); | 48 setDevice(device); |
49 device->unref(); // Was created with refcount 1, and setDevice also refs. | 49 device->unref(); // Was created with refcount 1, and setDevice also refs. |
50 return true; | 50 return true; |
51 } | 51 } |
52 | 52 |
53 CGContextRef PlatformCanvas::beginPlatformPaint() { | 53 CGContextRef PlatformCanvas::beginPlatformPaint() { |
54 return getTopPlatformDevice().GetBitmapContext(); | 54 return getTopPlatformDevice().GetBitmapContext(); |
55 } | 55 } |
56 | 56 |
57 void PlatformCanvas::endPlatformPaint() { | 57 void PlatformCanvas::endPlatformPaint() { |
58 // Flushing will be done in onAccessBitmap. | 58 // Flushing will be done in onAccessBitmap. |
59 } | 59 } |
60 | 60 |
61 SkDevice* PlatformCanvas::createDevice(SkBitmap::Config config, | 61 SkDevice* PlatformCanvas::createDevice(SkBitmap::Config config, |
62 int width, | 62 int width, |
63 int height, | 63 int height, |
64 bool is_opaque, bool isForLayer) { | 64 bool is_opaque, bool isForLayer) { |
65 SkASSERT(config == SkBitmap::kARGB_8888_Config); | 65 SkASSERT(config == SkBitmap::kARGB_8888_Config); |
66 return BitmapPlatformDevice::Create(NULL, width, height, is_opaque); | 66 return BitmapPlatformDevice::CreateWithContext(NULL, width, height, |
| 67 is_opaque); |
67 } | 68 } |
68 | 69 |
69 } // namespace skia | 70 } // namespace skia |
OLD | NEW |