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

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 conics 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
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
10 #ifdef SK_SUPPORT_XPS
11
8 #ifndef UNICODE 12 #ifndef UNICODE
9 #define UNICODE 13 #define UNICODE
10 #endif 14 #endif
11 #ifndef _UNICODE 15 #ifndef _UNICODE
12 #define _UNICODE 16 #define _UNICODE
13 #endif 17 #endif
14 #include "SkTypes.h"
15 #include <ObjBase.h> 18 #include <ObjBase.h>
16 #include <XpsObjectModel.h> 19 #include <XpsObjectModel.h>
17 #include <T2EmbApi.h> 20 #include <T2EmbApi.h>
18 #include <FontSub.h> 21 #include <FontSub.h>
19 22
20 #include "SkColor.h" 23 #include "SkColor.h"
21 #include "SkConstexprMath.h" 24 #include "SkConstexprMath.h"
22 #include "SkData.h" 25 #include "SkData.h"
23 #include "SkDraw.h" 26 #include "SkDraw.h"
24 #include "SkDrawProcs.h" 27 #include "SkDrawProcs.h"
25 #include "SkEndian.h" 28 #include "SkEndian.h"
29 #include "SkGeometry.h"
26 #include "SkGlyphCache.h" 30 #include "SkGlyphCache.h"
27 #include "SkHRESULT.h" 31 #include "SkHRESULT.h"
28 #include "SkImageEncoder.h" 32 #include "SkImageEncoder.h"
29 #include "SkIStream.h" 33 #include "SkIStream.h"
30 #include "SkMaskFilter.h" 34 #include "SkMaskFilter.h"
31 #include "SkPaint.h" 35 #include "SkPaint.h"
32 #include "SkPathOps.h" 36 #include "SkPathOps.h"
33 #include "SkPoint.h" 37 #include "SkPoint.h"
34 #include "SkRasterizer.h" 38 #include "SkRasterizer.h"
35 #include "SkSFNTHeader.h" 39 #include "SkSFNTHeader.h"
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 case SkPath::kCubic_Verb: 1360 case SkPath::kCubic_Verb:
1357 segmentTypes.push(XPS_SEGMENT_TYPE_BEZIER); 1361 segmentTypes.push(XPS_SEGMENT_TYPE_BEZIER);
1358 segmentStrokes.push(stroke); 1362 segmentStrokes.push(stroke);
1359 segmentData.push(SkScalarToFLOAT(points[1].fX)); 1363 segmentData.push(SkScalarToFLOAT(points[1].fX));
1360 segmentData.push(SkScalarToFLOAT(points[1].fY)); 1364 segmentData.push(SkScalarToFLOAT(points[1].fY));
1361 segmentData.push(SkScalarToFLOAT(points[2].fX)); 1365 segmentData.push(SkScalarToFLOAT(points[2].fX));
1362 segmentData.push(SkScalarToFLOAT(points[2].fY)); 1366 segmentData.push(SkScalarToFLOAT(points[2].fY));
1363 segmentData.push(SkScalarToFLOAT(points[3].fX)); 1367 segmentData.push(SkScalarToFLOAT(points[3].fX));
1364 segmentData.push(SkScalarToFLOAT(points[3].fY)); 1368 segmentData.push(SkScalarToFLOAT(points[3].fY));
1365 break; 1369 break;
1370 case SkPath::kConic_Verb: {
1371 const SkScalar tol = SK_Scalar1 / 4;
1372 SkAutoConicToQuads converter;
1373 const SkPoint* quads = converter.computeQuads(points, iter.conic Weight(), tol);
1374 for (int i = 0; i < converter.countQuads(); ++i) {
1375 segmentTypes.push(XPS_SEGMENT_TYPE_QUADRATIC_BEZIER);
1376 segmentStrokes.push(stroke);
1377 segmentData.push(SkScalarToFLOAT(quads[2 * i + 1].fX));
1378 segmentData.push(SkScalarToFLOAT(quads[2 * i + 1].fY));
1379 segmentData.push(SkScalarToFLOAT(quads[2 * i + 2].fX));
1380 segmentData.push(SkScalarToFLOAT(quads[2 * i + 2].fY));
1381 }
1382 break;
1383 }
1366 case SkPath::kClose_Verb: 1384 case SkPath::kClose_Verb:
1367 // we ignore these, and just get the whole segment from 1385 // we ignore these, and just get the whole segment from
1368 // the corresponding line/quad/cubic verbs 1386 // the corresponding line/quad/cubic verbs
1369 break; 1387 break;
1370 default: 1388 default:
1371 SkDEBUGFAIL("unexpected verb"); 1389 SkDEBUGFAIL("unexpected verb");
1372 break; 1390 break;
1373 } 1391 }
1374 } 1392 }
1375 if (xpsFigure.get()) { 1393 if (xpsFigure.get()) {
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
2200 typeface, 2218 typeface,
2201 NULL, 2219 NULL,
2202 procs.xpsGlyphs.begin(), procs.xpsGlyphs.count(), 2220 procs.xpsGlyphs.begin(), procs.xpsGlyphs.count(),
2203 &origin, 2221 &origin,
2204 SkScalarToFLOAT(paint.getTextSize()), 2222 SkScalarToFLOAT(paint.getTextSize()),
2205 XPS_STYLE_SIMULATION_NONE, 2223 XPS_STYLE_SIMULATION_NONE,
2206 *d.fMatrix, 2224 *d.fMatrix,
2207 paint)); 2225 paint));
2208 } 2226 }
2209 2227
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, 2228 void SkXPSDevice::drawDevice(const SkDraw& d, SkBaseDevice* dev,
2218 int x, int y, 2229 int x, int y,
2219 const SkPaint&) { 2230 const SkPaint&) {
2220 SkXPSDevice* that = static_cast<SkXPSDevice*>(dev); 2231 SkXPSDevice* that = static_cast<SkXPSDevice*>(dev);
2221 2232
2222 SkTScopedComPtr<IXpsOMMatrixTransform> xpsTransform; 2233 SkTScopedComPtr<IXpsOMMatrixTransform> xpsTransform;
2223 XPS_MATRIX rawTransform = { 2234 XPS_MATRIX rawTransform = {
2224 1.0f, 2235 1.0f,
2225 0.0f, 2236 0.0f,
2226 0.0f, 2237 0.0f,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 IID_PPV_ARGS(&this->fXpsFactory)), 2279 IID_PPV_ARGS(&this->fXpsFactory)),
2269 "Could not create factory for layer."); 2280 "Could not create factory for layer.");
2270 2281
2271 HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas), 2282 HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas),
2272 "Could not create canvas for layer."); 2283 "Could not create canvas for layer.");
2273 } 2284 }
2274 2285
2275 bool SkXPSDevice::allowImageFilter(const SkImageFilter*) { 2286 bool SkXPSDevice::allowImageFilter(const SkImageFilter*) {
2276 return false; 2287 return false;
2277 } 2288 }
2289
2290 #endif // SK_SUPPORT_XPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698