| 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 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1976 NOT_IMPLEMENTED(paint.getColorFilter() != nullptr, false); | 1976 NOT_IMPLEMENTED(paint.getColorFilter() != nullptr, false); |
| 1977 | 1977 |
| 1978 entry->fMatrix = matrix; | 1978 entry->fMatrix = matrix; |
| 1979 entry->fClipStack = clipStack; | 1979 entry->fClipStack = clipStack; |
| 1980 entry->fClipRegion = clipRegion; | 1980 entry->fClipRegion = clipRegion; |
| 1981 entry->fColor = SkColorSetA(paint.getColor(), 0xFF); | 1981 entry->fColor = SkColorSetA(paint.getColor(), 0xFF); |
| 1982 entry->fShaderIndex = -1; | 1982 entry->fShaderIndex = -1; |
| 1983 | 1983 |
| 1984 // PDF treats a shader as a color, so we only set one or the other. | 1984 // PDF treats a shader as a color, so we only set one or the other. |
| 1985 sk_sp<SkPDFObject> pdfShader; | 1985 sk_sp<SkPDFObject> pdfShader; |
| 1986 const SkShader* shader = paint.getShader(); | 1986 SkShader* shader = paint.getShader(); |
| 1987 SkColor color = paint.getColor(); | 1987 SkColor color = paint.getColor(); |
| 1988 if (shader) { | 1988 if (shader) { |
| 1989 // PDF positions patterns relative to the initial transform, so | 1989 // PDF positions patterns relative to the initial transform, so |
| 1990 // we need to apply the current transform to the shader parameters. | 1990 // we need to apply the current transform to the shader parameters. |
| 1991 SkMatrix transform = matrix; | 1991 SkMatrix transform = matrix; |
| 1992 transform.postConcat(fInitialTransform); | 1992 transform.postConcat(fInitialTransform); |
| 1993 | 1993 |
| 1994 // PDF doesn't support kClamp_TileMode, so we simulate it by making | 1994 // PDF doesn't support kClamp_TileMode, so we simulate it by making |
| 1995 // a pattern the size of the current clip. | 1995 // a pattern the size of the current clip. |
| 1996 SkIRect bounds = clipRegion.getBounds(); | 1996 SkIRect bounds = clipRegion.getBounds(); |
| 1997 | 1997 |
| 1998 // We need to apply the initial transform to bounds in order to get | 1998 // We need to apply the initial transform to bounds in order to get |
| 1999 // bounds in a consistent coordinate system. | 1999 // bounds in a consistent coordinate system. |
| 2000 SkRect boundsTemp; | 2000 SkRect boundsTemp; |
| 2001 boundsTemp.set(bounds); | 2001 boundsTemp.set(bounds); |
| 2002 fInitialTransform.mapRect(&boundsTemp); | 2002 fInitialTransform.mapRect(&boundsTemp); |
| 2003 boundsTemp.roundOut(&bounds); | 2003 boundsTemp.roundOut(&bounds); |
| 2004 | 2004 |
| 2005 SkScalar rasterScale = | 2005 SkScalar rasterScale = |
| 2006 SkIntToScalar(fRasterDpi) / DPI_FOR_RASTER_SCALE_ONE; | 2006 SkIntToScalar(fRasterDpi) / DPI_FOR_RASTER_SCALE_ONE; |
| 2007 pdfShader.reset(SkPDFShader::GetPDFShader( | 2007 pdfShader.reset(SkPDFShader::GetPDFShader( |
| 2008 fDocument, fRasterDpi, *shader, transform, bounds, rasterScale))
; | 2008 fDocument, fRasterDpi, shader, transform, bounds, rasterScale)); |
| 2009 | 2009 |
| 2010 if (pdfShader.get()) { | 2010 if (pdfShader.get()) { |
| 2011 // pdfShader has been canonicalized so we can directly compare | 2011 // pdfShader has been canonicalized so we can directly compare |
| 2012 // pointers. | 2012 // pointers. |
| 2013 int resourceIndex = fShaderResources.find(pdfShader.get()); | 2013 int resourceIndex = fShaderResources.find(pdfShader.get()); |
| 2014 if (resourceIndex < 0) { | 2014 if (resourceIndex < 0) { |
| 2015 resourceIndex = fShaderResources.count(); | 2015 resourceIndex = fShaderResources.count(); |
| 2016 fShaderResources.push(pdfShader.get()); | 2016 fShaderResources.push(pdfShader.get()); |
| 2017 pdfShader.get()->ref(); | 2017 pdfShader.get()->ref(); |
| 2018 } | 2018 } |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2270 sk_sp<SkData> encodedImage(image->refEncodedData()); | 2270 sk_sp<SkData> encodedImage(image->refEncodedData()); |
| 2271 if (!encodedImage) { | 2271 if (!encodedImage) { |
| 2272 fDocument->serialize(pdfimage); | 2272 fDocument->serialize(pdfimage); |
| 2273 } | 2273 } |
| 2274 #endif | 2274 #endif |
| 2275 fDocument->canon()->addPDFBitmap(image->uniqueID(), pdfimage.get()); | 2275 fDocument->canon()->addPDFBitmap(image->uniqueID(), pdfimage.get()); |
| 2276 } | 2276 } |
| 2277 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), | 2277 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), |
| 2278 &content.entry()->fContent); | 2278 &content.entry()->fContent); |
| 2279 } | 2279 } |
| OLD | NEW |