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

Unified Diff: src/pdf/SkPDFDevice.cpp

Issue 941023005: PDF : New factory function for SkPDFDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase on 07d5947 Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFDevice.h ('k') | src/pdf/SkPDFShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFDevice.cpp
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 329d0971dd0878af13b8dac960b06c084e8394bf..7c0aaa280e75b6eade1e3cecf6a332ac12fd36db 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -575,11 +575,8 @@ SkBaseDevice* SkPDFDevice::onCreateCompatibleDevice(const CreateInfo& cinfo) {
if (kImageFilter_Usage == cinfo.fUsage) {
return SkBitmapDevice::Create(cinfo.fInfo);
}
-
- SkMatrix initialTransform;
- initialTransform.reset();
SkISize size = SkISize::Make(cinfo.fInfo.width(), cinfo.fInfo.height());
- return SkNEW_ARGS(SkPDFDevice, (size, size, initialTransform));
+ return SkPDFDevice::Create(size, fRasterDpi, fCanon);
}
@@ -695,76 +692,36 @@ private:
////////////////////////////////////////////////////////////////////////////////
-static inline SkImageInfo make_content_info(const SkISize& contentSize,
- const SkMatrix* initialTransform) {
- SkImageInfo info;
- if (initialTransform) {
- // Compute the size of the drawing area.
- SkVector drawingSize;
- SkMatrix inverse;
- drawingSize.set(SkIntToScalar(contentSize.fWidth),
- SkIntToScalar(contentSize.fHeight));
- if (!initialTransform->invert(&inverse)) {
- // This shouldn't happen, initial transform should be invertible.
- SkASSERT(false);
- inverse.reset();
- }
- inverse.mapVectors(&drawingSize, 1);
- SkISize size = SkSize::Make(drawingSize.fX, drawingSize.fY).toRound();
- info = SkImageInfo::MakeUnknown(abs(size.fWidth), abs(size.fHeight));
- } else {
- info = SkImageInfo::MakeUnknown(abs(contentSize.fWidth),
- abs(contentSize.fHeight));
- }
- return info;
-}
-
-// TODO(vandebo) change pageSize to SkSize.
-SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize,
- const SkMatrix& initialTransform)
+SkPDFDevice::SkPDFDevice(SkISize pageSize,
+ SkScalar rasterDpi,
+ SkPDFCanon* canon,
+ bool flip)
: fPageSize(pageSize)
- , fContentSize(contentSize)
+ , fContentSize(pageSize)
+ , fExistingClipRegion(SkIRect::MakeSize(pageSize))
+ , fAnnotations(NULL)
+ , fResourceDict(NULL)
, fLastContentEntry(NULL)
, fLastMarginContentEntry(NULL)
+ , fDrawingArea(kContent_DrawingArea)
, fClipStack(NULL)
- , fRasterDpi(72.0f)
-{
- const SkImageInfo info = make_content_info(contentSize, &initialTransform);
-
- // Just report that PDF does not supports perspective in the
- // initial transform.
- NOT_IMPLEMENTED(initialTransform.hasPerspective(), true);
-
- // Skia generally uses the top left as the origin but PDF natively has the
- // origin at the bottom left. This matrix corrects for that. But that only
- // needs to be done once, we don't do it when layering.
- fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight));
- fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1);
- fInitialTransform.preConcat(initialTransform);
- fLegacyBitmap.setInfo(info);
-
- SkIRect existingClip = info.bounds();
- fExistingClipRegion.setRect(existingClip);
- this->init();
-}
-
-// TODO(vandebo) change layerSize to SkSize.
-SkPDFDevice::SkPDFDevice(const SkISize& layerSize,
- const SkClipStack& existingClipStack,
- const SkRegion& existingClipRegion)
- : fPageSize(layerSize)
- , fContentSize(layerSize)
- , fExistingClipStack(existingClipStack)
- , fExistingClipRegion(existingClipRegion)
- , fLastContentEntry(NULL)
- , fLastMarginContentEntry(NULL)
- , fClipStack(NULL)
- , fRasterDpi(72.0f)
-{
- fInitialTransform.reset();
- fLegacyBitmap.setInfo(make_content_info(layerSize, NULL));
-
- this->init();
+ , fFontGlyphUsage(SkNEW(SkPDFGlyphSetMap))
+ , fRasterDpi(rasterDpi)
+ , fCanon(canon) {
+ SkASSERT(pageSize.width() > 0);
+ SkASSERT(pageSize.height() > 0);
+ fLegacyBitmap.setInfo(
+ SkImageInfo::MakeUnknown(pageSize.width(), pageSize.height()));
+ if (flip) {
+ // Skia generally uses the top left as the origin but PDF
+ // natively has the origin at the bottom left. This matrix
+ // corrects for that. But that only needs to be done once, we
+ // don't do it when layering.
+ fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight));
+ fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1);
+ } else {
+ fInitialTransform.setIdentity();
+ }
}
SkPDFDevice::~SkPDFDevice() {
« no previous file with comments | « src/pdf/SkPDFDevice.h ('k') | src/pdf/SkPDFShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698