aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/pdf
diff options
context:
space:
mode:
authorGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-24 17:19:38 +0000
committerGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-24 17:19:38 +0000
commitb069c8cfcd5df285193eb334b3bc33438782e8da (patch)
tree2990dae2945b568582b455ff21a747f36491c842 /include/pdf
parent8f096724a2fa6c6210a354015e598a37cdf222f0 (diff)
[PDF] Add helper class to manage ContentEntry set up and completion.
This stack object helper class calls finishContentEntry when it goes out of scope, maintains the current content entry, and manages the dst form xobject when it is needed. This can be made cleaner by moving the guts of SkPDFDevice into a core object, which can expose setUp/finishContentEntry as public, but that is left as a todo. Review URL: http://codereview.appspot.com/4515126 git-svn-id: http://skia.googlecode.com/svn/trunk@1409 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/pdf')
-rw-r--r--include/pdf/SkPDFDevice.h38
1 files changed, 21 insertions, 17 deletions
diff --git a/include/pdf/SkPDFDevice.h b/include/pdf/SkPDFDevice.h
index b6c1389100..7d093dc5d9 100644
--- a/include/pdf/SkPDFDevice.h
+++ b/include/pdf/SkPDFDevice.h
@@ -17,6 +17,7 @@
#ifndef SkPDFDevice_DEFINED
#define SkPDFDevice_DEFINED
+#include "SkCanvas.h"
#include "SkDevice.h"
#include "SkPaint.h"
#include "SkPath.h"
@@ -35,6 +36,7 @@ class SkPDFShader;
class SkPDFStream;
// Private classes.
+class ContentEntryAccessor;
struct ContentEntry;
struct GraphicStateEntry;
@@ -141,6 +143,9 @@ protected:
private:
friend class SkPDFDeviceFactory;
+ // TODO(vandebo) push most of SkPDFDevice's state into a core object in
+ // order to get the right access levels without using friend.
+ friend class ContentEntryAccessor;
SkISize fPageSize;
SkISize fContentSize;
@@ -155,8 +160,7 @@ private:
SkTDArray<SkPDFShader*> fShaderResources;
SkTScopedPtr<ContentEntry> fContentEntries;
- ContentEntry* fCurrentContentEntry;
- SkRefPtr<SkPDFFormXObject> fDstFormXObject;
+ ContentEntry* fLastContentEntry;
// For use by the DeviceFactory.
SkPDFDevice(const SkISize& layerSize, const SkClipStack& existingClipStack,
@@ -174,18 +178,18 @@ private:
const SkRegion& clipRegion,
bool invertClip);
- // If the paint or clip is such that we shouldn't draw anything, these
- // return false and do not create a content entry.
- bool setUpContentEntry(const SkClipStack* clipStack,
- const SkRegion& clipRegion,
- const SkMatrix& matrix,
- const SkPaint& paint,
- bool hasText = false);
- bool setUpContentEntryForText(const SkClipStack* clipStack,
- const SkRegion& clipRegion,
- const SkMatrix& matrix,
- const SkPaint& paint);
- void finishContentEntry(const SkPaint& paint);
+ // 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
+ // the preferred method is to use the ContentEntryAccessor helper class.
+ ContentEntry* setUpContentEntry(const SkClipStack* clipStack,
+ const SkRegion& clipRegion,
+ const SkMatrix& matrix,
+ const SkPaint& paint,
+ bool hasText,
+ SkRefPtr<SkPDFFormXObject>* dst);
+ void finishContentEntry(SkXfermode::Mode xfermode,
+ SkPDFFormXObject* dst);
bool isContentEmpty();
void populateGraphicStateEntryFromPaint(const SkMatrix& matrix,
@@ -196,11 +200,11 @@ private:
GraphicStateEntry* entry);
int addGraphicStateResource(SkPDFGraphicState* gs);
- void updateFont(const SkPaint& paint, uint16_t glyphID);
+ void updateFont(const SkPaint& paint, uint16_t glyphID,
+ ContentEntry* contentEntry);
int getFontResourceIndex(SkTypeface* typeface, uint16_t glyphID);
- void setTextTransform(SkScalar x, SkScalar y, SkScalar textSkewX);
- void internalDrawPaint(const SkPaint& paint);
+ void internalDrawPaint(const SkPaint& paint, ContentEntry* contentEntry);
void internalDrawBitmap(const SkMatrix& matrix,
const SkClipStack* clipStack,
const SkRegion& clipRegion,