diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-07 21:30:39 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-07 21:30:39 +0000 |
commit | 4b63c934d571a5a1d773fd3129edeab4bd2c4504 (patch) | |
tree | 50f0df251c814e91a0a0510e9f76cb3b972e2fc7 /skia/ext/vector_platform_device_skia.h | |
parent | 8360c7edcb39a407723ce7c32a0fabeeae397f7a (diff) | |
download | chromium_src-4b63c934d571a5a1d773fd3129edeab4bd2c4504.zip chromium_src-4b63c934d571a5a1d773fd3129edeab4bd2c4504.tar.gz chromium_src-4b63c934d571a5a1d773fd3129edeab4bd2c4504.tar.bz2 |
+ This CL pulls in all the PDF code (i.e. we are now compiling the PDF backend on Chrome).
+ Add a Metafile to contain Skia PDF content.
+ Add a VectorPlatformDevice for use with the Skia PDF backend.
BUG=62889
TEST=NONE
Review URL: http://codereview.chromium.org/6499024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80841 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/vector_platform_device_skia.h')
-rw-r--r-- | skia/ext/vector_platform_device_skia.h | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/skia/ext/vector_platform_device_skia.h b/skia/ext/vector_platform_device_skia.h new file mode 100644 index 0000000..38cf0c5 --- /dev/null +++ b/skia/ext/vector_platform_device_skia.h @@ -0,0 +1,106 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SKIA_EXT_VECTOR_PLATFORM_DEVICE_SKIA_H_ +#define SKIA_EXT_VECTOR_PLATFORM_DEVICE_SKIA_H_ +#pragma once + +#include "base/basictypes.h" +#include "base/logging.h" +#include "skia/ext/platform_device.h" +#include "third_party/skia/include/core/SkMatrix.h" +#include "third_party/skia/include/core/SkRefCnt.h" +#include "third_party/skia/include/core/SkTScopedPtr.h" +#include "third_party/skia/include/pdf/SkPDFDevice.h" + +class SkClipStack; +struct SkIRect; +struct SkRect; + +namespace skia { + +class BitmapPlatformDevice; + +class VectorPlatformDeviceSkiaFactory : public SkDeviceFactory { + public: + virtual SkDevice* newDevice(SkCanvas* notUsed, SkBitmap::Config config, + int width, int height, bool isOpaque, + bool isForLayer); +}; + +class VectorPlatformDeviceSkia : public PlatformDevice { + public: + VectorPlatformDeviceSkia(int width, int height, + SkPDFDevice::OriginTransform flip); + + ~VectorPlatformDeviceSkia(); + + SkPDFDevice* PdfDevice() { return pdf_device_.get(); } + + // PlatformDevice methods. + virtual bool IsVectorial(); + virtual bool IsNativeFontRenderingAllowed(); + + virtual PlatformSurface BeginPlatformPaint(); + virtual void EndPlatformPaint(); + + // SkDevice methods. + virtual SkDeviceFactory* getDeviceFactory(); + virtual uint32_t getDeviceCapabilities(); + + virtual int width() const; + virtual int height() const; + virtual void setMatrixClip(const SkMatrix& matrix, const SkRegion& region, + const SkClipStack& stack); + virtual bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap); + + virtual void drawPaint(const SkDraw& draw, const SkPaint& paint); + virtual void drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, + size_t count, const SkPoint[], const SkPaint& paint); + virtual void drawRect(const SkDraw& draw, const SkRect& rect, + const SkPaint& paint); + virtual void drawPath(const SkDraw& draw, const SkPath& path, + const SkPaint& paint, const SkMatrix* prePathMatrix, + bool pathIsMutable); + virtual void drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, + const SkIRect* srcRectOrNull, const SkMatrix& matrix, + const SkPaint& paint); + virtual void drawSprite(const SkDraw& draw, const SkBitmap& bitmap, + int x, int y, const SkPaint& paint); + virtual void drawText(const SkDraw& draw, const void* text, size_t len, + SkScalar x, SkScalar y, const SkPaint& paint); + virtual void drawPosText(const SkDraw& draw, const void* text, size_t len, + const SkScalar pos[], SkScalar constY, + int scalarsPerPos, const SkPaint& paint); + virtual void drawTextOnPath(const SkDraw& draw, const void* text, size_t len, + const SkPath& path, const SkMatrix* matrix, + const SkPaint& paint); + virtual void drawVertices(const SkDraw& draw, SkCanvas::VertexMode, + int vertexCount, const SkPoint verts[], + const SkPoint texs[], const SkColor colors[], + SkXfermode* xmode, const uint16_t indices[], + int indexCount, const SkPaint& paint); + virtual void drawDevice(const SkDraw& draw, SkDevice*, int x, int y, + const SkPaint&); + +#if defined(OS_WIN) + virtual void drawToHDC(HDC dc, int x, int y, const RECT* src_rect); +#endif + + // Our own methods. + + // This needs to be called before anything is drawn. + void setInitialTransform(int xOffset, int yOffset, float scale_factor); + + private: + SkRefPtr<SkPDFDevice> pdf_device_; + SkMatrix base_transform_; + SkRefPtr<BitmapPlatformDevice> raster_surface_; + + DISALLOW_COPY_AND_ASSIGN(VectorPlatformDeviceSkia); +}; + +} // namespace skia + +#endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_SKIA_H_ |