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

Unified Diff: src/core/SkDevice.cpp

Issue 586743002: SkTextBlob shader space workaround. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: review + win build fix Created 6 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 | « gyp/gmslides.gypi ('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 d22b22752d23852e676fd18b4c8e0f445ba40fb3..6d00c6b172af0f8312e0336dab8e33f3c265e857 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -9,6 +9,7 @@
#include "SkDraw.h"
#include "SkMetaData.h"
#include "SkPatchUtils.h"
+#include "SkShader.h"
#include "SkTextBlob.h"
SkBaseDevice::SkBaseDevice()
@@ -98,6 +99,7 @@ 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) {
+ SkPaint runPaint = paint;
SkMatrix localMatrix;
SkDraw localDraw(draw);
@@ -105,9 +107,21 @@ void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSc
localMatrix = *draw.fMatrix;
localMatrix.preTranslate(x, y);
localDraw.fMatrix = &localMatrix;
+
+ if (paint.getShader()) {
+ // FIXME: We need to compensate for the translate above. This is suboptimal but
+ // temporary -- until we get proper derived class drawTextBlob implementations.
+
+ // TODO: pass x,y down to the other methods so they can handle the additional
+ // translate without needing to allocate a new shader.
+ SkMatrix shaderMatrix;
+ shaderMatrix.setTranslate(-x, -y);
+ SkAutoTUnref<SkShader> wrapper(
+ SkShader::CreateLocalMatrixShader(paint.getShader(), shaderMatrix));
+ runPaint.setShader(wrapper);
+ }
}
- SkPaint runPaint = paint;
SkTextBlob::RunIterator it(blob);
while (!it.done()) {
size_t textLen = it.glyphCount() * sizeof(uint16_t);
« no previous file with comments | « gyp/gmslides.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698