| 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 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 raster_surface_ = BitmapPlatformDevice::CreateAndClear(width(), height(), | 44 raster_surface_ = skia::AdoptRef( |
| 45 false); | 45 BitmapPlatformDevice::CreateAndClear(width(), height(), 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())); |
| 57 draw.fClip=&clip; | 56 draw.fClip=&clip; |
| 58 drawSprite(draw, raster_surface_->accessBitmap(false), 0, 0, paint); | 57 drawSprite(draw, raster_surface_->accessBitmap(false), 0, 0, paint); |
| 59 // BitmapPlatformDevice matches begin and end calls. | 58 // BitmapPlatformDevice matches begin and end calls. |
| 60 raster_surface_->EndPlatformPaint(); | 59 raster_surface_->EndPlatformPaint(); |
| 61 raster_surface_ = NULL; | 60 raster_surface_.clear(); |
| 62 } | 61 } |
| 63 | 62 |
| 64 #if defined(OS_WIN) | 63 #if defined(OS_WIN) |
| 65 void VectorPlatformDeviceSkia::DrawToNativeContext(HDC dc, | 64 void VectorPlatformDeviceSkia::DrawToNativeContext(HDC dc, |
| 66 int x, | 65 int x, |
| 67 int y, | 66 int y, |
| 68 const RECT* src_rect) { | 67 const RECT* src_rect) { |
| 69 SkASSERT(false); | 68 SkASSERT(false); |
| 70 } | 69 } |
| 71 #elif defined(OS_MACOSX) | 70 #elif defined(OS_MACOSX) |
| 72 void VectorPlatformDeviceSkia::DrawToNativeContext(CGContext* context, int x, | 71 void VectorPlatformDeviceSkia::DrawToNativeContext(CGContext* context, int x, |
| 73 int y, const CGRect* src_rect) { | 72 int y, const CGRect* src_rect) { |
| 74 SkASSERT(false); | 73 SkASSERT(false); |
| 75 } | 74 } |
| 76 | 75 |
| 77 CGContextRef VectorPlatformDeviceSkia::GetBitmapContext() { | 76 CGContextRef VectorPlatformDeviceSkia::GetBitmapContext() { |
| 78 SkASSERT(false); | 77 SkASSERT(false); |
| 79 return NULL; | 78 return NULL; |
| 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 |