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

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

Issue 1367993002: SkPDF Implement colorfilters on bitmaps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-09-24 (Thursday) 13:13:56 EDT Created 5 years, 2 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
« no previous file with comments | « gm/colorfilterimagefilter.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "SkColor.h" 11 #include "SkColor.h"
12 #include "SkColorFilter.h"
12 #include "SkClipStack.h" 13 #include "SkClipStack.h"
13 #include "SkData.h" 14 #include "SkData.h"
14 #include "SkDraw.h" 15 #include "SkDraw.h"
15 #include "SkGlyphCache.h" 16 #include "SkGlyphCache.h"
16 #include "SkPaint.h" 17 #include "SkPaint.h"
17 #include "SkPath.h" 18 #include "SkPath.h"
18 #include "SkPathOps.h" 19 #include "SkPathOps.h"
19 #include "SkPDFBitmap.h" 20 #include "SkPDFBitmap.h"
20 #include "SkPDFFont.h" 21 #include "SkPDFFont.h"
21 #include "SkPDFFormXObject.h" 22 #include "SkPDFFormXObject.h"
(...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 shape.addRect(SkRect::MakeWH(SkIntToScalar(subset.width()), 2196 shape.addRect(SkRect::MakeWH(SkIntToScalar(subset.width()),
2196 SkIntToScalar(subset.height()))); 2197 SkIntToScalar(subset.height())));
2197 shape.transform(matrix); 2198 shape.transform(matrix);
2198 content.setShape(shape); 2199 content.setShape(shape);
2199 } 2200 }
2200 if (!content.needSource()) { 2201 if (!content.needSource()) {
2201 return; 2202 return;
2202 } 2203 }
2203 2204
2204 SkBitmap subsetBitmap; 2205 SkBitmap subsetBitmap;
2205 // Should extractSubset be done by the SkPDFDevice?
2206 if (!bitmap->extractSubset(&subsetBitmap, subset)) { 2206 if (!bitmap->extractSubset(&subsetBitmap, subset)) {
2207 return; 2207 return;
2208 } 2208 }
2209 if (SkColorFilter* colorFilter = paint.getColorFilter()) {
2210 // TODO(http://skbug.com/4378): implement colorfilter on other
2211 // draw calls. This code here works for all drawBitmap*()
2212 // calls amd ImageFilters (which rasterize a layer on this
2213 // backend). Fortuanely, this seems to be how Chromium
scroggo 2015/09/24 17:20:26 nit: Fortunately*
2214 // impements most color-filters.
2215 SkBitmap tmp;
2216 if (subsetBitmap.copyTo(&tmp, kN32_SkColorType)) {
2217 SkAutoLockPixels autoLockPixelsTmp(tmp);
2218 for (int y = 0; y < tmp.height(); ++y) {
2219 SkPMColor* pixels = tmp.getAddr32(0, y);
2220 colorFilter->filterSpan(pixels, tmp.width(), pixels);
2221 }
2222 tmp.setImmutable();
2223 subsetBitmap = tmp;
2224 }
2225 }
2209 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap)); 2226 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap));
2210 if (!image) { 2227 if (!image) {
2211 return; 2228 return;
2212 } 2229 }
2213 2230
2214 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), 2231 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()),
2215 &content.entry()->fContent); 2232 &content.entry()->fContent);
2216 } 2233 }
OLDNEW
« no previous file with comments | « gm/colorfilterimagefilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698