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

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

Issue 517663003: Expose drawTextBlob to devices. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebased. 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 | « src/core/SkCanvas.cpp ('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 "SkTextBlob.h"
12 13
13 SkBaseDevice::SkBaseDevice() 14 SkBaseDevice::SkBaseDevice()
14 : fLeakyProperties(SkDeviceProperties::MakeDefault()) 15 : fLeakyProperties(SkDeviceProperties::MakeDefault())
15 #ifdef SK_DEBUG 16 #ifdef SK_DEBUG
16 , fAttachedToCanvas(false) 17 , fAttachedToCanvas(false)
17 #endif 18 #endif
18 { 19 {
19 fOrigin.setZero(); 20 fOrigin.setZero();
20 fMetaData = NULL; 21 fMetaData = NULL;
21 } 22 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 88
88 // It automatically adjusts lodX and lodY in case it exceeds the number of i ndices. 89 // It automatically adjusts lodX and lodY in case it exceeds the number of i ndices.
89 // If it fails to generate the vertices, then we do not draw. 90 // If it fails to generate the vertices, then we do not draw.
90 if (SkPatchUtils::getVertexData(&data, cubics, colors, texCoords, lod.width( ), lod.height())) { 91 if (SkPatchUtils::getVertexData(&data, cubics, colors, texCoords, lod.width( ), lod.height())) {
91 this->drawVertices(draw, SkCanvas::kTriangles_VertexMode, data.fVertexCo unt, data.fPoints, 92 this->drawVertices(draw, SkCanvas::kTriangles_VertexMode, data.fVertexCo unt, data.fPoints,
92 data.fTexCoords, data.fColors, xmode, data.fIndices, data.fIndexCount, 93 data.fTexCoords, data.fColors, xmode, data.fIndices, data.fIndexCount,
93 paint); 94 paint);
94 } 95 }
95 } 96 }
96 97
98 void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSc alar x, SkScalar y,
99 const SkPaint &paint) {
100
101 SkMatrix localMatrix;
102 SkDraw localDraw(draw);
103
104 if (x || y) {
105 localMatrix = *draw.fMatrix;
106 localMatrix.preTranslate(x, y);
107 localDraw.fMatrix = &localMatrix;
108 }
109
110 SkPaint runPaint = paint;
111 SkTextBlob::RunIterator it(blob);
112 while (!it.done()) {
113 size_t textLen = it.glyphCount() * sizeof(uint16_t);
114 const SkPoint& offset = it.offset();
115 // applyFontToPaint() always overwrites the exact same attributes,
116 // so it is safe to not re-seed the paint.
117 it.applyFontToPaint(&runPaint);
118
119 switch (it.positioning()) {
120 case SkTextBlob::kDefault_Positioning:
121 this->drawText(localDraw, it.glyphs(), textLen, offset.x(), offset.y (), runPaint);
122 break;
123 case SkTextBlob::kHorizontal_Positioning:
124 case SkTextBlob::kFull_Positioning:
125 this->drawPosText(localDraw, it.glyphs(), textLen, it.pos(), offset. y(),
126 SkTextBlob::ScalarsPerGlyph(it.positioning()), run Paint);
127 break;
128 default:
129 SkFAIL("unhandled positioning mode");
130 }
131
132 it.next();
133 }
134 }
135
97 bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowByt es, int x, int y) { 136 bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowByt es, int x, int y) {
98 #ifdef SK_DEBUG 137 #ifdef SK_DEBUG
99 SkASSERT(info.width() > 0 && info.height() > 0); 138 SkASSERT(info.width() > 0 && info.height() > 0);
100 SkASSERT(dstP); 139 SkASSERT(dstP);
101 SkASSERT(rowBytes >= info.minRowBytes()); 140 SkASSERT(rowBytes >= info.minRowBytes());
102 SkASSERT(x >= 0 && y >= 0); 141 SkASSERT(x >= 0 && y >= 0);
103 142
104 const SkImageInfo& srcInfo = this->imageInfo(); 143 const SkImageInfo& srcInfo = this->imageInfo();
105 SkASSERT(x + info.width() <= srcInfo.width()); 144 SkASSERT(x + info.width() <= srcInfo.width());
106 SkASSERT(y + info.height() <= srcInfo.height()); 145 SkASSERT(y + info.height() <= srcInfo.height());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 188
150 void SkBaseDevice::EXPERIMENTAL_optimize(const SkPicture* picture) { 189 void SkBaseDevice::EXPERIMENTAL_optimize(const SkPicture* picture) {
151 // The base class doesn't perform any analysis but derived classes may 190 // The base class doesn't perform any analysis but derived classes may
152 } 191 }
153 192
154 bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const S kMatrix*, 193 bool SkBaseDevice::EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const S kMatrix*,
155 const SkPaint*) { 194 const SkPaint*) {
156 // The base class doesn't perform any accelerated picture rendering 195 // The base class doesn't perform any accelerated picture rendering
157 return false; 196 return false;
158 } 197 }
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698