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

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

Issue 920513003: Make filters use SkImage instead of SkBitmap Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 months 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
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"
11 #include "SkBitmapDevice.h" 11 #include "SkBitmapDevice.h"
12 #include "SkClipStack.h"
12 #include "SkColor.h" 13 #include "SkColor.h"
13 #include "SkClipStack.h"
14 #include "SkData.h" 14 #include "SkData.h"
15 #include "SkDraw.h" 15 #include "SkDraw.h"
16 #include "SkGlyphCache.h" 16 #include "SkGlyphCache.h"
17 #include "SkPaint.h" 17 #include "SkImage_Base.h"
18 #include "SkPath.h"
19 #include "SkPathOps.h"
20 #include "SkPDFFont.h" 18 #include "SkPDFFont.h"
21 #include "SkPDFFormXObject.h" 19 #include "SkPDFFormXObject.h"
22 #include "SkPDFGraphicState.h" 20 #include "SkPDFGraphicState.h"
23 #include "SkPDFImage.h" 21 #include "SkPDFImage.h"
24 #include "SkPDFResourceDict.h" 22 #include "SkPDFResourceDict.h"
25 #include "SkPDFShader.h" 23 #include "SkPDFShader.h"
26 #include "SkPDFStream.h" 24 #include "SkPDFStream.h"
27 #include "SkPDFTypes.h" 25 #include "SkPDFTypes.h"
28 #include "SkPDFUtils.h" 26 #include "SkPDFUtils.h"
27 #include "SkPaint.h"
28 #include "SkPath.h"
29 #include "SkPathOps.h"
30 #include "SkRRect.h"
29 #include "SkRect.h" 31 #include "SkRect.h"
30 #include "SkRRect.h"
31 #include "SkString.h" 32 #include "SkString.h"
32 #include "SkSurface.h" 33 #include "SkSurface.h"
34 #include "SkTSet.h"
35 #include "SkTemplates.h"
33 #include "SkTextFormatParams.h" 36 #include "SkTextFormatParams.h"
34 #include "SkTemplates.h"
35 #include "SkTypefacePriv.h" 37 #include "SkTypefacePriv.h"
36 #include "SkTSet.h"
37 38
38 #define DPI_FOR_RASTER_SCALE_ONE 72 39 #define DPI_FOR_RASTER_SCALE_ONE 72
39 40
40 // Utility functions 41 // Utility functions
41 42
42 static void emit_pdf_color(SkColor color, SkWStream* result) { 43 static void emit_pdf_color(SkColor color, SkWStream* result) {
43 SkASSERT(SkColorGetA(color) == 0xFF); // We handle alpha elsewhere. 44 SkASSERT(SkColorGetA(color) == 0xFF); // We handle alpha elsewhere.
44 SkScalar colorMax = SkIntToScalar(0xFF); 45 SkScalar colorMax = SkIntToScalar(0xFF);
45 SkPDFScalar::Append( 46 SkPDFScalar::Append(
46 SkScalarDiv(SkIntToScalar(SkColorGetR(color)), colorMax), result); 47 SkScalarDiv(SkIntToScalar(SkColorGetR(color)), colorMax), result);
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 if (d.fClip->isEmpty()) { 1043 if (d.fClip->isEmpty()) {
1043 return; 1044 return;
1044 } 1045 }
1045 1046
1046 SkMatrix matrix; 1047 SkMatrix matrix;
1047 matrix.setTranslate(SkIntToScalar(x), SkIntToScalar(y)); 1048 matrix.setTranslate(SkIntToScalar(x), SkIntToScalar(y));
1048 this->internalDrawBitmap(matrix, d.fClipStack, *d.fClip, bitmap, NULL, 1049 this->internalDrawBitmap(matrix, d.fClipStack, *d.fClip, bitmap, NULL,
1049 paint); 1050 paint);
1050 } 1051 }
1051 1052
1053 void SkPDFDevice::drawSprite(const SkDraw& draw, const SkImage& image, int x, in t y,
1054 const SkPaint& paint) {
1055 SkBitmap bitmap;
1056 if (!as_IB(&image)->getROPixels(&bitmap)) {
1057 return;
1058 }
1059 this->drawSprite(draw, bitmap, x, y, paint);
1060 }
1061
1052 void SkPDFDevice::drawText(const SkDraw& d, const void* text, size_t len, 1062 void SkPDFDevice::drawText(const SkDraw& d, const void* text, size_t len,
1053 SkScalar x, SkScalar y, const SkPaint& paint) { 1063 SkScalar x, SkScalar y, const SkPaint& paint) {
1054 NOT_IMPLEMENTED(paint.getMaskFilter() != NULL, false); 1064 NOT_IMPLEMENTED(paint.getMaskFilter() != NULL, false);
1055 if (paint.getMaskFilter() != NULL) { 1065 if (paint.getMaskFilter() != NULL) {
1056 // Don't pretend we support drawing MaskFilters, it makes for artifacts 1066 // Don't pretend we support drawing MaskFilters, it makes for artifacts
1057 // making text unreadable (e.g. same text twice when using CSS shadows). 1067 // making text unreadable (e.g. same text twice when using CSS shadows).
1058 return; 1068 return;
1059 } 1069 }
1060 SkPaint textPaint = calculate_text_paint(paint); 1070 SkPaint textPaint = calculate_text_paint(paint);
1061 ScopedContentEntry content(this, d, textPaint, true); 1071 ScopedContentEntry content(this, d, textPaint, true);
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 2140
2131 SkAutoTUnref<SkPDFObject> image( 2141 SkAutoTUnref<SkPDFObject> image(
2132 SkPDFCreateImageObject(fCanon, *bitmap, subset)); 2142 SkPDFCreateImageObject(fCanon, *bitmap, subset));
2133 if (!image) { 2143 if (!image) {
2134 return; 2144 return;
2135 } 2145 }
2136 2146
2137 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), 2147 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()),
2138 &content.entry()->fContent); 2148 &content.entry()->fContent);
2139 } 2149 }
OLDNEW
« include/core/SkDevice.h ('K') | « src/pdf/SkPDFDevice.h ('k') | src/svg/SkSVGDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698