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" |
(...skipping 23 matching lines...) Expand all Loading... |
34 return false; | 34 return false; |
35 } | 35 } |
36 | 36 |
37 PlatformSurface VectorPlatformDeviceSkia::BeginPlatformPaint() { | 37 PlatformSurface VectorPlatformDeviceSkia::BeginPlatformPaint() { |
38 // Even when drawing a vector representation of the page, we have to | 38 // Even when drawing a vector representation of the page, we have to |
39 // provide a raster surface for plugins to render into - they don't have | 39 // provide a raster surface for plugins to render into - they don't have |
40 // a vector interface. Therefore we create a BitmapPlatformDevice here | 40 // a vector interface. Therefore we create a BitmapPlatformDevice here |
41 // and return the context from it, then layer on the raster data as an | 41 // and return the context from it, then layer on the raster data as an |
42 // image in EndPlatformPaint. | 42 // image in EndPlatformPaint. |
43 DCHECK(raster_surface_ == NULL); | 43 DCHECK(raster_surface_ == NULL); |
44 #if defined(OS_WIN) | 44 raster_surface_ = BitmapPlatformDevice::CreateAndClear(width(), height(), |
45 raster_surface_ = BitmapPlatformDevice::create(width(), | 45 false); |
46 height(), | |
47 false, /* not opaque */ | |
48 NULL); | |
49 #elif defined(OS_POSIX) && !defined(OS_MACOSX) | |
50 raster_surface_ = BitmapPlatformDevice::Create(width(), | |
51 height(), | |
52 false /* not opaque */); | |
53 #endif | |
54 raster_surface_->unref(); // SkRefPtr and create both took a reference. | 46 raster_surface_->unref(); // SkRefPtr and create both took a reference. |
55 | |
56 SkCanvas canvas(raster_surface_.get()); | |
57 return raster_surface_->BeginPlatformPaint(); | 47 return raster_surface_->BeginPlatformPaint(); |
58 } | 48 } |
59 | 49 |
60 void VectorPlatformDeviceSkia::EndPlatformPaint() { | 50 void VectorPlatformDeviceSkia::EndPlatformPaint() { |
61 DCHECK(raster_surface_ != NULL); | 51 DCHECK(raster_surface_ != NULL); |
62 SkPaint paint; | 52 SkPaint paint; |
63 // SkPDFDevice checks the passed SkDraw for an empty clip (only). Fake | 53 // SkPDFDevice checks the passed SkDraw for an empty clip (only). Fake |
64 // it out by setting a non-empty clip. | 54 // it out by setting a non-empty clip. |
65 SkDraw draw; | 55 SkDraw draw; |
66 SkRegion clip(SkIRect::MakeWH(width(), height())); | 56 SkRegion clip(SkIRect::MakeWH(width(), height())); |
(...skipping 23 matching lines...) Expand all Loading... |
90 } | 80 } |
91 #elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_OPENBSD) | 81 #elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_OPENBSD) |
92 void VectorPlatformDeviceSkia::DrawToNativeContext( | 82 void VectorPlatformDeviceSkia::DrawToNativeContext( |
93 PlatformSurface surface, int x, int y, const PlatformRect* src_rect) { | 83 PlatformSurface surface, int x, int y, const PlatformRect* src_rect) { |
94 // Should never be called on Linux. | 84 // Should never be called on Linux. |
95 SkASSERT(false); | 85 SkASSERT(false); |
96 } | 86 } |
97 #endif | 87 #endif |
98 | 88 |
99 } // namespace skia | 89 } // namespace skia |
OLD | NEW |