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 CGContextRef GetBitmapContext(SkDevice* device) { |
| 18 PlatformDevice* platform_device = GetPlatformDevice(device); |
| 19 if (platform_device) |
| 20 return platform_device->GetBitmapContext(); |
17 | 21 |
18 // Constrains position and size to fit within available_size. | 22 return NULL; |
19 bool constrain(int available_size, int* position, int *size) { | |
20 if (*position < 0) { | |
21 *size += *position; | |
22 *position = 0; | |
23 } | |
24 if (*size > 0 && *position < available_size) { | |
25 int overflow = (*position + *size) - available_size; | |
26 if (overflow > 0) { | |
27 *size -= overflow; | |
28 } | |
29 return true; | |
30 } | |
31 return false; | |
32 } | 23 } |
33 | 24 |
34 } // namespace | |
35 | |
36 PlatformDevice::PlatformDevice(const SkBitmap& bitmap) | 25 PlatformDevice::PlatformDevice(const SkBitmap& bitmap) |
37 : SkDevice(NULL, bitmap, /*isForLayer=*/false) { | 26 : SkDevice(NULL, bitmap, /*isForLayer=*/false) { |
| 27 SetPlatformDevice(this, this); |
38 } | 28 } |
39 | 29 |
40 bool PlatformDevice::IsNativeFontRenderingAllowed() { | 30 bool PlatformDevice::IsNativeFontRenderingAllowed() { |
41 return true; | 31 return true; |
42 } | 32 } |
43 | 33 |
44 CGContextRef PlatformDevice::BeginPlatformPaint() { | 34 CGContextRef PlatformDevice::BeginPlatformPaint() { |
45 return GetBitmapContext(); | 35 return GetBitmapContext(); |
46 } | 36 } |
47 | 37 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 path.transform(transformation); | 156 path.transform(transformation); |
167 // TODO(playmobil): Implement. | 157 // TODO(playmobil): Implement. |
168 SkASSERT(false); | 158 SkASSERT(false); |
169 // LoadPathToDC(context, path); | 159 // LoadPathToDC(context, path); |
170 // hrgn = PathToRegion(context); | 160 // hrgn = PathToRegion(context); |
171 } | 161 } |
172 } | 162 } |
173 | 163 |
174 } // namespace skia | 164 } // namespace skia |
175 | 165 |
OLD | NEW |