| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/vector_platform_device_skia.h" | 5 #include "skia/ext/vector_platform_device_skia.h" |
| 6 | 6 |
| 7 #include "skia/ext/bitmap_platform_device.h" | 7 #include "skia/ext/bitmap_platform_device.h" |
| 8 #include "third_party/skia/include/core/SkClipStack.h" | 8 #include "third_party/skia/include/core/SkClipStack.h" |
| 9 #include "third_party/skia/include/core/SkDraw.h" | 9 #include "third_party/skia/include/core/SkDraw.h" |
| 10 #include "third_party/skia/include/core/SkRect.h" | 10 #include "third_party/skia/include/core/SkRect.h" |
| 11 #include "third_party/skia/include/core/SkRegion.h" | 11 #include "third_party/skia/include/core/SkRegion.h" |
| 12 #include "third_party/skia/include/core/SkScalar.h" | 12 #include "third_party/skia/include/core/SkScalar.h" |
| 13 | 13 |
| 14 namespace skia { | 14 namespace skia { |
| 15 | 15 |
| 16 SkDevice* VectorPlatformDeviceSkiaFactory::newDevice(SkCanvas* canvas, |
| 17 SkBitmap::Config config, |
| 18 int width, int height, |
| 19 bool isOpaque, |
| 20 bool isForLayer) { |
| 21 SkASSERT(config == SkBitmap::kARGB_8888_Config); |
| 22 SkRefPtr<SkDevice> device = factory_.newDevice(canvas, config, width, height, |
| 23 isOpaque, isForLayer); |
| 24 device->unref(); // SkRefPtr and new both took a reference. |
| 25 SkPDFDevice* pdf_device = static_cast<SkPDFDevice*>(device.get()); |
| 26 return new VectorPlatformDeviceSkia(pdf_device); |
| 27 } |
| 28 |
| 16 static inline SkBitmap makeABitmap(int width, int height) { | 29 static inline SkBitmap makeABitmap(int width, int height) { |
| 17 SkBitmap bitmap; | 30 SkBitmap bitmap; |
| 18 bitmap.setConfig(SkBitmap::kNo_Config, width, height); | 31 bitmap.setConfig(SkBitmap::kNo_Config, width, height); |
| 19 return bitmap; | 32 return bitmap; |
| 20 } | 33 } |
| 21 | 34 |
| 22 VectorPlatformDeviceSkia::VectorPlatformDeviceSkia(SkPDFDevice* pdf_device) | 35 VectorPlatformDeviceSkia::VectorPlatformDeviceSkia(SkPDFDevice* pdf_device) |
| 23 : PlatformDevice(makeABitmap(pdf_device->width(), pdf_device->height())), | 36 : PlatformDevice(makeABitmap(pdf_device->width(), pdf_device->height())), |
| 24 pdf_device_(pdf_device) { | 37 pdf_device_(pdf_device) { |
| 25 } | 38 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 SkASSERT(false); | 217 SkASSERT(false); |
| 205 } | 218 } |
| 206 | 219 |
| 207 CGContextRef VectorPlatformDeviceSkia::GetBitmapContext() { | 220 CGContextRef VectorPlatformDeviceSkia::GetBitmapContext() { |
| 208 SkASSERT(false); | 221 SkASSERT(false); |
| 209 return NULL; | 222 return NULL; |
| 210 } | 223 } |
| 211 | 224 |
| 212 #endif | 225 #endif |
| 213 | 226 |
| 214 SkDevice* VectorPlatformDeviceSkia::onCreateCompatibleDevice( | 227 SkDeviceFactory* VectorPlatformDeviceSkia::onNewDeviceFactory() { |
| 215 SkBitmap::Config config, int width, int height, bool isOpaque, | 228 return SkNEW(VectorPlatformDeviceSkiaFactory); |
| 216 Usage /*usage*/) { | |
| 217 SkAutoTUnref<SkDevice> dev(pdf_device_->createCompatibleDevice(config, width, | |
| 218 height, | |
| 219 isOpaque)); | |
| 220 return new VectorPlatformDeviceSkia(static_cast<SkPDFDevice*>(dev.get())); | |
| 221 } | 229 } |
| 222 | 230 |
| 223 } // namespace skia | 231 } // namespace skia |
| OLD | NEW |