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/bitmap_platform_device_mac.h" | 5 #include "skia/ext/platform_device.h" |
| 6 #include "skia/ext/bitmap_platform_device.h" |
6 | 7 |
7 #import <ApplicationServices/ApplicationServices.h> | 8 #import <ApplicationServices/ApplicationServices.h> |
8 #include "skia/ext/skia_utils_mac.h" | 9 #include "skia/ext/skia_utils_mac.h" |
9 #include "third_party/skia/include/core/SkMatrix.h" | 10 #include "third_party/skia/include/core/SkMatrix.h" |
10 #include "third_party/skia/include/core/SkPath.h" | 11 #include "third_party/skia/include/core/SkPath.h" |
11 #include "third_party/skia/include/core/SkTypes.h" | 12 #include "third_party/skia/include/core/SkTypes.h" |
12 #include "third_party/skia/include/core/SkUtils.h" | 13 #include "third_party/skia/include/core/SkUtils.h" |
13 | 14 |
14 namespace skia { | 15 namespace skia { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
| 19 #if 0 |
18 // Constrains position and size to fit within available_size. | 20 // Constrains position and size to fit within available_size. |
19 bool constrain(int available_size, int* position, int *size) { | 21 bool constrain(int available_size, int* position, int *size) { |
20 if (*position < 0) { | 22 if (*position < 0) { |
21 *size += *position; | 23 *size += *position; |
22 *position = 0; | 24 *position = 0; |
23 } | 25 } |
24 if (*size > 0 && *position < available_size) { | 26 if (*size > 0 && *position < available_size) { |
25 int overflow = (*position + *size) - available_size; | 27 int overflow = (*position + *size) - available_size; |
26 if (overflow > 0) { | 28 if (overflow > 0) { |
27 *size -= overflow; | 29 *size -= overflow; |
28 } | 30 } |
29 return true; | 31 return true; |
30 } | 32 } |
31 return false; | 33 return false; |
32 } | 34 } |
| 35 #endif |
33 | 36 |
34 } // namespace | 37 } // namespace |
35 | 38 |
| 39 namespace platform_util { |
| 40 |
| 41 void DrawToContext(SkDevice* device, CGContextRef context, int x, int y, |
| 42 const CGRect* src_rect) { |
| 43 PlatformDevice* platform_device = GetPlatformDevice(device); |
| 44 if (platform_device) |
| 45 platform_device->DrawToContext(context, x, y, src_rect); |
| 46 } |
| 47 |
| 48 CGContextRef GetBitmapContext(SkDevice* device) { |
| 49 PlatformDevice* platform_device = GetPlatformDevice(device); |
| 50 if (platform_device) |
| 51 return platform_device->GetBitmapContext(); |
| 52 |
| 53 return NULL; |
| 54 } |
| 55 |
| 56 } |
| 57 |
36 PlatformDevice::PlatformDevice(const SkBitmap& bitmap) | 58 PlatformDevice::PlatformDevice(const SkBitmap& bitmap) |
37 : SkDevice(NULL, bitmap, /*isForLayer=*/false) { | 59 : SkDevice(NULL, bitmap, /*isForLayer=*/false) { |
| 60 SetPlatformDevice(this, this); |
38 } | 61 } |
39 | 62 |
40 bool PlatformDevice::IsNativeFontRenderingAllowed() { | 63 bool PlatformDevice::IsNativeFontRenderingAllowed() { |
41 return true; | 64 return true; |
42 } | 65 } |
43 | 66 |
44 CGContextRef PlatformDevice::BeginPlatformPaint() { | 67 CGContextRef PlatformDevice::BeginPlatformPaint() { |
45 return GetBitmapContext(); | 68 return GetBitmapContext(); |
46 } | 69 } |
47 | 70 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 path.transform(transformation); | 189 path.transform(transformation); |
167 // TODO(playmobil): Implement. | 190 // TODO(playmobil): Implement. |
168 SkASSERT(false); | 191 SkASSERT(false); |
169 // LoadPathToDC(context, path); | 192 // LoadPathToDC(context, path); |
170 // hrgn = PathToRegion(context); | 193 // hrgn = PathToRegion(context); |
171 } | 194 } |
172 } | 195 } |
173 | 196 |
174 } // namespace skia | 197 } // namespace skia |
175 | 198 |
OLD | NEW |