Instrumented libraries: update configure flags for libgcrypt11.
[chromium-blink-merge.git] / skia / ext / vector_platform_device_skia.cc
blob5b8217c12b5d80d64babe151b9af0dffe27a12b8
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
3 // found in the LICENSE file.
5 #include "skia/ext/vector_platform_device_skia.h"
7 #include "skia/ext/bitmap_platform_device.h"
8 #include "third_party/skia/include/core/SkClipStack.h"
9 #include "third_party/skia/include/core/SkDraw.h"
10 #include "third_party/skia/include/core/SkRect.h"
11 #include "third_party/skia/include/core/SkRegion.h"
12 #include "third_party/skia/include/core/SkScalar.h"
14 namespace skia {
16 static inline SkBitmap makeABitmap(int width, int height) {
17 SkBitmap bitmap;
18 bitmap.setInfo(SkImageInfo::MakeUnknown(width, height));
19 return bitmap;
22 VectorPlatformDeviceSkia::VectorPlatformDeviceSkia(
23 const SkISize& pageSize,
24 const SkISize& contentSize,
25 const SkMatrix& initialTransform)
26 : SkPDFDevice(pageSize, contentSize, initialTransform) {
27 SetPlatformDevice(this, this);
30 VectorPlatformDeviceSkia::~VectorPlatformDeviceSkia() {
33 bool VectorPlatformDeviceSkia::SupportsPlatformPaint() {
34 return false;
37 PlatformSurface VectorPlatformDeviceSkia::BeginPlatformPaint() {
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
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
42 // image in EndPlatformPaint.
43 DCHECK(raster_surface_ == NULL);
44 raster_surface_ = skia::AdoptRef(
45 BitmapPlatformDevice::CreateAndClear(width(), height(), false));
46 return raster_surface_->BeginPlatformPaint();
49 void VectorPlatformDeviceSkia::EndPlatformPaint() {
50 DCHECK(raster_surface_ != NULL);
51 SkPaint paint;
52 // SkPDFDevice checks the passed SkDraw for an empty clip (only). Fake
53 // it out by setting a non-empty clip.
54 SkDraw draw;
55 SkRegion clip(SkIRect::MakeWH(width(), height()));
56 draw.fClip=&clip;
57 drawSprite(draw, raster_surface_->accessBitmap(false), 0, 0, paint);
58 // BitmapPlatformDevice matches begin and end calls.
59 raster_surface_->EndPlatformPaint();
60 raster_surface_.clear();
63 #if defined(OS_WIN)
64 void VectorPlatformDeviceSkia::DrawToNativeContext(HDC dc,
65 int x,
66 int y,
67 const RECT* src_rect) {
68 SkASSERT(false);
70 #elif defined(OS_MACOSX)
71 void VectorPlatformDeviceSkia::DrawToNativeContext(CGContext* context, int x,
72 int y, const CGRect* src_rect) {
73 SkASSERT(false);
76 CGContextRef VectorPlatformDeviceSkia::GetBitmapContext() {
77 SkASSERT(false);
78 return NULL;
80 #elif defined(OS_POSIX)
81 void VectorPlatformDeviceSkia::DrawToNativeContext(
82 PlatformSurface surface, int x, int y, const PlatformRect* src_rect) {
83 // Should never be called on Linux.
84 SkASSERT(false);
86 #endif
88 } // namespace skia