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

Issue 16660002: SkDocument base for pdf, xps, etc. (Closed)

Created:
7 years, 6 months ago by reed1
Modified:
7 years, 6 months ago
CC:
skia-review_googlegroups.com
Visibility:
Public.

Description

SkDocument base for pdf, xps, etc. R=scroggo@google.com Committed: https://code.google.com/p/skia/source/detail?r=9476

Patch Set 1 #

Total comments: 8

Patch Set 2 : #

Total comments: 2

Patch Set 3 : #

Patch Set 4 : update dox that we don't take ownership of the stream #

Total comments: 2

Patch Set 5 : add Done proc, so caller can delete the stream automatically when the doc is done with it #

Total comments: 5
Unified diffs Side-by-side diffs Delta from patch set Stats (+329 lines, -18 lines) Patch
M gyp/core.gypi View 1 chunk +2 lines, -0 lines 0 comments Download
M gyp/pdf.gyp View 1 chunk +2 lines, -0 lines 0 comments Download
M gyp/tools.gyp View 1 chunk +1 line, -0 lines 0 comments Download
A include/core/SkDocument.h View 1 2 3 4 1 chunk +92 lines, -0 lines 4 comments Download
A src/doc/SkDocument.cpp View 1 2 3 4 1 chunk +83 lines, -0 lines 1 comment Download
A src/doc/SkDocument_PDF.cpp View 1 2 3 4 1 chunk +92 lines, -0 lines 0 comments Download
M tools/skhello.cpp View 2 chunks +57 lines, -18 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
reed1
7 years, 6 months ago (2013-06-07 19:07:49 UTC) #1
scroggo
lgtm https://codereview.chromium.org/16660002/diff/1/src/doc/SkDocument_PDF.cpp File src/doc/SkDocument_PDF.cpp (right): https://codereview.chromium.org/16660002/diff/1/src/doc/SkDocument_PDF.cpp#newcode15 src/doc/SkDocument_PDF.cpp:15: fDoc = new SkPDFDocument; SkNEW https://codereview.chromium.org/16660002/diff/1/src/doc/SkDocument_PDF.cpp#newcode22 src/doc/SkDocument_PDF.cpp:22: delete ...
7 years, 6 months ago (2013-06-07 19:35:23 UTC) #2
epoger
https://codereview.chromium.org/16660002/diff/3001/include/core/SkDocument.h File include/core/SkDocument.h (right): https://codereview.chromium.org/16660002/diff/3001/include/core/SkDocument.h#newcode17 include/core/SkDocument.h:17: class SkDocument : public SkRefCnt { Since this is ...
7 years, 6 months ago (2013-06-07 19:39:04 UTC) #3
reed1
https://codereview.chromium.org/16660002/diff/1/src/doc/SkDocument_PDF.cpp File src/doc/SkDocument_PDF.cpp (right): https://codereview.chromium.org/16660002/diff/1/src/doc/SkDocument_PDF.cpp#newcode15 src/doc/SkDocument_PDF.cpp:15: fDoc = new SkPDFDocument; On 2013/06/07 19:35:23, scroggo wrote: ...
7 years, 6 months ago (2013-06-07 19:50:40 UTC) #4
reed1
updated dox, that we don't take ownership of the stream
7 years, 6 months ago (2013-06-07 20:09:01 UTC) #5
scroggo
https://codereview.chromium.org/16660002/diff/16001/include/core/SkDocument.h File include/core/SkDocument.h (right): https://codereview.chromium.org/16660002/diff/16001/include/core/SkDocument.h#newcode37 include/core/SkDocument.h:37: * there is an error trying to create the ...
7 years, 6 months ago (2013-06-07 20:12:32 UTC) #6
scroggo
lgtm
7 years, 6 months ago (2013-06-07 20:29:46 UTC) #7
reed1
Committed patchset #5 manually as r9476 (presubmit successful).
7 years, 6 months ago (2013-06-07 20:30:23 UTC) #8
wrong vandebo
7 years, 6 months ago (2013-06-10 16:41:11 UTC) #9
Message was sent while issue was closed.
https://codereview.chromium.org/16660002/diff/23001/include/core/SkDocument.h
File include/core/SkDocument.h (right):

https://codereview.chromium.org/16660002/diff/23001/include/core/SkDocument.h...
include/core/SkDocument.h:33: static SkDocument* CreatePDF(const char
filename[]);
Are these factory methods and you'll have additional methods for other
multi-page output formats, i.e. XPS, etc ?  It's a bit strange to how them on
the base class otherwise.

However, based on the signatures, it looks like you'd end up with two methods
per file format.  It seems that you could just make an enum with all the file
formats and make these methods generic.  i.e.

enum DocumentType {
 kPDF,
 kEMF,
 ...
}

CreateDocument(DocumentType type, const char filename[]);

https://codereview.chromium.org/16660002/diff/23001/include/core/SkDocument.h...
include/core/SkDocument.h:45: static SkDocument* CreatePDF(SkWStream*, void
(*Done)(SkWStream*) = NULL);
PDF has a couple of document options: disable compression, disable link
annotations.  I'm not sure if these are generic enough, but it seems like this
is the place to pipe them through.

https://codereview.chromium.org/16660002/diff/23001/include/core/SkDocument.h...
include/core/SkDocument.h:53: const SkRect* content = NULL);
I tried using only a rect to specify the content area at the device level but it
didn't work out.  I don't recall if there was a deeper issue or if was just that
the device layer needed a transform and using a rect at the canvas layer would
work fine. 

With both interfaces, you still need another mechanism to enable drawing in the
margin area.  In Chrome this is used to add headers and footers.

https://codereview.chromium.org/16660002/diff/23001/include/core/SkDocument.h...
include/core/SkDocument.h:68: void close();
A feature that the PDF code has that's not representable here is to emit
multiple documents with different sets of drawn pages.  In Chrome the print
preview flow uses this to decrease latency; while creating a single PDF with all
<n> pages, it also creates <n> single page PDFs.  The single page PDFs are
streamed to the print preview page as they are ready.  A on SkDocument to
combine multiple SkDocuments or a method to get an SkDocument for a subset of
pages would preserve that functionality.

https://codereview.chromium.org/16660002/diff/23001/src/doc/SkDocument.cpp
File src/doc/SkDocument.cpp (right):

https://codereview.chromium.org/16660002/diff/23001/src/doc/SkDocument.cpp#ne...
src/doc/SkDocument.cpp:54: void SkDocument::endPage() {
It seems like this method isn't strictly needed and the method could be
generated implicitly.  I don't object to the method, just noting that it doesn't
seem necessary.

Powered by Google App Engine
This is Rietveld 408576698