Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: skia/ext/vector_platform_device_skia.cc

Issue 6879098: Fix print preview clipping issues due to scaling. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Proposed modification to metafile interface. Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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* noUsed, 16 SkDevice* VectorPlatformDeviceSkiaFactory::newDevice(SkCanvas* noUsed,
17 SkBitmap::Config config, 17 SkBitmap::Config config,
18 int width, int height, 18 int width, int height,
19 bool isOpaque, 19 bool isOpaque,
20 bool isForLayer) { 20 bool isForLayer) {
21 SkASSERT(config == SkBitmap::kARGB_8888_Config); 21 SkASSERT(config == SkBitmap::kARGB_8888_Config);
22 SkMatrix initialTransform; 22 SkMatrix initialTransform;
23 initialTransform.reset(); 23 initialTransform.reset();
24 if (isForLayer) { 24 if (isForLayer) {
25 initialTransform.setTranslate(0, height); 25 initialTransform.setTranslate(0, height);
26 initialTransform.preScale(1, -1); 26 initialTransform.preScale(1, -1);
27 } 27 }
28 return new VectorPlatformDeviceSkia(width, height, initialTransform); 28 SkSize device_size = SkSize::Make(width, height);
29 SkRefPtr<SkPDFDevice> pdf_device =
30 new SkPDFDevice(device_size, device_size, initialTransform);
31 pdf_device->unref(); // SkRefPtr and new both took a reference.
32 return new VectorPlatformDeviceSkia(pdf_device.get(), initialTransform);
29 } 33 }
30 34
31 static inline SkBitmap makeABitmap(int width, int height) { 35 static inline SkBitmap makeABitmap(int width, int height) {
32 SkBitmap bitmap; 36 SkBitmap bitmap;
33 bitmap.setConfig(SkBitmap::kNo_Config, width, height); 37 bitmap.setConfig(SkBitmap::kNo_Config, width, height);
34 return bitmap; 38 return bitmap;
35 } 39 }
36 40
37 VectorPlatformDeviceSkia::VectorPlatformDeviceSkia( 41 VectorPlatformDeviceSkia::VectorPlatformDeviceSkia(
38 int width, int height, const SkMatrix& initialTransform) 42 SkPDFDevice* pdf_device, const SkMatrix& initialTransform)
39 : PlatformDevice(makeABitmap(width, height)), 43 : PlatformDevice(makeABitmap(pdf_device->width(), pdf_device->height())),
40 pdf_device_(new SkPDFDevice(width, height, initialTransform)) { 44 pdf_device_(pdf_device) {
41 pdf_device_->unref(); // SkRefPtr and new both took a reference.
42 } 45 }
43 46
44 VectorPlatformDeviceSkia::~VectorPlatformDeviceSkia() { 47 VectorPlatformDeviceSkia::~VectorPlatformDeviceSkia() {
45 } 48 }
46 49
47 bool VectorPlatformDeviceSkia::IsVectorial() { 50 bool VectorPlatformDeviceSkia::IsVectorial() {
48 return true; 51 return true;
49 } 52 }
50 53
51 bool VectorPlatformDeviceSkia::IsNativeFontRenderingAllowed() { 54 bool VectorPlatformDeviceSkia::IsNativeFontRenderingAllowed() {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 #if defined(OS_WIN) 223 #if defined(OS_WIN)
221 void VectorPlatformDeviceSkia::drawToHDC(HDC dc, 224 void VectorPlatformDeviceSkia::drawToHDC(HDC dc,
222 int x, 225 int x,
223 int y, 226 int y,
224 const RECT* src_rect) { 227 const RECT* src_rect) {
225 SkASSERT(false); 228 SkASSERT(false);
226 } 229 }
227 #endif 230 #endif
228 231
229 } // namespace skia 232 } // namespace skia
OLDNEW
« skia/ext/vector_platform_device_skia.h ('K') | « skia/ext/vector_platform_device_skia.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698