| 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 "SkAnnotationKeys.h" | 10 #include "SkAnnotationKeys.h" |
| (...skipping 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 } | 1981 } |
| 1982 return resourceIndex; | 1982 return resourceIndex; |
| 1983 } | 1983 } |
| 1984 | 1984 |
| 1985 static SkSize rect_to_size(const SkRect& r) { | 1985 static SkSize rect_to_size(const SkRect& r) { |
| 1986 return SkSize::Make(r.width(), r.height()); | 1986 return SkSize::Make(r.width(), r.height()); |
| 1987 } | 1987 } |
| 1988 | 1988 |
| 1989 static sk_sp<SkImage> color_filter(const SkImageBitmap& imageBitmap, | 1989 static sk_sp<SkImage> color_filter(const SkImageBitmap& imageBitmap, |
| 1990 SkColorFilter* colorFilter) { | 1990 SkColorFilter* colorFilter) { |
| 1991 auto surface = | 1991 auto surface = |
| 1992 SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(imageBitmap.dimensions(
))); | 1992 SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(imageBitmap.dimensions(
))); |
| 1993 SkASSERT(surface); | 1993 SkASSERT(surface); |
| 1994 SkCanvas* canvas = surface->getCanvas(); | 1994 SkCanvas* canvas = surface->getCanvas(); |
| 1995 canvas->clear(SK_ColorTRANSPARENT); | 1995 canvas->clear(SK_ColorTRANSPARENT); |
| 1996 SkPaint paint; | 1996 SkPaint paint; |
| 1997 paint.setColorFilter(sk_ref_sp(colorFilter)); | 1997 paint.setColorFilter(sk_ref_sp(colorFilter)); |
| 1998 imageBitmap.draw(canvas, &paint); | 1998 imageBitmap.draw(canvas, &paint); |
| 1999 canvas->flush(); | 1999 canvas->flush(); |
| 2000 return surface->makeImageSnapshot(); | 2000 return surface->makeImageSnapshot(); |
| 2001 } | 2001 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2139 if (!pdfimage) { | 2139 if (!pdfimage) { |
| 2140 return; | 2140 return; |
| 2141 } | 2141 } |
| 2142 fDocument->serialize(pdfimage); // serialize images early. | 2142 fDocument->serialize(pdfimage); // serialize images early. |
| 2143 fDocument->canon()->addPDFBitmap(key, pdfimage); | 2143 fDocument->canon()->addPDFBitmap(key, pdfimage); |
| 2144 } | 2144 } |
| 2145 // TODO(halcanary): addXObjectResource() should take a sk_sp<SkPDFObject> | 2145 // TODO(halcanary): addXObjectResource() should take a sk_sp<SkPDFObject> |
| 2146 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), | 2146 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), |
| 2147 &content.entry()->fContent); | 2147 &content.entry()->fContent); |
| 2148 } | 2148 } |
| OLD | NEW |