| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 25 matching lines...) Expand all Loading... |
| 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 raster_surface_ = BitmapPlatformDevice::CreateAndClear(width(), height(), | 44 raster_surface_ = BitmapPlatformDevice::CreateAndClear(width(), height(), |
| 45 false); | 45 false); |
| 46 raster_surface_->unref(); // SkRefPtr and create both took a reference. | |
| 47 return raster_surface_->BeginPlatformPaint(); | 46 return raster_surface_->BeginPlatformPaint(); |
| 48 } | 47 } |
| 49 | 48 |
| 50 void VectorPlatformDeviceSkia::EndPlatformPaint() { | 49 void VectorPlatformDeviceSkia::EndPlatformPaint() { |
| 51 DCHECK(raster_surface_ != NULL); | 50 DCHECK(raster_surface_ != NULL); |
| 52 SkPaint paint; | 51 SkPaint paint; |
| 53 // SkPDFDevice checks the passed SkDraw for an empty clip (only). Fake | 52 // SkPDFDevice checks the passed SkDraw for an empty clip (only). Fake |
| 54 // it out by setting a non-empty clip. | 53 // it out by setting a non-empty clip. |
| 55 SkDraw draw; | 54 SkDraw draw; |
| 56 SkRegion clip(SkIRect::MakeWH(width(), height())); | 55 SkRegion clip(SkIRect::MakeWH(width(), height())); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 80 } | 79 } |
| 81 #elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_OPENBSD) | 80 #elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_OPENBSD) |
| 82 void VectorPlatformDeviceSkia::DrawToNativeContext( | 81 void VectorPlatformDeviceSkia::DrawToNativeContext( |
| 83 PlatformSurface surface, int x, int y, const PlatformRect* src_rect) { | 82 PlatformSurface surface, int x, int y, const PlatformRect* src_rect) { |
| 84 // Should never be called on Linux. | 83 // Should never be called on Linux. |
| 85 SkASSERT(false); | 84 SkASSERT(false); |
| 86 } | 85 } |
| 87 #endif | 86 #endif |
| 88 | 87 |
| 89 } // namespace skia | 88 } // namespace skia |
| OLD | NEW |