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

Unified Diff: src/core/SkDevice.cpp

Issue 973973003: Text blob run paints should be filtered. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: fix iterator filter skipping Created 5 years, 10 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 | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDevice.cpp
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index 2f510700753d1c51d41e92ae83fbb204f61aa344..a77e54c2ffd39f6755e40502f542bcb744add1a1 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -8,6 +8,7 @@
#include "SkDevice.h"
#include "SkDeviceProperties.h"
#include "SkDraw.h"
+#include "SkDrawFilter.h"
#include "SkMetaData.h"
#include "SkPatchUtils.h"
#include "SkPathMeasure.h"
@@ -121,17 +122,24 @@ void SkBaseDevice::drawPatch(const SkDraw& draw, const SkPoint cubics[12], const
}
void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkScalar x, SkScalar y,
- const SkPaint &paint) {
+ const SkPaint &paint, SkDrawFilter* drawFilter) {
SkPaint runPaint = paint;
SkTextBlob::RunIterator it(blob);
- while (!it.done()) {
+ for (;!it.done(); it.next()) {
size_t textLen = it.glyphCount() * sizeof(uint16_t);
const SkPoint& offset = it.offset();
// applyFontToPaint() always overwrites the exact same attributes,
- // so it is safe to not re-seed the paint.
+ // so it is safe to not re-seed the paint for this reason.
it.applyFontToPaint(&runPaint);
+
+ if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Type)) {
+ // A false return from filter() means we should abort the current draw.
+ runPaint = paint;
+ continue;
+ }
+
runPaint.setFlags(this->filterTextFlags(runPaint));
switch (it.positioning()) {
@@ -150,7 +158,10 @@ void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSc
SkFAIL("unhandled positioning mode");
}
- it.next();
+ if (drawFilter) {
+ // A draw filter may change the paint arbitrarily, so we must re-seed in this case.
+ runPaint = paint;
+ }
}
}
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698