OLD | NEW |
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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 fContentEntry = fDevice->setUpContentEntry(clipStack, clipRegion, | 697 fContentEntry = fDevice->setUpContentEntry(clipStack, clipRegion, |
698 matrix, paint, hasText, | 698 matrix, paint, hasText, |
699 &fDstFormXObject); | 699 &fDstFormXObject); |
700 } | 700 } |
701 }; | 701 }; |
702 | 702 |
703 //////////////////////////////////////////////////////////////////////////////// | 703 //////////////////////////////////////////////////////////////////////////////// |
704 | 704 |
705 static inline SkBitmap makeContentBitmap(const SkISize& contentSize, | 705 static inline SkBitmap makeContentBitmap(const SkISize& contentSize, |
706 const SkMatrix* initialTransform) { | 706 const SkMatrix* initialTransform) { |
707 SkBitmap bitmap; | 707 SkImageInfo info; |
708 if (initialTransform) { | 708 if (initialTransform) { |
709 // Compute the size of the drawing area. | 709 // Compute the size of the drawing area. |
710 SkVector drawingSize; | 710 SkVector drawingSize; |
711 SkMatrix inverse; | 711 SkMatrix inverse; |
712 drawingSize.set(SkIntToScalar(contentSize.fWidth), | 712 drawingSize.set(SkIntToScalar(contentSize.fWidth), |
713 SkIntToScalar(contentSize.fHeight)); | 713 SkIntToScalar(contentSize.fHeight)); |
714 if (!initialTransform->invert(&inverse)) { | 714 if (!initialTransform->invert(&inverse)) { |
715 // This shouldn't happen, initial transform should be invertible. | 715 // This shouldn't happen, initial transform should be invertible. |
716 SkASSERT(false); | 716 SkASSERT(false); |
717 inverse.reset(); | 717 inverse.reset(); |
718 } | 718 } |
719 inverse.mapVectors(&drawingSize, 1); | 719 inverse.mapVectors(&drawingSize, 1); |
720 SkISize size = SkSize::Make(drawingSize.fX, drawingSize.fY).toRound(); | 720 SkISize size = SkSize::Make(drawingSize.fX, drawingSize.fY).toRound(); |
721 bitmap.setConfig(SkBitmap::kNo_Config, abs(size.fWidth), | 721 info = SkImageInfo::MakeUnknown(abs(size.fWidth), abs(size.fHeight)); |
722 abs(size.fHeight)); | |
723 } else { | 722 } else { |
724 bitmap.setConfig(SkBitmap::kNo_Config, abs(contentSize.fWidth), | 723 info = SkImageInfo::MakeUnknown(abs(contentSize.fWidth), |
725 abs(contentSize.fHeight)); | 724 abs(contentSize.fHeight)); |
726 } | 725 } |
727 | 726 |
| 727 SkBitmap bitmap; |
| 728 bitmap.setConfig(info); |
728 return bitmap; | 729 return bitmap; |
729 } | 730 } |
730 | 731 |
731 // TODO(vandebo) change pageSize to SkSize. | 732 // TODO(vandebo) change pageSize to SkSize. |
| 733 // TODO: inherit from SkBaseDevice instead of SkBitmapDevice |
732 SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, | 734 SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, |
733 const SkMatrix& initialTransform) | 735 const SkMatrix& initialTransform) |
734 : SkBitmapDevice(makeContentBitmap(contentSize, &initialTransform)), | 736 : SkBitmapDevice(makeContentBitmap(contentSize, &initialTransform)), |
735 fPageSize(pageSize), | 737 fPageSize(pageSize), |
736 fContentSize(contentSize), | 738 fContentSize(contentSize), |
737 fLastContentEntry(NULL), | 739 fLastContentEntry(NULL), |
738 fLastMarginContentEntry(NULL), | 740 fLastMarginContentEntry(NULL), |
739 fClipStack(NULL), | 741 fClipStack(NULL), |
740 fEncoder(NULL), | 742 fEncoder(NULL), |
741 fRasterDpi(72.0f) { | 743 fRasterDpi(72.0f) { |
(...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2319 } | 2321 } |
2320 | 2322 |
2321 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, | 2323 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, |
2322 SkCanvas::Config8888) { | 2324 SkCanvas::Config8888) { |
2323 return false; | 2325 return false; |
2324 } | 2326 } |
2325 | 2327 |
2326 bool SkPDFDevice::allowImageFilter(const SkImageFilter*) { | 2328 bool SkPDFDevice::allowImageFilter(const SkImageFilter*) { |
2327 return false; | 2329 return false; |
2328 } | 2330 } |
OLD | NEW |