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

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

Issue 586743002: SkTextBlob shader space workaround. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 unified diff | Download patch
« gm/textblobshader.cpp ('K') | « gyp/gmslides.gypi ('k') | no next file » | 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 "SkDraw.h" 9 #include "SkDraw.h"
10 #include "SkMetaData.h" 10 #include "SkMetaData.h"
11 #include "SkPatchUtils.h" 11 #include "SkPatchUtils.h"
12 #include "SkShader.h"
12 #include "SkTextBlob.h" 13 #include "SkTextBlob.h"
13 14
14 SkBaseDevice::SkBaseDevice() 15 SkBaseDevice::SkBaseDevice()
15 : fLeakyProperties(SkDeviceProperties::MakeDefault()) 16 : fLeakyProperties(SkDeviceProperties::MakeDefault())
16 #ifdef SK_DEBUG 17 #ifdef SK_DEBUG
17 , fAttachedToCanvas(false) 18 , fAttachedToCanvas(false)
18 #endif 19 #endif
19 { 20 {
20 fOrigin.setZero(); 21 fOrigin.setZero();
21 fMetaData = NULL; 22 fMetaData = NULL;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 if (SkPatchUtils::getVertexData(&data, cubics, colors, texCoords, lod.width( ), lod.height())) { 92 if (SkPatchUtils::getVertexData(&data, cubics, colors, texCoords, lod.width( ), lod.height())) {
92 this->drawVertices(draw, SkCanvas::kTriangles_VertexMode, data.fVertexCo unt, data.fPoints, 93 this->drawVertices(draw, SkCanvas::kTriangles_VertexMode, data.fVertexCo unt, data.fPoints,
93 data.fTexCoords, data.fColors, xmode, data.fIndices, data.fIndexCount, 94 data.fTexCoords, data.fColors, xmode, data.fIndices, data.fIndexCount,
94 paint); 95 paint);
95 } 96 }
96 } 97 }
97 98
98 void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSc alar x, SkScalar y, 99 void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSc alar x, SkScalar y,
99 const SkPaint &paint) { 100 const SkPaint &paint) {
100 101
102 SkPaint runPaint = paint;
101 SkMatrix localMatrix; 103 SkMatrix localMatrix;
102 SkDraw localDraw(draw); 104 SkDraw localDraw(draw);
103 105
104 if (x || y) { 106 if (x || y) {
105 localMatrix = *draw.fMatrix; 107 localMatrix = *draw.fMatrix;
106 localMatrix.preTranslate(x, y); 108 localMatrix.preTranslate(x, y);
107 localDraw.fMatrix = &localMatrix; 109 localDraw.fMatrix = &localMatrix;
110
111 if (paint.getShader()) {
reed1 2014/09/19 16:47:19 Tricky, but seems fine for now. Perhaps a TODO to
f(malita) 2014/09/19 17:55:53 Done.
112 // FIXME: We need to compensate for the translate above. This is sub optimal but
113 // temporary -- until we get proper derived class drawTextBlob imple mentations.
114 SkMatrix shaderMatrix;
115 shaderMatrix.setTranslate(-x, -y);
116 SkAutoTUnref<SkShader> wrapper(
117 SkShader::CreateLocalMatrixShader(paint.getShader(), shaderMatri x));
118 runPaint.setShader(wrapper);
119 }
108 } 120 }
109 121
110 SkPaint runPaint = paint;
111 SkTextBlob::RunIterator it(blob); 122 SkTextBlob::RunIterator it(blob);
112 while (!it.done()) { 123 while (!it.done()) {
113 size_t textLen = it.glyphCount() * sizeof(uint16_t); 124 size_t textLen = it.glyphCount() * sizeof(uint16_t);
114 const SkPoint& offset = it.offset(); 125 const SkPoint& offset = it.offset();
115 // applyFontToPaint() always overwrites the exact same attributes, 126 // applyFontToPaint() always overwrites the exact same attributes,
116 // so it is safe to not re-seed the paint. 127 // so it is safe to not re-seed the paint.
117 it.applyFontToPaint(&runPaint); 128 it.applyFontToPaint(&runPaint);
118 129
119 switch (it.positioning()) { 130 switch (it.positioning()) {
120 case SkTextBlob::kDefault_Positioning: 131 case SkTextBlob::kDefault_Positioning:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 199
189 void SkBaseDevice::EXPERIMENTAL_optimize(const SkPicture* picture) { 200 void SkBaseDevice::EXPERIMENTAL_optimize(const SkPicture* picture) {
190 // The base class doesn't perform any analysis but derived classes may 201 // The base class doesn't perform any analysis but derived classes may
191 } 202 }
192 203
193 bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const S kMatrix*, 204 bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const S kMatrix*,
194 const SkPaint*) { 205 const SkPaint*) {
195 // The base class doesn't perform any accelerated picture rendering 206 // The base class doesn't perform any accelerated picture rendering
196 return false; 207 return false;
197 } 208 }
OLDNEW
« gm/textblobshader.cpp ('K') | « gyp/gmslides.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698