| 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 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2113 | 2113 |
| 2114 // TODO(edisonn): A better approach would be to use a bitmap shader | 2114 // TODO(edisonn): A better approach would be to use a bitmap shader |
| 2115 // (in clamp mode) and draw a rect over the entire bounding box. Then | 2115 // (in clamp mode) and draw a rect over the entire bounding box. Then |
| 2116 // intersect perspectiveOutline to the clip. That will avoid introducing | 2116 // intersect perspectiveOutline to the clip. That will avoid introducing |
| 2117 // alpha to the image while still giving good behavior at the edge of | 2117 // alpha to the image while still giving good behavior at the edge of |
| 2118 // the image. Avoiding alpha will reduce the pdf size and generation | 2118 // the image. Avoiding alpha will reduce the pdf size and generation |
| 2119 // CPU time some. | 2119 // CPU time some. |
| 2120 | 2120 |
| 2121 const int w = SkScalarCeilToInt(physicalPerspectiveOutline.getBounds().w
idth()); | 2121 const int w = SkScalarCeilToInt(physicalPerspectiveOutline.getBounds().w
idth()); |
| 2122 const int h = SkScalarCeilToInt(physicalPerspectiveOutline.getBounds().h
eight()); | 2122 const int h = SkScalarCeilToInt(physicalPerspectiveOutline.getBounds().h
eight()); |
| 2123 if (!perspectiveBitmap.allocPixels(SkImageInfo::MakeN32Premul(w, h))) { | 2123 if (!perspectiveBitmap.tryAllocN32Pixels(w, h)) { |
| 2124 return; | 2124 return; |
| 2125 } | 2125 } |
| 2126 perspectiveBitmap.eraseColor(SK_ColorTRANSPARENT); | 2126 perspectiveBitmap.eraseColor(SK_ColorTRANSPARENT); |
| 2127 | 2127 |
| 2128 SkCanvas canvas(perspectiveBitmap); | 2128 SkCanvas canvas(perspectiveBitmap); |
| 2129 | 2129 |
| 2130 SkScalar deltaX = bounds.left(); | 2130 SkScalar deltaX = bounds.left(); |
| 2131 SkScalar deltaY = bounds.top(); | 2131 SkScalar deltaY = bounds.top(); |
| 2132 | 2132 |
| 2133 SkMatrix offsetMatrix = origMatrix; | 2133 SkMatrix offsetMatrix = origMatrix; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2185 SkAutoTUnref<SkPDFObject> image( | 2185 SkAutoTUnref<SkPDFObject> image( |
| 2186 SkPDFCreateImageObject(*bitmap, subset, fEncoder)); | 2186 SkPDFCreateImageObject(*bitmap, subset, fEncoder)); |
| 2187 if (!image) { | 2187 if (!image) { |
| 2188 return; | 2188 return; |
| 2189 } | 2189 } |
| 2190 | 2190 |
| 2191 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), | 2191 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), |
| 2192 &content.entry()->fContent); | 2192 &content.entry()->fContent); |
| 2193 } | 2193 } |
| 2194 | 2194 |
| OLD | NEW |