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

Side by Side Diff: src/pdf/SkPDFDevice.cpp

Issue 24811002: Update the SkDocument interface to allow for 1) abort won't emit pdf, 2) close can report success/f… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkPDFDevice.h" 8 #include "SkPDFDevice.h"
9 9
10 #include "SkAnnotation.h" 10 #include "SkAnnotation.h"
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight)); 700 fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight));
701 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1); 701 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1);
702 fInitialTransform.preConcat(initialTransform); 702 fInitialTransform.preConcat(initialTransform);
703 703
704 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height()); 704 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height());
705 fExistingClipRegion.setRect(existingClip); 705 fExistingClipRegion.setRect(existingClip);
706 706
707 this->init(); 707 this->init();
708 } 708 }
709 709
710 SkISize SkSizeToISize(const SkSize& size) {
711 return SkISize::Make(SkScalarRoundToInt(size.width()), SkScalarRoundToInt(si ze.height()));
712 }
713
714 SkPDFDevice::SkPDFDevice(const SkSize& trimBox, const SkRect& content)
715 : SkBitmapDevice(makeContentBitmap(SkSizeToISize(SkSize::Make(content.width( ), content.height())),
716 NULL)),
717 fPageSize(SkSizeToISize(SkSize::Make(content.width(), content.height()))),
718 fContentSize(SkSizeToISize(trimBox)),
719 fLastContentEntry(NULL),
720 fLastMarginContentEntry(NULL),
721 fClipStack(NULL),
722 fEncoder(NULL) {
723 // Skia generally uses the top left as the origin but PDF natively has the
724 // origin at the bottom left. This matrix corrects for that. But that only
725 // needs to be done once, we don't do it when layering.
726 fInitialTransform.reset();
727 fInitialTransform.setTranslate(0, SkIntToScalar(fPageSize.fHeight));
728 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1);
729 fInitialTransform.preTranslate(-content.left(), -content.top());
730
731 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height());
732 fExistingClipRegion.setRect(existingClip);
733
734 this->init();
735 }
736
737
710 // TODO(vandebo) change layerSize to SkSize. 738 // TODO(vandebo) change layerSize to SkSize.
711 SkPDFDevice::SkPDFDevice(const SkISize& layerSize, 739 SkPDFDevice::SkPDFDevice(const SkISize& layerSize,
712 const SkClipStack& existingClipStack, 740 const SkClipStack& existingClipStack,
713 const SkRegion& existingClipRegion) 741 const SkRegion& existingClipRegion)
714 : SkBitmapDevice(makeContentBitmap(layerSize, NULL)), 742 : SkBitmapDevice(makeContentBitmap(layerSize, NULL)),
715 fPageSize(layerSize), 743 fPageSize(layerSize),
716 fContentSize(layerSize), 744 fContentSize(layerSize),
717 fExistingClipStack(existingClipStack), 745 fExistingClipStack(existingClipStack),
718 fExistingClipRegion(existingClipRegion), 746 fExistingClipRegion(existingClipRegion),
719 fLastContentEntry(NULL), 747 fLastContentEntry(NULL),
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 } 1964 }
1937 1965
1938 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, 1966 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y,
1939 SkCanvas::Config8888) { 1967 SkCanvas::Config8888) {
1940 return false; 1968 return false;
1941 } 1969 }
1942 1970
1943 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { 1971 bool SkPDFDevice::allowImageFilter(SkImageFilter*) {
1944 return false; 1972 return false;
1945 } 1973 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698