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

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: 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 unified diff | Download patch
« no previous file with comments | « 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()) {
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
115 // TODO: pass x,y down to the other methods so they can handle the a dditional
116 // translate without needing to allocate a new shader.
117 SkMatrix shaderMatrix;
118 shaderMatrix.setTranslate(-x, -y);
119 SkAutoTUnref<SkShader> wrapper(
120 SkShader::CreateLocalMatrixShader(paint.getShader(), shaderMatri x));
121 runPaint.setShader(wrapper);
122 }
108 } 123 }
109 124
110 SkPaint runPaint = paint;
111 SkTextBlob::RunIterator it(blob); 125 SkTextBlob::RunIterator it(blob);
112 while (!it.done()) { 126 while (!it.done()) {
113 size_t textLen = it.glyphCount() * sizeof(uint16_t); 127 size_t textLen = it.glyphCount() * sizeof(uint16_t);
114 const SkPoint& offset = it.offset(); 128 const SkPoint& offset = it.offset();
115 // applyFontToPaint() always overwrites the exact same attributes, 129 // applyFontToPaint() always overwrites the exact same attributes,
116 // so it is safe to not re-seed the paint. 130 // so it is safe to not re-seed the paint.
117 it.applyFontToPaint(&runPaint); 131 it.applyFontToPaint(&runPaint);
118 132
119 switch (it.positioning()) { 133 switch (it.positioning()) {
120 case SkTextBlob::kDefault_Positioning: 134 case SkTextBlob::kDefault_Positioning:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 202
189 void SkBaseDevice::EXPERIMENTAL_optimize(const SkPicture* picture) { 203 void SkBaseDevice::EXPERIMENTAL_optimize(const SkPicture* picture) {
190 // The base class doesn't perform any analysis but derived classes may 204 // The base class doesn't perform any analysis but derived classes may
191 } 205 }
192 206
193 bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const S kMatrix*, 207 bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const S kMatrix*,
194 const SkPaint*) { 208 const SkPaint*) {
195 // The base class doesn't perform any accelerated picture rendering 209 // The base class doesn't perform any accelerated picture rendering
196 return false; 210 return false;
197 } 211 }
OLDNEW
« 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