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

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

Issue 26389006: PDF: support perspective in simple shaders. (this version does not work well with tilling) (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: code review updates + return from ContentEntry if perspective is used in matrix, in adittion to rep… Created 7 years, 1 month 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
« no previous file with comments | « no previous file | src/pdf/SkPDFShader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 ContentEntry* entry() { return fContentEntry; } 641 ContentEntry* entry() { return fContentEntry; }
642 private: 642 private:
643 SkPDFDevice* fDevice; 643 SkPDFDevice* fDevice;
644 ContentEntry* fContentEntry; 644 ContentEntry* fContentEntry;
645 SkXfermode::Mode fXfermode; 645 SkXfermode::Mode fXfermode;
646 SkPDFFormXObject* fDstFormXObject; 646 SkPDFFormXObject* fDstFormXObject;
647 647
648 void init(const SkClipStack* clipStack, const SkRegion& clipRegion, 648 void init(const SkClipStack* clipStack, const SkRegion& clipRegion,
649 const SkMatrix& matrix, const SkPaint& paint, bool hasText) { 649 const SkMatrix& matrix, const SkPaint& paint, bool hasText) {
650 fDstFormXObject = NULL; 650 fDstFormXObject = NULL;
651 if (matrix.hasPerspective() || 651 // Shape has to be flatten before we get here.
652 (paint.getShader() && 652 if (matrix.hasPerspective()) {
653 paint.getShader()->getLocalMatrix().hasPerspective())) { 653 NOT_IMPLEMENTED(!matrix.hasPerspective(), false);
654 // Just report that PDF does not supports perspective
655 // TODO(edisonn): update the shape when possible
656 // or dump in an image otherwise
657 NOT_IMPLEMENTED(true, false);
658 return; 654 return;
659 } 655 }
660
661 if (paint.getXfermode()) { 656 if (paint.getXfermode()) {
662 paint.getXfermode()->asMode(&fXfermode); 657 paint.getXfermode()->asMode(&fXfermode);
663 } 658 }
664 fContentEntry = fDevice->setUpContentEntry(clipStack, clipRegion, 659 fContentEntry = fDevice->setUpContentEntry(clipStack, clipRegion,
665 matrix, paint, hasText, 660 matrix, paint, hasText,
666 &fDstFormXObject); 661 &fDstFormXObject);
667 } 662 }
668 }; 663 };
669 664
670 //////////////////////////////////////////////////////////////////////////////// 665 ////////////////////////////////////////////////////////////////////////////////
(...skipping 28 matching lines...) Expand all
699 SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, 694 SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize,
700 const SkMatrix& initialTransform) 695 const SkMatrix& initialTransform)
701 : SkBitmapDevice(makeContentBitmap(contentSize, &initialTransform)), 696 : SkBitmapDevice(makeContentBitmap(contentSize, &initialTransform)),
702 fPageSize(pageSize), 697 fPageSize(pageSize),
703 fContentSize(contentSize), 698 fContentSize(contentSize),
704 fLastContentEntry(NULL), 699 fLastContentEntry(NULL),
705 fLastMarginContentEntry(NULL), 700 fLastMarginContentEntry(NULL),
706 fClipStack(NULL), 701 fClipStack(NULL),
707 fEncoder(NULL), 702 fEncoder(NULL),
708 fRasterDpi(SkFloatToScalar(72.0f)) { 703 fRasterDpi(SkFloatToScalar(72.0f)) {
709 // just report that PDF does not supports perspective 704 // Just report that PDF does not supports perspective in the
710 // TODO(edisonn): update the shape when possible 705 // initial transform.
711 // or dump in an image otherwise
712 NOT_IMPLEMENTED(initialTransform.hasPerspective(), true); 706 NOT_IMPLEMENTED(initialTransform.hasPerspective(), true);
713 707
714 // Skia generally uses the top left as the origin but PDF natively has the 708 // Skia generally uses the top left as the origin but PDF natively has the
715 // origin at the bottom left. This matrix corrects for that. But that only 709 // origin at the bottom left. This matrix corrects for that. But that only
716 // needs to be done once, we don't do it when layering. 710 // needs to be done once, we don't do it when layering.
717 fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight)); 711 fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight));
718 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1); 712 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1);
719 fInitialTransform.preConcat(initialTransform); 713 fInitialTransform.preConcat(initialTransform);
720 714
721 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height()); 715 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height());
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 } 2138 }
2145 2139
2146 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, 2140 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y,
2147 SkCanvas::Config8888) { 2141 SkCanvas::Config8888) {
2148 return false; 2142 return false;
2149 } 2143 }
2150 2144
2151 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { 2145 bool SkPDFDevice::allowImageFilter(SkImageFilter*) {
2152 return false; 2146 return false;
2153 } 2147 }
OLDNEW
« no previous file with comments | « no previous file | src/pdf/SkPDFShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698