aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2015-09-24 10:20:05 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-24 10:20:06 -0700
commit287d22d9999f340d485e1db4dd19930f76f40230 (patch)
tree67c9815247e2f775117de58690ea3172e138db90 /src
parent24eb7a8ed04db40cec68d215f5b2c646777f254c (diff)
SkPDF Implement colorfilters on bitmaps
Diffstat (limited to 'src')
-rw-r--r--src/pdf/SkPDFDevice.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 52c4c655cd..461ae7f9e2 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
+ // 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;