aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2014-09-29 06:29:53 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-29 06:29:53 -0700
commit05c4a4322e7d4f3417b7df33825bab8603d52051 (patch)
tree79a22f660fe2b6b58bab4e9f8cc1c9f86f50d565 /src/gpu
parentee6631ef90fb5a9c80de6eacd37632f11367a088 (diff)
Revert of Revert of Fix SkTextBlob offset semantics. (patchset #1 id:1 of https://codereview.chromium.org/609223003/)
Reason for revert: Re-landing: Chromium-side fix to be landed with the roll (https://codereview.chromium.org/607853003/) Original issue's description: > Revert of Fix SkTextBlob offset semantics. (patchset #2 id:20001 of https://codereview.chromium.org/605533002/) > > Reason for revert: > Breaking the Chrome builds with the error: > > [14:54:14.317833] ../../skia/ext/pixel_ref_utils.cc:221:16: error: 'drawPosText' marked 'override' but does not override any member functions > [14:54:14.318022] virtual void drawPosText(const SkDraw& draw, > [14:54:14.318082] ^ > > Original issue's description: > > Fix SkTextBlob offset semantics. > > > > Implement proper x/y drawTextBlob() handling by plumbing a > > drawPosText() offset parameter (to act as an additional glyph pos > > translation) throughout the device layer. > > > > The new offset superceeds the existing constY, with a minor semantic > > tweak: whereas previous implementations were ignoring constY in 2D > > positioning mode (scalarsPerGlyph == 2), now the offset is always > > observed, in all positioning modes. We can do this because existing > > drawPosText() clients always pass constY == 0 for full positioning mode. > > > > R=reed@google.com, jvanverth@google.com, robertphillips@google.com > > > > Committed: https://skia.googlesource.com/skia/+/c13bc571d3e61a43b87eb97f0719abd304cafaf2 > > TBR=jvanverth@google.com,reed@google.com,bsalomon@google.com,fmalita@chromium.org > NOTREECHECKS=true > NOTRY=true > > Committed: https://skia.googlesource.com/skia/+/d46b8d2bab7cfba8458432248e1568ac377429e9 R=jvanverth@google.com, reed@google.com, bsalomon@google.com, robertphillips@google.com TBR=bsalomon@google.com, jvanverth@google.com, reed@google.com, robertphillips@google.com NOTREECHECKS=true NOTRY=true Author: fmalita@chromium.org Review URL: https://codereview.chromium.org/607413003
Diffstat (limited to 'src/gpu')
-rwxr-xr-xsrc/gpu/GrBitmapTextContext.cpp6
-rw-r--r--src/gpu/GrBitmapTextContext.h4
-rwxr-xr-xsrc/gpu/GrDistanceFieldTextContext.cpp12
-rw-r--r--src/gpu/GrDistanceFieldTextContext.h4
-rw-r--r--src/gpu/GrStencilAndCoverTextContext.cpp17
-rw-r--r--src/gpu/GrStencilAndCoverTextContext.h6
-rw-r--r--src/gpu/GrTextContext.h4
-rw-r--r--src/gpu/SkGpuDevice.cpp14
-rw-r--r--src/gpu/SkGpuDevice.h4
9 files changed, 34 insertions, 37 deletions
diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp
index 82784bf0e3..0f6d1b62a9 100755
--- a/src/gpu/GrBitmapTextContext.cpp
+++ b/src/gpu/GrBitmapTextContext.cpp
@@ -270,8 +270,8 @@ void GrBitmapTextContext::drawText(const GrPaint& paint, const SkPaint& skPaint,
void GrBitmapTextContext::drawPosText(const GrPaint& paint, const SkPaint& skPaint,
const char text[], size_t byteLength,
- const SkScalar pos[], SkScalar constY,
- int scalarsPerPosition) {
+ const SkScalar pos[], int scalarsPerPosition,
+ const SkPoint& offset) {
SkASSERT(byteLength == 0 || text != NULL);
SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
@@ -295,7 +295,7 @@ void GrBitmapTextContext::drawPosText(const GrPaint& paint, const SkPaint& skPai
const char* stop = text + byteLength;
SkTextAlignProc alignProc(fSkPaint.getTextAlign());
- SkTextMapStateProc tmsProc(ctm, constY, scalarsPerPosition);
+ SkTextMapStateProc tmsProc(ctm, offset, scalarsPerPosition);
SkFixed halfSampleX = 0, halfSampleY = 0;
if (cache->isSubpixel()) {
diff --git a/src/gpu/GrBitmapTextContext.h b/src/gpu/GrBitmapTextContext.h
index 80abf681f4..c136270c65 100644
--- a/src/gpu/GrBitmapTextContext.h
+++ b/src/gpu/GrBitmapTextContext.h
@@ -25,8 +25,8 @@ public:
SkScalar x, SkScalar y) SK_OVERRIDE;
virtual void drawPosText(const GrPaint&, const SkPaint&,
const char text[], size_t byteLength,
- const SkScalar pos[], SkScalar constY,
- int scalarsPerPosition) SK_OVERRIDE;
+ const SkScalar pos[], int scalarsPerPosition,
+ const SkPoint& offset) SK_OVERRIDE;
virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index 9fd024af9f..e2bd6e9f9c 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -609,8 +609,8 @@ void GrDistanceFieldTextContext::drawText(const GrPaint& paint, const SkPaint& s
void GrDistanceFieldTextContext::drawPosText(const GrPaint& paint, const SkPaint& skPaint,
const char text[], size_t byteLength,
- const SkScalar pos[], SkScalar constY,
- int scalarsPerPosition) {
+ const SkScalar pos[], int scalarsPerPosition,
+ const SkPoint& offset) {
SkASSERT(byteLength == 0 || text != NULL);
SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
@@ -638,8 +638,8 @@ void GrDistanceFieldTextContext::drawPosText(const GrPaint& paint, const SkPaint
const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
if (glyph.fWidth) {
- SkScalar x = pos[0];
- SkScalar y = scalarsPerPosition == 1 ? constY : pos[1];
+ SkScalar x = offset.x() + pos[0];
+ SkScalar y = offset.y() + (2 == scalarsPerPosition ? pos[1] : 0);
this->drawPackedGlyph(GrGlyph::Pack(glyph.getGlyphID(),
glyph.getSubXFixed(),
@@ -657,8 +657,8 @@ void GrDistanceFieldTextContext::drawPosText(const GrPaint& paint, const SkPaint
const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
if (glyph.fWidth) {
- SkScalar x = pos[0];
- SkScalar y = scalarsPerPosition == 1 ? constY : pos[1];
+ SkScalar x = offset.x() + pos[0];
+ SkScalar y = offset.y() + (2 == scalarsPerPosition ? pos[1] : 0);
this->drawPackedGlyph(GrGlyph::Pack(glyph.getGlyphID(),
glyph.getSubXFixed(),
diff --git a/src/gpu/GrDistanceFieldTextContext.h b/src/gpu/GrDistanceFieldTextContext.h
index 85d9250e44..0b08b5986c 100644
--- a/src/gpu/GrDistanceFieldTextContext.h
+++ b/src/gpu/GrDistanceFieldTextContext.h
@@ -25,8 +25,8 @@ public:
SkScalar x, SkScalar y) SK_OVERRIDE;
virtual void drawPosText(const GrPaint&, const SkPaint&,
const char text[], size_t byteLength,
- const SkScalar pos[], SkScalar constY,
- int scalarsPerPosition) SK_OVERRIDE;
+ const SkScalar pos[], int scalarsPerPosition,
+ const SkPoint& offset) SK_OVERRIDE;
virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
diff --git a/src/gpu/GrStencilAndCoverTextContext.cpp b/src/gpu/GrStencilAndCoverTextContext.cpp
index c1d9e9d32d..cfcabe923f 100644
--- a/src/gpu/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/GrStencilAndCoverTextContext.cpp
@@ -54,7 +54,7 @@ void GrStencilAndCoverTextContext::drawText(const GrPaint& paint,
// will turn off the use of device-space glyphs when perspective transforms
// are in use.
- this->init(paint, skPaint, byteLength, kMaxAccuracy_RenderMode);
+ this->init(paint, skPaint, byteLength, kMaxAccuracy_RenderMode, SkPoint::Make(0, 0));
// Transform our starting point.
if (fNeedsDeviceSpaceGlyphs) {
@@ -123,8 +123,8 @@ void GrStencilAndCoverTextContext::drawPosText(const GrPaint& paint,
const char text[],
size_t byteLength,
const SkScalar pos[],
- SkScalar constY,
- int scalarsPerPosition) {
+ int scalarsPerPosition,
+ const SkPoint& offset) {
SkASSERT(byteLength == 0 || text != NULL);
SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
@@ -141,8 +141,7 @@ void GrStencilAndCoverTextContext::drawPosText(const GrPaint& paint,
// transform is not part of SkPaint::measureText API, and thus we use the
// same glyphs as what were measured.
- const float textTranslateY = (1 == scalarsPerPosition ? constY : 0);
- this->init(paint, skPaint, byteLength, kMaxPerformance_RenderMode, textTranslateY);
+ this->init(paint, skPaint, byteLength, kMaxPerformance_RenderMode, offset);
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
@@ -171,7 +170,7 @@ void GrStencilAndCoverTextContext::drawPosText(const GrPaint& paint,
}
} else {
fTransformType = GrPathRendering::kTranslate_PathTransformType;
- SkTextMapStateProc tmsProc(SkMatrix::I(), 0, scalarsPerPosition);
+ SkTextMapStateProc tmsProc(SkMatrix::I(), SkPoint::Make(0, 0), scalarsPerPosition);
SkTextAlignProcScalar alignProc(fSkPaint.getTextAlign());
while (text < stop) {
const SkGlyph& glyph = glyphCacheProc(fGlyphCache, &text, 0, 0);
@@ -242,7 +241,7 @@ void GrStencilAndCoverTextContext::init(const GrPaint& paint,
const SkPaint& skPaint,
size_t textByteLength,
RenderMode renderMode,
- SkScalar textTranslateY) {
+ const SkPoint& textTranslate) {
GrTextContext::init(paint, skPaint);
fContextInitialMatrix = fContext->getMatrix();
@@ -258,7 +257,7 @@ void GrStencilAndCoverTextContext::init(const GrPaint& paint,
if (fNeedsDeviceSpaceGlyphs) {
// SkDraw::ShouldDrawTextAsPaths takes care of perspective transforms.
SkASSERT(!fContextInitialMatrix.hasPerspective());
- SkASSERT(0 == textTranslateY); // TODO: Handle textTranslateY in device-space usecase.
+ SkASSERT(textTranslate.isZero()); // TODO: Handle textTranslate in device-space usecase.
fTextRatio = fTextInverseRatio = 1.0f;
@@ -340,7 +339,7 @@ void GrStencilAndCoverTextContext::init(const GrPaint& paint,
}
SkMatrix textMatrix;
- textMatrix.setTranslate(0, textTranslateY);
+ textMatrix.setTranslate(textTranslate.x(), textTranslate.y());
// Glyphs loaded by GPU path rendering have an inverted y-direction.
textMatrix.preScale(fTextRatio, -fTextRatio);
fPaint.localCoordChange(textMatrix);
diff --git a/src/gpu/GrStencilAndCoverTextContext.h b/src/gpu/GrStencilAndCoverTextContext.h
index 5ba4a7027b..b6e23bdb3f 100644
--- a/src/gpu/GrStencilAndCoverTextContext.h
+++ b/src/gpu/GrStencilAndCoverTextContext.h
@@ -32,8 +32,8 @@ public:
SkScalar x, SkScalar y) SK_OVERRIDE;
virtual void drawPosText(const GrPaint&, const SkPaint&,
const char text[], size_t byteLength,
- const SkScalar pos[], SkScalar constY,
- int scalarsPerPosition) SK_OVERRIDE;
+ const SkScalar pos[], int scalarsPerPosition,
+ const SkPoint& offset) SK_OVERRIDE;
virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
@@ -62,7 +62,7 @@ private:
};
void init(const GrPaint&, const SkPaint&, size_t textByteLength,
- RenderMode, SkScalar textTranslateY = 0);
+ RenderMode, const SkPoint& textTranslate);
void initGlyphs(SkGlyphCache* cache);
void appendGlyph(uint16_t glyphID, float x);
void appendGlyph(uint16_t glyphID, float x, float y);
diff --git a/src/gpu/GrTextContext.h b/src/gpu/GrTextContext.h
index c139e22295..da41c1bb3c 100644
--- a/src/gpu/GrTextContext.h
+++ b/src/gpu/GrTextContext.h
@@ -28,8 +28,8 @@ public:
SkScalar x, SkScalar y) = 0;
virtual void drawPosText(const GrPaint&, const SkPaint&,
const char text[], size_t byteLength,
- const SkScalar pos[], SkScalar constY,
- int scalarsPerPosition) = 0;
+ const SkScalar pos[], int scalarsPerPosition,
+ const SkPoint& offset) = 0;
virtual bool canDraw(const SkPaint& paint) = 0;
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index bd075cfd97..30b3668d6b 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1713,10 +1713,9 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text,
}
}
-void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text,
- size_t byteLength, const SkScalar pos[],
- SkScalar constY, int scalarsPerPos,
- const SkPaint& paint) {
+void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteLength,
+ const SkScalar pos[], int scalarsPerPos,
+ const SkPoint& offset, const SkPaint& paint) {
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext);
CHECK_SHOULD_DRAW(draw, false);
@@ -1727,7 +1726,7 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text,
SkDEBUGCODE(this->validate();)
fMainTextContext->drawPosText(grPaint, paint, (const char *)text, byteLength, pos,
- constY, scalarsPerPos);
+ scalarsPerPos, offset);
} else if (fFallbackTextContext && fFallbackTextContext->canDraw(paint)) {
GrPaint grPaint;
SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
@@ -1735,10 +1734,9 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text,
SkDEBUGCODE(this->validate();)
fFallbackTextContext->drawPosText(grPaint, paint, (const char *)text, byteLength, pos,
- constY, scalarsPerPos);
+ scalarsPerPos, offset);
} else {
- draw.drawPosText_asPaths((const char*)text, byteLength, pos, constY,
- scalarsPerPos, paint);
+ draw.drawPosText_asPaths((const char*)text, byteLength, pos, scalarsPerPos, offset, paint);
}
}
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index 41b53b1213..f19d2cb62b 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -90,8 +90,8 @@ public:
virtual void drawText(const SkDraw&, const void* text, size_t len,
SkScalar x, SkScalar y, const SkPaint&) SK_OVERRIDE;
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
- const SkScalar pos[], SkScalar constY,
- int scalarsPerPos, const SkPaint&) SK_OVERRIDE;
+ const SkScalar pos[], int scalarsPerPos,
+ const SkPoint& offset, const SkPaint&) SK_OVERRIDE;
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
const SkPath& path, const SkMatrix* matrix,
const SkPaint&) SK_OVERRIDE;