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

Side by Side Diff: src/core/SkDevice.cpp

Issue 609223003: Revert of Fix SkTextBlob offset semantics. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkDraw.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDevice.h" 8 #include "SkDevice.h"
9 #include "SkDeviceProperties.h" 9 #include "SkDeviceProperties.h"
10 #include "SkDraw.h" 10 #include "SkDraw.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 this->drawVertices(draw, SkCanvas::kTriangles_VertexMode, data.fVertexCo unt, data.fPoints, 89 this->drawVertices(draw, SkCanvas::kTriangles_VertexMode, data.fVertexCo unt, data.fPoints,
90 data.fTexCoords, data.fColors, xmode, data.fIndices, data.fIndexCount, 90 data.fTexCoords, data.fColors, xmode, data.fIndices, data.fIndexCount,
91 paint); 91 paint);
92 } 92 }
93 } 93 }
94 94
95 void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSc alar x, SkScalar y, 95 void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSc alar x, SkScalar y,
96 const SkPaint &paint) { 96 const SkPaint &paint) {
97 97
98 SkPaint runPaint = paint; 98 SkPaint runPaint = paint;
99 SkMatrix localMatrix;
100 SkDraw localDraw(draw);
101
102 if (x || y) {
103 localMatrix = *draw.fMatrix;
104 localMatrix.preTranslate(x, y);
105 localDraw.fMatrix = &localMatrix;
106
107 if (paint.getShader()) {
108 // FIXME: We need to compensate for the translate above. This is sub optimal but
109 // temporary -- until we get proper derived class drawTextBlob imple mentations.
110
111 // TODO: pass x,y down to the other methods so they can handle the a dditional
112 // translate without needing to allocate a new shader.
113 SkMatrix shaderMatrix;
114 shaderMatrix.setTranslate(-x, -y);
115 SkAutoTUnref<SkShader> wrapper(
116 SkShader::CreateLocalMatrixShader(paint.getShader(), shaderMatri x));
117 runPaint.setShader(wrapper);
118 }
119 }
99 120
100 SkTextBlob::RunIterator it(blob); 121 SkTextBlob::RunIterator it(blob);
101 while (!it.done()) { 122 while (!it.done()) {
102 size_t textLen = it.glyphCount() * sizeof(uint16_t); 123 size_t textLen = it.glyphCount() * sizeof(uint16_t);
103 const SkPoint& offset = it.offset(); 124 const SkPoint& offset = it.offset();
104 // applyFontToPaint() always overwrites the exact same attributes, 125 // applyFontToPaint() always overwrites the exact same attributes,
105 // so it is safe to not re-seed the paint. 126 // so it is safe to not re-seed the paint.
106 it.applyFontToPaint(&runPaint); 127 it.applyFontToPaint(&runPaint);
107 128
108 switch (it.positioning()) { 129 switch (it.positioning()) {
109 case SkTextBlob::kDefault_Positioning: 130 case SkTextBlob::kDefault_Positioning:
110 this->drawText(draw, it.glyphs(), textLen, x + offset.x(), y + offse t.y(), runPaint); 131 this->drawText(localDraw, it.glyphs(), textLen, offset.x(), offset.y (), runPaint);
111 break; 132 break;
112 case SkTextBlob::kHorizontal_Positioning: 133 case SkTextBlob::kHorizontal_Positioning:
113 this->drawPosText(draw, it.glyphs(), textLen, it.pos(), 1,
114 SkPoint::Make(x, y + offset.y()), runPaint);
115 break;
116 case SkTextBlob::kFull_Positioning: 134 case SkTextBlob::kFull_Positioning:
117 this->drawPosText(draw, it.glyphs(), textLen, it.pos(), 2, 135 this->drawPosText(localDraw, it.glyphs(), textLen, it.pos(), offset. y(),
118 SkPoint::Make(x, y), runPaint); 136 SkTextBlob::ScalarsPerGlyph(it.positioning()), run Paint);
119 break; 137 break;
120 default: 138 default:
121 SkFAIL("unhandled positioning mode"); 139 SkFAIL("unhandled positioning mode");
122 } 140 }
123 141
124 it.next(); 142 it.next();
125 } 143 }
126 } 144 }
127 145
128 bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowByt es, int x, int y) { 146 bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowByt es, int x, int y) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 198
181 void SkBaseDevice::EXPERIMENTAL_optimize(const SkPicture* picture) { 199 void SkBaseDevice::EXPERIMENTAL_optimize(const SkPicture* picture) {
182 // The base class doesn't perform any analysis but derived classes may 200 // The base class doesn't perform any analysis but derived classes may
183 } 201 }
184 202
185 bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const S kMatrix*, 203 bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const S kMatrix*,
186 const SkPaint*) { 204 const SkPaint*) {
187 // The base class doesn't perform any accelerated picture rendering 205 // The base class doesn't perform any accelerated picture rendering
188 return false; 206 return false;
189 } 207 }
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698