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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/colorfilterimagefilter.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFDevice.cpp
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 52c4c655cd9c38d6b1cd58c4cb0b217f54321c8a..461ae7f9e274fb41c2f91ce4f2d4d9543c042125 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -9,6 +9,7 @@
#include "SkAnnotation.h"
#include "SkColor.h"
+#include "SkColorFilter.h"
#include "SkClipStack.h"
#include "SkData.h"
#include "SkDraw.h"
@@ -2202,10 +2203,26 @@ void SkPDFDevice::internalDrawBitmap(const SkMatrix& origMatrix,
}
SkBitmap subsetBitmap;
- // Should extractSubset be done by the SkPDFDevice?
if (!bitmap->extractSubset(&subsetBitmap, subset)) {
return;
}
+ if (SkColorFilter* colorFilter = paint.getColorFilter()) {
+ // TODO(http://skbug.com/4378): implement colorfilter on other
+ // draw calls. This code here works for all drawBitmap*()
+ // calls amd ImageFilters (which rasterize a layer on this
+ // backend). Fortuanely, this seems to be how Chromium
scroggo 2015/09/24 17:20:26 nit: Fortunately*
+ // impements most color-filters.
+ SkBitmap tmp;
+ if (subsetBitmap.copyTo(&tmp, kN32_SkColorType)) {
+ SkAutoLockPixels autoLockPixelsTmp(tmp);
+ for (int y = 0; y < tmp.height(); ++y) {
+ SkPMColor* pixels = tmp.getAddr32(0, y);
+ colorFilter->filterSpan(pixels, tmp.width(), pixels);
+ }
+ tmp.setImmutable();
+ subsetBitmap = tmp;
+ }
+ }
SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap));
if (!image) {
return;
« 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