2011-07-28 14:26:00 +00:00
|
|
|
|
2010-10-20 22:23:29 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2011 Google Inc.
|
2010-10-20 22:23:29 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2010-10-20 22:23:29 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
2010-10-20 22:23:29 +00:00
|
|
|
#ifndef SkPDFDevice_DEFINED
|
|
|
|
#define SkPDFDevice_DEFINED
|
|
|
|
|
2013-08-29 11:54:56 +00:00
|
|
|
#include "SkBitmapDevice.h"
|
2013-10-14 13:42:12 +00:00
|
|
|
#include "SkBitmap.h"
|
2011-05-24 17:19:38 +00:00
|
|
|
#include "SkCanvas.h"
|
2010-10-26 19:48:49 +00:00
|
|
|
#include "SkPaint.h"
|
|
|
|
#include "SkPath.h"
|
2013-10-03 19:29:21 +00:00
|
|
|
#include "SkPicture.h"
|
2012-07-13 20:06:02 +00:00
|
|
|
#include "SkRect.h"
|
2011-05-09 07:55:58 +00:00
|
|
|
#include "SkRefCnt.h"
|
|
|
|
#include "SkStream.h"
|
2013-03-08 09:09:10 +00:00
|
|
|
#include "SkTDArray.h"
|
2013-08-29 22:14:04 +00:00
|
|
|
#include "SkTemplates.h"
|
2010-10-20 22:23:29 +00:00
|
|
|
|
|
|
|
class SkPDFArray;
|
|
|
|
class SkPDFDevice;
|
|
|
|
class SkPDFDict;
|
PDF: Add text support with a font framework (font embedding to come).
Supports fakeBold, underline, strikethrough, mode (fill, stroke, both), size, skew, alignment (left, center, right).
Missing is drawFontOnPath and font lookup and embedding.
Changed SkPDFString to support how it is used from drawText methods.
Moved compile assert into SkTypes.
Moved constants and utility function used to support fakeBold, underline, and strikethrough into higher level locations.
Review URL: http://codereview.appspot.com/2946041
git-svn-id: http://skia.googlecode.com/svn/trunk@624 2bbb7eff-a529-9590-31e7-b0007b416f81
2010-11-11 21:37:00 +00:00
|
|
|
class SkPDFFont;
|
2011-05-13 03:50:38 +00:00
|
|
|
class SkPDFFormXObject;
|
2011-07-25 22:34:12 +00:00
|
|
|
class SkPDFGlyphSetMap;
|
2010-10-20 22:23:29 +00:00
|
|
|
class SkPDFGraphicState;
|
|
|
|
class SkPDFObject;
|
2013-07-23 21:49:29 +00:00
|
|
|
class SkPDFResourceDict;
|
2011-03-08 18:31:02 +00:00
|
|
|
class SkPDFShader;
|
2010-10-20 22:23:29 +00:00
|
|
|
class SkPDFStream;
|
2013-11-08 18:02:53 +00:00
|
|
|
class SkRRect;
|
2013-05-31 18:04:20 +00:00
|
|
|
template <typename T> class SkTSet;
|
2010-10-20 22:23:29 +00:00
|
|
|
|
2011-05-09 07:55:58 +00:00
|
|
|
// Private classes.
|
|
|
|
struct ContentEntry;
|
|
|
|
struct GraphicStateEntry;
|
2013-03-08 09:09:10 +00:00
|
|
|
struct NamedDestination;
|
2011-05-09 07:55:58 +00:00
|
|
|
|
2010-10-20 22:23:29 +00:00
|
|
|
/** \class SkPDFDevice
|
|
|
|
|
|
|
|
The drawing context for the PDF backend.
|
|
|
|
*/
|
2013-08-29 11:54:56 +00:00
|
|
|
class SkPDFDevice : public SkBitmapDevice {
|
2010-10-20 22:23:29 +00:00
|
|
|
public:
|
|
|
|
/** Create a PDF drawing context with the given width and height.
|
|
|
|
* 72 points/in means letter paper is 612x792.
|
2011-04-29 17:54:16 +00:00
|
|
|
* @param pageSize Page size in points.
|
|
|
|
* @param contentSize The content size of the page in points. This will be
|
|
|
|
* combined with the initial transform to determine the drawing area
|
|
|
|
* (as reported by the width and height methods). Anything outside
|
|
|
|
* of the drawing area will be clipped.
|
2011-04-11 23:24:18 +00:00
|
|
|
* @param initialTransform The initial transform to apply to the page.
|
|
|
|
* This may be useful to, for example, move the origin in and
|
|
|
|
* over a bit to account for a margin, scale the canvas,
|
|
|
|
* or apply a rotation. Note1: the SkPDFDevice also applies
|
|
|
|
* a scale+translate transform to move the origin from the
|
|
|
|
* bottom left (PDF default) to the top left. Note2: drawDevice
|
|
|
|
* (used by layer restore) draws the device after this initial
|
2011-07-06 20:00:52 +00:00
|
|
|
* transform is applied, so the PDF device does an
|
2011-04-11 23:24:18 +00:00
|
|
|
* inverse scale+translate to accommodate the one that SkPDFDevice
|
|
|
|
* always does.
|
2010-10-20 22:23:29 +00:00
|
|
|
*/
|
2013-10-14 13:42:12 +00:00
|
|
|
// Deprecated, please use SkDocument::CreatePdf() instead.
|
2011-04-29 17:54:16 +00:00
|
|
|
SK_API SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize,
|
|
|
|
const SkMatrix& initialTransform);
|
|
|
|
SK_API virtual ~SkPDFDevice();
|
2010-10-20 22:23:29 +00:00
|
|
|
|
2011-12-07 18:34:08 +00:00
|
|
|
virtual uint32_t getDeviceCapabilities() SK_OVERRIDE;
|
2010-10-26 19:47:30 +00:00
|
|
|
|
2011-12-07 18:34:08 +00:00
|
|
|
virtual void clear(SkColor color) SK_OVERRIDE;
|
2011-04-15 20:57:37 +00:00
|
|
|
|
2010-10-20 22:23:29 +00:00
|
|
|
/** These are called inside the per-device-layer loop for each draw call.
|
|
|
|
When these are called, we have already applied any saveLayer operations,
|
|
|
|
and are handling any looping from the paint, and any effects from the
|
|
|
|
DrawFilter.
|
|
|
|
*/
|
2011-12-07 18:34:08 +00:00
|
|
|
virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE;
|
2010-10-20 22:23:29 +00:00
|
|
|
virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode,
|
|
|
|
size_t count, const SkPoint[],
|
2011-12-07 18:34:08 +00:00
|
|
|
const SkPaint& paint) SK_OVERRIDE;
|
2010-10-20 22:23:29 +00:00
|
|
|
virtual void drawRect(const SkDraw&, const SkRect& r, const SkPaint& paint);
|
2013-11-08 18:02:53 +00:00
|
|
|
virtual void drawRRect(const SkDraw&, const SkRRect& rr,
|
|
|
|
const SkPaint& paint) SK_OVERRIDE;
|
2011-05-17 18:58:44 +00:00
|
|
|
virtual void drawPath(const SkDraw&, const SkPath& origpath,
|
2011-01-25 22:06:29 +00:00
|
|
|
const SkPaint& paint, const SkMatrix* prePathMatrix,
|
2011-12-07 18:34:08 +00:00
|
|
|
bool pathIsMutable) SK_OVERRIDE;
|
2013-02-12 01:06:38 +00:00
|
|
|
virtual void drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
|
|
|
|
const SkRect* src, const SkRect& dst,
|
2013-08-16 10:24:37 +00:00
|
|
|
const SkPaint& paint,
|
|
|
|
SkCanvas::DrawBitmapRectFlags flags) SK_OVERRIDE;
|
2010-10-20 22:23:29 +00:00
|
|
|
virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
|
2011-12-07 18:34:08 +00:00
|
|
|
const SkMatrix& matrix, const SkPaint&) SK_OVERRIDE;
|
2010-10-20 22:23:29 +00:00
|
|
|
virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap, int x, int y,
|
2011-12-07 18:34:08 +00:00
|
|
|
const SkPaint& paint) SK_OVERRIDE;
|
2010-10-20 22:23:29 +00:00
|
|
|
virtual void drawText(const SkDraw&, const void* text, size_t len,
|
2011-12-07 18:34:08 +00:00
|
|
|
SkScalar x, SkScalar y, const SkPaint&) SK_OVERRIDE;
|
2010-10-20 22:23:29 +00:00
|
|
|
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
|
|
|
|
const SkScalar pos[], SkScalar constY,
|
2011-12-07 18:34:08 +00:00
|
|
|
int scalarsPerPos, const SkPaint&) SK_OVERRIDE;
|
2010-10-20 22:23:29 +00:00
|
|
|
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
|
|
|
|
const SkPath& path, const SkMatrix* matrix,
|
2011-12-07 18:34:08 +00:00
|
|
|
const SkPaint& paint) SK_OVERRIDE;
|
2010-10-20 22:23:29 +00:00
|
|
|
virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode,
|
|
|
|
int vertexCount, const SkPoint verts[],
|
|
|
|
const SkPoint texs[], const SkColor colors[],
|
|
|
|
SkXfermode* xmode, const uint16_t indices[],
|
2011-12-07 18:34:08 +00:00
|
|
|
int indexCount, const SkPaint& paint) SK_OVERRIDE;
|
2013-08-29 11:54:56 +00:00
|
|
|
virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
|
2011-12-07 18:34:08 +00:00
|
|
|
const SkPaint&) SK_OVERRIDE;
|
2010-10-20 22:23:29 +00:00
|
|
|
|
2012-07-13 15:36:15 +00:00
|
|
|
virtual void onAttachToCanvas(SkCanvas* canvas) SK_OVERRIDE;
|
|
|
|
virtual void onDetachFromCanvas() SK_OVERRIDE;
|
|
|
|
|
2011-07-12 21:56:27 +00:00
|
|
|
enum DrawingArea {
|
2011-07-27 00:10:51 +00:00
|
|
|
kContent_DrawingArea, // Drawing area for the page content.
|
|
|
|
kMargin_DrawingArea, // Drawing area for the margin content.
|
2011-07-12 21:56:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Sets the drawing area for the device. Subsequent draw calls are directed
|
2011-08-20 00:36:18 +00:00
|
|
|
* to the specific drawing area (margin or content). The default drawing
|
2011-07-12 21:56:27 +00:00
|
|
|
* area is the content drawing area.
|
2011-07-27 00:10:51 +00:00
|
|
|
*
|
|
|
|
* Currently if margin content is drawn and then a complex (for PDF) xfer
|
|
|
|
* mode is used, like SrcIn, Clear, etc, the margin content will get
|
|
|
|
* clipped. A simple way to avoid the bug is to always draw the margin
|
|
|
|
* content last.
|
2011-07-12 21:56:27 +00:00
|
|
|
*/
|
2011-08-26 14:40:38 +00:00
|
|
|
SK_API void setDrawingArea(DrawingArea drawingArea);
|
2011-07-12 21:56:27 +00:00
|
|
|
|
2013-04-24 13:01:01 +00:00
|
|
|
/** Sets the DCTEncoder for images.
|
|
|
|
* @param encoder The encoder to encode a bitmap as JPEG (DCT).
|
|
|
|
* Result of encodings are cached, if the encoder changes the
|
|
|
|
* behaivor dynamically and an image is added to a second catalog,
|
|
|
|
* we will likely use the result of the first encoding call.
|
|
|
|
* By returning false from the encoder function, the encoder result
|
|
|
|
* is not used.
|
|
|
|
* Callers might not want to encode small images, as the time spent
|
|
|
|
* encoding and decoding might not be worth the space savings,
|
|
|
|
* if any at all.
|
|
|
|
*/
|
2013-10-03 19:29:21 +00:00
|
|
|
void setDCTEncoder(SkPicture::EncodeBitmap encoder) {
|
2013-04-24 13:01:01 +00:00
|
|
|
fEncoder = encoder;
|
|
|
|
}
|
|
|
|
|
2010-10-20 22:23:29 +00:00
|
|
|
// PDF specific methods.
|
|
|
|
|
2011-07-20 18:43:19 +00:00
|
|
|
/** Returns the resource dictionary for this device.
|
2010-10-20 22:23:29 +00:00
|
|
|
*/
|
2013-07-23 21:49:29 +00:00
|
|
|
SK_API SkPDFResourceDict* getResourceDict();
|
2010-10-20 22:23:29 +00:00
|
|
|
|
2011-05-29 05:55:42 +00:00
|
|
|
/** Get the fonts used on this device.
|
|
|
|
*/
|
2011-05-30 20:52:33 +00:00
|
|
|
SK_API const SkTDArray<SkPDFFont*>& getFontResources() const;
|
2011-05-29 05:55:42 +00:00
|
|
|
|
2013-03-08 09:09:10 +00:00
|
|
|
/** Add our named destinations to the supplied dictionary.
|
|
|
|
* @param dict Dictionary to add destinations to.
|
|
|
|
* @param page The PDF object representing the page for this device.
|
|
|
|
*/
|
|
|
|
void appendDestinations(SkPDFDict* dict, SkPDFObject* page);
|
|
|
|
|
2012-09-19 17:05:55 +00:00
|
|
|
/** Returns a copy of the media box for this device. The caller is required
|
|
|
|
* to unref() this when it is finished.
|
2010-10-20 22:23:29 +00:00
|
|
|
*/
|
2012-09-19 17:05:55 +00:00
|
|
|
SK_API SkPDFArray* copyMediaBox() const;
|
2010-10-20 22:23:29 +00:00
|
|
|
|
2012-09-19 17:05:55 +00:00
|
|
|
/** Get the annotations from this page, or NULL if there are none.
|
2012-07-13 20:06:02 +00:00
|
|
|
*/
|
2012-09-19 17:05:55 +00:00
|
|
|
SK_API SkPDFArray* getAnnotations() const { return fAnnotations; }
|
2012-07-13 20:06:02 +00:00
|
|
|
|
2011-02-24 23:22:30 +00:00
|
|
|
/** Returns a SkStream with the page contents. The caller is responsible
|
|
|
|
for a reference to the returned value.
|
2011-06-27 14:42:15 +00:00
|
|
|
DEPRECATED: use copyContentToData()
|
2010-10-20 22:23:29 +00:00
|
|
|
*/
|
2011-05-30 20:52:33 +00:00
|
|
|
SK_API SkStream* content() const;
|
2010-10-20 22:23:29 +00:00
|
|
|
|
2011-06-27 14:42:15 +00:00
|
|
|
/** Returns a SkStream with the page contents. The caller is responsible
|
|
|
|
* for calling data->unref() when it is finished.
|
|
|
|
*/
|
|
|
|
SK_API SkData* copyContentToData() const;
|
2011-07-25 22:34:12 +00:00
|
|
|
|
2011-05-30 20:52:33 +00:00
|
|
|
SK_API const SkMatrix& initialTransform() const {
|
|
|
|
return fInitialTransform;
|
|
|
|
}
|
2011-05-24 23:02:07 +00:00
|
|
|
|
2011-07-25 22:34:12 +00:00
|
|
|
/** Returns a SkPDFGlyphSetMap which represents glyph usage of every font
|
|
|
|
* that shows on this device.
|
|
|
|
*/
|
|
|
|
const SkPDFGlyphSetMap& getFontGlyphUsage() const {
|
|
|
|
return *(fFontGlyphUsage.get());
|
|
|
|
}
|
2012-01-28 01:45:11 +00:00
|
|
|
|
2011-11-02 19:57:21 +00:00
|
|
|
protected:
|
2011-12-07 18:34:08 +00:00
|
|
|
virtual bool onReadPixels(const SkBitmap& bitmap, int x, int y,
|
|
|
|
SkCanvas::Config8888) SK_OVERRIDE;
|
2011-07-25 22:34:12 +00:00
|
|
|
|
2012-01-06 14:43:09 +00:00
|
|
|
virtual bool allowImageFilter(SkImageFilter*) SK_OVERRIDE;
|
|
|
|
|
2013-10-21 17:14:37 +00:00
|
|
|
/**
|
|
|
|
* rasterDpi - the DPI at which features without native PDF support
|
|
|
|
* will be rasterized (e.g. draw image with perspective,
|
|
|
|
* draw text with perspective, ...)
|
|
|
|
* A larger DPI would create a PDF that reflects the original
|
|
|
|
* intent with better fidelity, but it can make for larger
|
|
|
|
* PDF files too, which would use more memory while rendering,
|
|
|
|
* and it would be slower to be processed or sent online or
|
|
|
|
* to printer.
|
|
|
|
*/
|
|
|
|
void setRasterDpi(SkScalar rasterDpi) {
|
|
|
|
fRasterDpi = rasterDpi;
|
|
|
|
}
|
|
|
|
|
2010-10-20 22:23:29 +00:00
|
|
|
private:
|
2011-08-20 00:36:18 +00:00
|
|
|
// TODO(vandebo): push most of SkPDFDevice's state into a core object in
|
2011-05-24 17:19:38 +00:00
|
|
|
// order to get the right access levels without using friend.
|
2011-05-24 23:12:41 +00:00
|
|
|
friend class ScopedContentEntry;
|
2011-05-09 07:58:08 +00:00
|
|
|
|
2011-04-29 17:54:16 +00:00
|
|
|
SkISize fPageSize;
|
2011-05-09 07:55:58 +00:00
|
|
|
SkISize fContentSize;
|
2011-04-11 23:24:18 +00:00
|
|
|
SkMatrix fInitialTransform;
|
2011-05-09 07:55:58 +00:00
|
|
|
SkClipStack fExistingClipStack;
|
|
|
|
SkRegion fExistingClipRegion;
|
2012-09-19 17:05:55 +00:00
|
|
|
SkPDFArray* fAnnotations;
|
2013-07-23 21:49:29 +00:00
|
|
|
SkPDFResourceDict* fResourceDict;
|
2013-03-08 09:09:10 +00:00
|
|
|
SkTDArray<NamedDestination*> fNamedDestinations;
|
2010-10-20 22:23:29 +00:00
|
|
|
|
|
|
|
SkTDArray<SkPDFGraphicState*> fGraphicStateResources;
|
|
|
|
SkTDArray<SkPDFObject*> fXObjectResources;
|
PDF: Add text support with a font framework (font embedding to come).
Supports fakeBold, underline, strikethrough, mode (fill, stroke, both), size, skew, alignment (left, center, right).
Missing is drawFontOnPath and font lookup and embedding.
Changed SkPDFString to support how it is used from drawText methods.
Moved compile assert into SkTypes.
Moved constants and utility function used to support fakeBold, underline, and strikethrough into higher level locations.
Review URL: http://codereview.appspot.com/2946041
git-svn-id: http://skia.googlecode.com/svn/trunk@624 2bbb7eff-a529-9590-31e7-b0007b416f81
2010-11-11 21:37:00 +00:00
|
|
|
SkTDArray<SkPDFFont*> fFontResources;
|
2011-07-20 17:39:01 +00:00
|
|
|
SkTDArray<SkPDFObject*> fShaderResources;
|
2010-10-20 22:23:29 +00:00
|
|
|
|
2013-08-29 22:14:04 +00:00
|
|
|
SkAutoTDelete<ContentEntry> fContentEntries;
|
2011-05-24 17:19:38 +00:00
|
|
|
ContentEntry* fLastContentEntry;
|
2013-08-29 22:14:04 +00:00
|
|
|
SkAutoTDelete<ContentEntry> fMarginContentEntries;
|
2011-07-12 21:56:27 +00:00
|
|
|
ContentEntry* fLastMarginContentEntry;
|
|
|
|
DrawingArea fDrawingArea;
|
|
|
|
|
2012-07-13 15:36:15 +00:00
|
|
|
const SkClipStack* fClipStack;
|
|
|
|
|
2011-07-12 21:56:27 +00:00
|
|
|
// Accessor and setter functions based on the current DrawingArea.
|
2013-08-29 22:14:04 +00:00
|
|
|
SkAutoTDelete<ContentEntry>* getContentEntries();
|
2011-07-12 21:56:27 +00:00
|
|
|
ContentEntry* getLastContentEntry();
|
|
|
|
void setLastContentEntry(ContentEntry* contentEntry);
|
2010-10-20 22:23:29 +00:00
|
|
|
|
2011-07-25 22:34:12 +00:00
|
|
|
// Glyph ids used for each font on this device.
|
2013-08-29 22:14:04 +00:00
|
|
|
SkAutoTDelete<SkPDFGlyphSetMap> fFontGlyphUsage;
|
2011-07-25 22:34:12 +00:00
|
|
|
|
2013-10-03 19:29:21 +00:00
|
|
|
SkPicture::EncodeBitmap fEncoder;
|
2013-10-21 17:14:37 +00:00
|
|
|
SkScalar fRasterDpi;
|
2013-04-24 13:01:01 +00:00
|
|
|
|
2011-05-09 07:58:08 +00:00
|
|
|
SkPDFDevice(const SkISize& layerSize, const SkClipStack& existingClipStack,
|
|
|
|
const SkRegion& existingClipRegion);
|
|
|
|
|
2013-08-29 11:54:56 +00:00
|
|
|
// override from SkBaseDevice
|
|
|
|
virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config,
|
|
|
|
int width, int height,
|
|
|
|
bool isOpaque,
|
|
|
|
Usage usage) SK_OVERRIDE;
|
2011-06-17 13:10:25 +00:00
|
|
|
|
2011-04-15 20:57:37 +00:00
|
|
|
void init();
|
2011-07-25 22:34:12 +00:00
|
|
|
void cleanUp(bool clearFontUsage);
|
2012-09-20 17:52:20 +00:00
|
|
|
SkPDFFormXObject* createFormXObjectFromDevice();
|
2011-05-09 07:55:58 +00:00
|
|
|
|
2013-10-30 20:48:05 +00:00
|
|
|
void drawFormXObjectWithMask(int xObjectIndex,
|
|
|
|
SkPDFFormXObject* mask,
|
[PDF] Add clip support and some optimizations for "complex" xfer modes.
For Clear, Src, Dst/Src-In/Out, we have to consider the current clip, and
potentially draw Dst, clipped to the inverse of the current clip before
doing the operation of interest.
For clear or src, if we haven't drawn anything, or the clip is empty, there's
nothing to be done.
For Src/Dst-In/Out, if either is empty, the result is empty.
Review URL: http://codereview.appspot.com/4538082
git-svn-id: http://skia.googlecode.com/svn/trunk@1407 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-05-24 16:39:05 +00:00
|
|
|
const SkClipStack* clipStack,
|
|
|
|
const SkRegion& clipRegion,
|
2013-10-30 20:48:05 +00:00
|
|
|
SkXfermode::Mode mode,
|
[PDF] Add clip support and some optimizations for "complex" xfer modes.
For Clear, Src, Dst/Src-In/Out, we have to consider the current clip, and
potentially draw Dst, clipped to the inverse of the current clip before
doing the operation of interest.
For clear or src, if we haven't drawn anything, or the clip is empty, there's
nothing to be done.
For Src/Dst-In/Out, if either is empty, the result is empty.
Review URL: http://codereview.appspot.com/4538082
git-svn-id: http://skia.googlecode.com/svn/trunk@1407 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-05-24 16:39:05 +00:00
|
|
|
bool invertClip);
|
2011-05-18 23:06:29 +00:00
|
|
|
|
2011-05-24 17:19:38 +00:00
|
|
|
// If the paint or clip is such that we shouldn't draw anything, this
|
|
|
|
// returns NULL and does not create a content entry.
|
|
|
|
// setUpContentEntry and finishContentEntry can be used directly, but
|
2011-05-24 23:12:41 +00:00
|
|
|
// the preferred method is to use the ScopedContentEntry helper class.
|
2011-05-24 17:19:38 +00:00
|
|
|
ContentEntry* setUpContentEntry(const SkClipStack* clipStack,
|
|
|
|
const SkRegion& clipRegion,
|
|
|
|
const SkMatrix& matrix,
|
|
|
|
const SkPaint& paint,
|
|
|
|
bool hasText,
|
2012-09-20 17:52:20 +00:00
|
|
|
SkPDFFormXObject** dst);
|
2011-05-24 17:19:38 +00:00
|
|
|
void finishContentEntry(SkXfermode::Mode xfermode,
|
2013-10-30 20:48:05 +00:00
|
|
|
SkPDFFormXObject* dst,
|
|
|
|
SkPath* shape);
|
[PDF] Add clip support and some optimizations for "complex" xfer modes.
For Clear, Src, Dst/Src-In/Out, we have to consider the current clip, and
potentially draw Dst, clipped to the inverse of the current clip before
doing the operation of interest.
For clear or src, if we haven't drawn anything, or the clip is empty, there's
nothing to be done.
For Src/Dst-In/Out, if either is empty, the result is empty.
Review URL: http://codereview.appspot.com/4538082
git-svn-id: http://skia.googlecode.com/svn/trunk@1407 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-05-24 16:39:05 +00:00
|
|
|
bool isContentEmpty();
|
|
|
|
|
2011-05-09 07:55:58 +00:00
|
|
|
void populateGraphicStateEntryFromPaint(const SkMatrix& matrix,
|
|
|
|
const SkClipStack& clipStack,
|
|
|
|
const SkRegion& clipRegion,
|
|
|
|
const SkPaint& paint,
|
|
|
|
bool hasText,
|
|
|
|
GraphicStateEntry* entry);
|
2011-05-13 03:50:38 +00:00
|
|
|
int addGraphicStateResource(SkPDFGraphicState* gs);
|
2013-10-30 20:48:05 +00:00
|
|
|
int addXObjectResource(SkPDFObject* xObject);
|
2011-05-09 07:55:58 +00:00
|
|
|
|
2011-05-24 17:19:38 +00:00
|
|
|
void updateFont(const SkPaint& paint, uint16_t glyphID,
|
|
|
|
ContentEntry* contentEntry);
|
2011-03-04 21:43:27 +00:00
|
|
|
int getFontResourceIndex(SkTypeface* typeface, uint16_t glyphID);
|
2011-05-09 07:55:58 +00:00
|
|
|
|
2011-05-24 17:19:38 +00:00
|
|
|
void internalDrawPaint(const SkPaint& paint, ContentEntry* contentEntry);
|
2011-05-09 07:55:58 +00:00
|
|
|
void internalDrawBitmap(const SkMatrix& matrix,
|
2011-05-11 18:46:03 +00:00
|
|
|
const SkClipStack* clipStack,
|
2011-05-09 07:55:58 +00:00
|
|
|
const SkRegion& clipRegion,
|
|
|
|
const SkBitmap& bitmap,
|
|
|
|
const SkIRect* srcRect,
|
|
|
|
const SkPaint& paint);
|
2010-10-20 22:23:29 +00:00
|
|
|
|
2011-07-12 21:56:27 +00:00
|
|
|
/** Helper method for copyContentToData. It is responsible for copying the
|
|
|
|
* list of content entries |entry| to |data|.
|
|
|
|
*/
|
|
|
|
void copyContentEntriesToData(ContentEntry* entry, SkWStream* data) const;
|
2011-07-27 00:10:51 +00:00
|
|
|
|
2013-08-08 02:52:05 +00:00
|
|
|
#ifdef SK_PDF_USE_PATHOPS
|
2013-07-31 22:54:31 +00:00
|
|
|
bool handleInversePath(const SkDraw& d, const SkPath& origPath,
|
2013-10-07 13:22:21 +00:00
|
|
|
const SkPaint& paint, bool pathIsMutable,
|
|
|
|
const SkMatrix* prePathMatrix = NULL);
|
2013-08-08 02:52:05 +00:00
|
|
|
#endif
|
2013-03-08 09:09:10 +00:00
|
|
|
bool handleRectAnnotation(const SkRect& r, const SkMatrix& matrix,
|
|
|
|
const SkPaint& paint);
|
|
|
|
bool handlePointAnnotation(const SkPoint* points, size_t count,
|
|
|
|
const SkMatrix& matrix, const SkPaint& paint);
|
|
|
|
SkPDFDict* createLinkAnnotation(const SkRect& r, const SkMatrix& matrix);
|
|
|
|
void handleLinkToURL(SkData* urlData, const SkRect& r,
|
|
|
|
const SkMatrix& matrix);
|
|
|
|
void handleLinkToNamedDest(SkData* nameData, const SkRect& r,
|
|
|
|
const SkMatrix& matrix);
|
|
|
|
void defineNamedDestination(SkData* nameData, const SkPoint& point,
|
|
|
|
const SkMatrix& matrix);
|
2012-07-13 20:06:02 +00:00
|
|
|
|
2013-08-29 11:54:56 +00:00
|
|
|
typedef SkBitmapDevice INHERITED;
|
2013-10-14 13:42:12 +00:00
|
|
|
|
|
|
|
// TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to create
|
|
|
|
// an SkPDFDevice
|
|
|
|
//friend class SkDocument_PDF;
|
|
|
|
//friend class SkPDFImageShader;
|
2010-10-20 22:23:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|