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

Side by Side Diff: src/device/xps/SkXPSDevice.cpp

Issue 963953002: XPS, DM: add SkDocument::CreateXPS (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix iOS compile Created 5 years, 9 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 | « include/device/xps/SkXPSDevice.h ('k') | src/doc/SkDocument_XPS.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 "SkTypes.h"
9
8 #ifndef UNICODE 10 #ifndef UNICODE
9 #define UNICODE 11 #define UNICODE
10 #endif 12 #endif
11 #ifndef _UNICODE 13 #ifndef _UNICODE
12 #define _UNICODE 14 #define _UNICODE
13 #endif 15 #endif
14 #include "SkTypes.h"
15 #include <ObjBase.h> 16 #include <ObjBase.h>
16 #include <XpsObjectModel.h> 17 #include <XpsObjectModel.h>
17 #include <T2EmbApi.h> 18 #include <T2EmbApi.h>
18 #include <FontSub.h> 19 #include <FontSub.h>
19 20
20 #include "SkColor.h" 21 #include "SkColor.h"
21 #include "SkConstexprMath.h" 22 #include "SkConstexprMath.h"
22 #include "SkData.h" 23 #include "SkData.h"
23 #include "SkDraw.h" 24 #include "SkDraw.h"
24 #include "SkDrawProcs.h" 25 #include "SkDrawProcs.h"
25 #include "SkEndian.h" 26 #include "SkEndian.h"
27 #include "SkGeometry.h"
26 #include "SkGlyphCache.h" 28 #include "SkGlyphCache.h"
27 #include "SkHRESULT.h" 29 #include "SkHRESULT.h"
28 #include "SkImageEncoder.h" 30 #include "SkImageEncoder.h"
29 #include "SkIStream.h" 31 #include "SkIStream.h"
30 #include "SkMaskFilter.h" 32 #include "SkMaskFilter.h"
31 #include "SkPaint.h" 33 #include "SkPaint.h"
32 #include "SkPathOps.h" 34 #include "SkPathOps.h"
33 #include "SkPoint.h" 35 #include "SkPoint.h"
34 #include "SkRasterizer.h" 36 #include "SkRasterizer.h"
35 #include "SkSFNTHeader.h" 37 #include "SkSFNTHeader.h"
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 case SkPath::kCubic_Verb: 1358 case SkPath::kCubic_Verb:
1357 segmentTypes.push(XPS_SEGMENT_TYPE_BEZIER); 1359 segmentTypes.push(XPS_SEGMENT_TYPE_BEZIER);
1358 segmentStrokes.push(stroke); 1360 segmentStrokes.push(stroke);
1359 segmentData.push(SkScalarToFLOAT(points[1].fX)); 1361 segmentData.push(SkScalarToFLOAT(points[1].fX));
1360 segmentData.push(SkScalarToFLOAT(points[1].fY)); 1362 segmentData.push(SkScalarToFLOAT(points[1].fY));
1361 segmentData.push(SkScalarToFLOAT(points[2].fX)); 1363 segmentData.push(SkScalarToFLOAT(points[2].fX));
1362 segmentData.push(SkScalarToFLOAT(points[2].fY)); 1364 segmentData.push(SkScalarToFLOAT(points[2].fY));
1363 segmentData.push(SkScalarToFLOAT(points[3].fX)); 1365 segmentData.push(SkScalarToFLOAT(points[3].fX));
1364 segmentData.push(SkScalarToFLOAT(points[3].fY)); 1366 segmentData.push(SkScalarToFLOAT(points[3].fY));
1365 break; 1367 break;
1368 case SkPath::kConic_Verb: {
1369 const SkScalar tol = SK_Scalar1 / 4;
1370 SkAutoConicToQuads converter;
1371 const SkPoint* quads =
1372 converter.computeQuads(points, iter.conicWeight(), tol);
1373 for (int i = 0; i < converter.countQuads(); ++i) {
1374 segmentTypes.push(XPS_SEGMENT_TYPE_QUADRATIC_BEZIER);
1375 segmentStrokes.push(stroke);
1376 segmentData.push(SkScalarToFLOAT(quads[2 * i + 1].fX));
1377 segmentData.push(SkScalarToFLOAT(quads[2 * i + 1].fY));
1378 segmentData.push(SkScalarToFLOAT(quads[2 * i + 2].fX));
1379 segmentData.push(SkScalarToFLOAT(quads[2 * i + 2].fY));
1380 }
1381 break;
1382 }
1366 case SkPath::kClose_Verb: 1383 case SkPath::kClose_Verb:
1367 // we ignore these, and just get the whole segment from 1384 // we ignore these, and just get the whole segment from
1368 // the corresponding line/quad/cubic verbs 1385 // the corresponding line/quad/cubic verbs
1369 break; 1386 break;
1370 default: 1387 default:
1371 SkDEBUGFAIL("unexpected verb"); 1388 SkDEBUGFAIL("unexpected verb");
1372 break; 1389 break;
1373 } 1390 }
1374 } 1391 }
1375 if (xpsFigure.get()) { 1392 if (xpsFigure.get()) {
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
2200 typeface, 2217 typeface,
2201 NULL, 2218 NULL,
2202 procs.xpsGlyphs.begin(), procs.xpsGlyphs.count(), 2219 procs.xpsGlyphs.begin(), procs.xpsGlyphs.count(),
2203 &origin, 2220 &origin,
2204 SkScalarToFLOAT(paint.getTextSize()), 2221 SkScalarToFLOAT(paint.getTextSize()),
2205 XPS_STYLE_SIMULATION_NONE, 2222 XPS_STYLE_SIMULATION_NONE,
2206 *d.fMatrix, 2223 *d.fMatrix,
2207 paint)); 2224 paint));
2208 } 2225 }
2209 2226
2210 void SkXPSDevice::drawTextOnPath(const SkDraw& d, const void* text, size_t len,
2211 const SkPath& path, const SkMatrix* matrix,
2212 const SkPaint& paint) {
2213 //This will call back into the device to do the drawing.
2214 d.drawTextOnPath((const char*)text, len, path, matrix, paint);
2215 }
2216
2217 void SkXPSDevice::drawDevice(const SkDraw& d, SkBaseDevice* dev, 2227 void SkXPSDevice::drawDevice(const SkDraw& d, SkBaseDevice* dev,
2218 int x, int y, 2228 int x, int y,
2219 const SkPaint&) { 2229 const SkPaint&) {
2220 SkXPSDevice* that = static_cast<SkXPSDevice*>(dev); 2230 SkXPSDevice* that = static_cast<SkXPSDevice*>(dev);
2221 2231
2222 SkTScopedComPtr<IXpsOMMatrixTransform> xpsTransform; 2232 SkTScopedComPtr<IXpsOMMatrixTransform> xpsTransform;
2223 XPS_MATRIX rawTransform = { 2233 XPS_MATRIX rawTransform = {
2224 1.0f, 2234 1.0f,
2225 0.0f, 2235 0.0f,
2226 0.0f, 2236 0.0f,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 IID_PPV_ARGS(&this->fXpsFactory)), 2278 IID_PPV_ARGS(&this->fXpsFactory)),
2269 "Could not create factory for layer."); 2279 "Could not create factory for layer.");
2270 2280
2271 HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas), 2281 HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas),
2272 "Could not create canvas for layer."); 2282 "Could not create canvas for layer.");
2273 } 2283 }
2274 2284
2275 bool SkXPSDevice::allowImageFilter(const SkImageFilter*) { 2285 bool SkXPSDevice::allowImageFilter(const SkImageFilter*) {
2276 return false; 2286 return false;
2277 } 2287 }
OLDNEW
« no previous file with comments | « include/device/xps/SkXPSDevice.h ('k') | src/doc/SkDocument_XPS.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698