Chromium Code Reviews| 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 | |
| 29 static inline SkBitmap makeABitmap(int width, int height) { | 16 static inline SkBitmap makeABitmap(int width, int height) { |
| 30 SkBitmap bitmap; | 17 SkBitmap bitmap; |
| 31 bitmap.setConfig(SkBitmap::kNo_Config, width, height); | 18 bitmap.setConfig(SkBitmap::kNo_Config, width, height); |
| 32 return bitmap; | 19 return bitmap; |
| 33 } | 20 } |
| 34 | 21 |
| 35 VectorPlatformDeviceSkia::VectorPlatformDeviceSkia(SkPDFDevice* pdf_device) | 22 VectorPlatformDeviceSkia::VectorPlatformDeviceSkia(SkPDFDevice* pdf_device) |
| 36 : PlatformDevice(makeABitmap(pdf_device->width(), pdf_device->height())), | 23 : PlatformDevice(makeABitmap(pdf_device->width(), pdf_device->height())), |
| 37 pdf_device_(pdf_device) { | 24 pdf_device_(pdf_device) { |
| 38 } | 25 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 SkASSERT(false); | 204 SkASSERT(false); |
| 218 } | 205 } |
| 219 | 206 |
| 220 CGContextRef VectorPlatformDeviceSkia::GetBitmapContext() { | 207 CGContextRef VectorPlatformDeviceSkia::GetBitmapContext() { |
| 221 SkASSERT(false); | 208 SkASSERT(false); |
| 222 return NULL; | 209 return NULL; |
| 223 } | 210 } |
| 224 | 211 |
| 225 #endif | 212 #endif |
| 226 | 213 |
| 227 SkDeviceFactory* VectorPlatformDeviceSkia::onNewDeviceFactory() { | 214 SkDevice* VectorPlatformDeviceSkia::onCreateCompatibleDevice( |
| 228 return SkNEW(VectorPlatformDeviceSkiaFactory); | 215 SkBitmap::Config config, int width, int height, |
|
vandebo (ex-Chrome)
2011/07/01 17:20:14
nit: indent is wrong.
| |
| 216 bool isOpaque, Usage /*usage*/) { | |
| 217 SkAutoTUnref<SkDevice> dev(pdf_device_->createCompatibleDevice(config, width, | |
| 218 height, | |
| 219 isOpaque)); | |
| 220 return new VectorPlatformDeviceSkia(static_cast<SkPDFDevice*>(dev.get())); | |
| 229 } | 221 } |
| 230 | 222 |
| 231 } // namespace skia | 223 } // namespace skia |
| OLD | NEW |