OLD | NEW |
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" | 8 #include "SkTypes.h" |
9 | 9 |
10 #ifndef UNICODE | 10 #ifndef UNICODE |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "SkTypefacePriv.h" | 45 #include "SkTypefacePriv.h" |
46 #include "SkUtils.h" | 46 #include "SkUtils.h" |
47 #include "SkXPSDevice.h" | 47 #include "SkXPSDevice.h" |
48 | 48 |
49 //Windows defines a FLOAT type, | 49 //Windows defines a FLOAT type, |
50 //make it clear when converting a scalar that this is what is wanted. | 50 //make it clear when converting a scalar that this is what is wanted. |
51 #define SkScalarToFLOAT(n) SkScalarToFloat(n) | 51 #define SkScalarToFLOAT(n) SkScalarToFloat(n) |
52 | 52 |
53 //Dummy representation of a GUID from createId. | 53 //Dummy representation of a GUID from createId. |
54 #define L_GUID_ID L"XXXXXXXXsXXXXsXXXXsXXXXsXXXXXXXXXXXX" | 54 #define L_GUID_ID L"XXXXXXXXsXXXXsXXXXsXXXXsXXXXXXXXXXXX" |
55 //Length of GUID representation from createId, including NULL terminator. | 55 //Length of GUID representation from createId, including nullptr terminator. |
56 #define GUID_ID_LEN SK_ARRAY_COUNT(L_GUID_ID) | 56 #define GUID_ID_LEN SK_ARRAY_COUNT(L_GUID_ID) |
57 | 57 |
58 /** | 58 /** |
59 Formats a GUID and places it into buffer. | 59 Formats a GUID and places it into buffer. |
60 buffer should have space for at least GUID_ID_LEN wide characters. | 60 buffer should have space for at least GUID_ID_LEN wide characters. |
61 The string will always be wchar null terminated. | 61 The string will always be wchar null terminated. |
62 XXXXXXXXsXXXXsXXXXsXXXXsXXXXXXXXXXXX0 | 62 XXXXXXXXsXXXXsXXXXsXXXXsXXXXXXXXXXXX0 |
63 @return -1 if there was an error, > 0 if success. | 63 @return -1 if there was an error, > 0 if success. |
64 */ | 64 */ |
65 static int format_guid(const GUID& guid, | 65 static int format_guid(const GUID& guid, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 : INHERITED(make_fake_bitmap(10000, 10000), SkSurfaceProps(0, kUnknown_SkPix
elGeometry)) | 115 : INHERITED(make_fake_bitmap(10000, 10000), SkSurfaceProps(0, kUnknown_SkPix
elGeometry)) |
116 , fCurrentPage(0) { | 116 , fCurrentPage(0) { |
117 } | 117 } |
118 | 118 |
119 SkXPSDevice::SkXPSDevice(IXpsOMObjectFactory* xpsFactory) | 119 SkXPSDevice::SkXPSDevice(IXpsOMObjectFactory* xpsFactory) |
120 : INHERITED(make_fake_bitmap(10000, 10000), SkSurfaceProps(0, kUnknown_SkPix
elGeometry)) | 120 : INHERITED(make_fake_bitmap(10000, 10000), SkSurfaceProps(0, kUnknown_SkPix
elGeometry)) |
121 , fCurrentPage(0) { | 121 , fCurrentPage(0) { |
122 | 122 |
123 HRVM(CoCreateInstance( | 123 HRVM(CoCreateInstance( |
124 CLSID_XpsOMObjectFactory, | 124 CLSID_XpsOMObjectFactory, |
125 NULL, | 125 nullptr, |
126 CLSCTX_INPROC_SERVER, | 126 CLSCTX_INPROC_SERVER, |
127 IID_PPV_ARGS(&this->fXpsFactory)), | 127 IID_PPV_ARGS(&this->fXpsFactory)), |
128 "Could not create factory for layer."); | 128 "Could not create factory for layer."); |
129 | 129 |
130 HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas), | 130 HRVM(this->fXpsFactory->CreateCanvas(&this->fCurrentXpsCanvas), |
131 "Could not create canvas for layer."); | 131 "Could not create canvas for layer."); |
132 } | 132 } |
133 | 133 |
134 SkXPSDevice::~SkXPSDevice() { | 134 SkXPSDevice::~SkXPSDevice() { |
135 } | 135 } |
136 | 136 |
137 SkXPSDevice::TypefaceUse::TypefaceUse() | 137 SkXPSDevice::TypefaceUse::TypefaceUse() |
138 : typefaceId(0xffffffff) | 138 : typefaceId(0xffffffff) |
139 , fontData(NULL) | 139 , fontData(nullptr) |
140 , xpsFont(NULL) | 140 , xpsFont(nullptr) |
141 , glyphsUsed(NULL) { | 141 , glyphsUsed(nullptr) { |
142 } | 142 } |
143 | 143 |
144 SkXPSDevice::TypefaceUse::~TypefaceUse() { | 144 SkXPSDevice::TypefaceUse::~TypefaceUse() { |
145 //xpsFont owns fontData ref | 145 //xpsFont owns fontData ref |
146 this->xpsFont->Release(); | 146 this->xpsFont->Release(); |
147 delete this->glyphsUsed; | 147 delete this->glyphsUsed; |
148 } | 148 } |
149 | 149 |
150 bool SkXPSDevice::beginPortfolio(SkWStream* outputStream) { | 150 bool SkXPSDevice::beginPortfolio(SkWStream* outputStream) { |
151 if (!this->fAutoCo.succeeded()) return false; | 151 if (!this->fAutoCo.succeeded()) return false; |
152 | 152 |
153 //Create XPS Factory. | 153 //Create XPS Factory. |
154 HRBM(CoCreateInstance( | 154 HRBM(CoCreateInstance( |
155 CLSID_XpsOMObjectFactory, | 155 CLSID_XpsOMObjectFactory, |
156 NULL, | 156 nullptr, |
157 CLSCTX_INPROC_SERVER, | 157 CLSCTX_INPROC_SERVER, |
158 IID_PPV_ARGS(&this->fXpsFactory)), | 158 IID_PPV_ARGS(&this->fXpsFactory)), |
159 "Could not create XPS factory."); | 159 "Could not create XPS factory."); |
160 | 160 |
161 HRBM(SkWIStream::CreateFromSkWStream(outputStream, &this->fOutputStream), | 161 HRBM(SkWIStream::CreateFromSkWStream(outputStream, &this->fOutputStream), |
162 "Could not convert SkStream to IStream."); | 162 "Could not convert SkStream to IStream."); |
163 | 163 |
164 return true; | 164 return true; |
165 } | 165 } |
166 | 166 |
(...skipping 19 matching lines...) Expand all Loading... |
186 | 186 |
187 return true; | 187 return true; |
188 } | 188 } |
189 | 189 |
190 HRESULT SkXPSDevice::createXpsThumbnail(IXpsOMPage* page, | 190 HRESULT SkXPSDevice::createXpsThumbnail(IXpsOMPage* page, |
191 const unsigned int pageNum, | 191 const unsigned int pageNum, |
192 IXpsOMImageResource** image) { | 192 IXpsOMImageResource** image) { |
193 SkTScopedComPtr<IXpsOMThumbnailGenerator> thumbnailGenerator; | 193 SkTScopedComPtr<IXpsOMThumbnailGenerator> thumbnailGenerator; |
194 HRM(CoCreateInstance( | 194 HRM(CoCreateInstance( |
195 CLSID_XpsOMThumbnailGenerator, | 195 CLSID_XpsOMThumbnailGenerator, |
196 NULL, | 196 nullptr, |
197 CLSCTX_INPROC_SERVER, | 197 CLSCTX_INPROC_SERVER, |
198 IID_PPV_ARGS(&thumbnailGenerator)), | 198 IID_PPV_ARGS(&thumbnailGenerator)), |
199 "Could not create thumbnail generator."); | 199 "Could not create thumbnail generator."); |
200 | 200 |
201 SkTScopedComPtr<IOpcPartUri> partUri; | 201 SkTScopedComPtr<IOpcPartUri> partUri; |
202 static const size_t size = SkTUMax< | 202 static const size_t size = SkTUMax< |
203 SK_ARRAY_COUNT(L"/Documents/1/Metadata/.png") + SK_DIGITS_IN(pageNum), | 203 SK_ARRAY_COUNT(L"/Documents/1/Metadata/.png") + SK_DIGITS_IN(pageNum), |
204 SK_ARRAY_COUNT(L"/Metadata/" L_GUID_ID L".png") | 204 SK_ARRAY_COUNT(L"/Metadata/" L_GUID_ID L".png") |
205 >::value; | 205 >::value; |
206 wchar_t buffer[size]; | 206 wchar_t buffer[size]; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 { | 250 { |
251 SkTScopedComPtr<IOpcPartUri> partUri; | 251 SkTScopedComPtr<IOpcPartUri> partUri; |
252 HRM(this->fXpsFactory->CreatePartUri(L"/FixedDocumentSequence.fdseq", | 252 HRM(this->fXpsFactory->CreatePartUri(L"/FixedDocumentSequence.fdseq", |
253 &partUri), | 253 &partUri), |
254 "Could not create document sequence part uri."); | 254 "Could not create document sequence part uri."); |
255 HRM(this->fXpsFactory->CreatePackageWriterOnStream( | 255 HRM(this->fXpsFactory->CreatePackageWriterOnStream( |
256 this->fOutputStream.get(), | 256 this->fOutputStream.get(), |
257 TRUE, | 257 TRUE, |
258 XPS_INTERLEAVING_OFF, //XPS_INTERLEAVING_ON, | 258 XPS_INTERLEAVING_OFF, //XPS_INTERLEAVING_ON, |
259 partUri.get(), | 259 partUri.get(), |
260 NULL, | 260 nullptr, |
261 image, | 261 image, |
262 NULL, | 262 nullptr, |
263 NULL, | 263 nullptr, |
264 &this->fPackageWriter), | 264 &this->fPackageWriter), |
265 "Could not create package writer."); | 265 "Could not create package writer."); |
266 } | 266 } |
267 | 267 |
268 //Begin the lone document. | 268 //Begin the lone document. |
269 { | 269 { |
270 SkTScopedComPtr<IOpcPartUri> partUri; | 270 SkTScopedComPtr<IOpcPartUri> partUri; |
271 HRM(this->fXpsFactory->CreatePartUri( | 271 HRM(this->fXpsFactory->CreatePartUri( |
272 L"/Documents/1/FixedDocument.fdoc", | 272 L"/Documents/1/FixedDocument.fdoc", |
273 &partUri), | 273 &partUri), |
274 "Could not create fixed document part uri."); | 274 "Could not create fixed document part uri."); |
275 HRM(this->fPackageWriter->StartNewDocument(partUri.get(), | 275 HRM(this->fPackageWriter->StartNewDocument(partUri.get(), |
276 NULL, | 276 nullptr, |
277 NULL, | 277 nullptr, |
278 NULL, | 278 nullptr, |
279 NULL), | 279 nullptr), |
280 "Could not start document."); | 280 "Could not start document."); |
281 } | 281 } |
282 | 282 |
283 return S_OK; | 283 return S_OK; |
284 } | 284 } |
285 | 285 |
286 bool SkXPSDevice::endSheet() { | 286 bool SkXPSDevice::endSheet() { |
287 //XPS is fixed at 96dpi (XPS Spec 11.1). | 287 //XPS is fixed at 96dpi (XPS Spec 11.1). |
288 static const float xpsDPI = 96.0f; | 288 static const float xpsDPI = 96.0f; |
289 static const float inchesPerMeter = 10000.0f / 254.0f; | 289 static const float inchesPerMeter = 10000.0f / 254.0f; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 HRB(this->createXpsPage(pageSize, &page)); | 321 HRB(this->createXpsPage(pageSize, &page)); |
322 | 322 |
323 SkTScopedComPtr<IXpsOMVisualCollection> pageVisuals; | 323 SkTScopedComPtr<IXpsOMVisualCollection> pageVisuals; |
324 HRBM(page->GetVisuals(&pageVisuals), "Could not get page visuals."); | 324 HRBM(page->GetVisuals(&pageVisuals), "Could not get page visuals."); |
325 | 325 |
326 //Add the scale canvas to the page. | 326 //Add the scale canvas to the page. |
327 HRBM(pageVisuals->Append(scaleCanvas.get()), | 327 HRBM(pageVisuals->Append(scaleCanvas.get()), |
328 "Could not add scale canvas to page."); | 328 "Could not add scale canvas to page."); |
329 | 329 |
330 //Create the package writer if it hasn't been created yet. | 330 //Create the package writer if it hasn't been created yet. |
331 if (NULL == this->fPackageWriter.get()) { | 331 if (nullptr == this->fPackageWriter.get()) { |
332 SkTScopedComPtr<IXpsOMImageResource> image; | 332 SkTScopedComPtr<IXpsOMImageResource> image; |
333 //Ignore return, thumbnail is completely optional. | 333 //Ignore return, thumbnail is completely optional. |
334 this->createXpsThumbnail(page.get(), 0, &image); | 334 this->createXpsThumbnail(page.get(), 0, &image); |
335 | 335 |
336 HRB(this->initXpsDocumentWriter(image.get())); | 336 HRB(this->initXpsDocumentWriter(image.get())); |
337 } | 337 } |
338 | 338 |
339 HRBM(this->fPackageWriter->AddPage(page.get(), | 339 HRBM(this->fPackageWriter->AddPage(page.get(), |
340 &pageSize, | 340 &pageSize, |
341 NULL, | 341 nullptr, |
342 NULL, | 342 nullptr, |
343 NULL, | 343 nullptr, |
344 NULL), | 344 nullptr), |
345 "Could not write the page."); | 345 "Could not write the page."); |
346 this->fCurrentXpsCanvas.reset(); | 346 this->fCurrentXpsCanvas.reset(); |
347 | 347 |
348 return true; | 348 return true; |
349 } | 349 } |
350 | 350 |
351 static HRESULT subset_typeface(SkXPSDevice::TypefaceUse* current) { | 351 static HRESULT subset_typeface(SkXPSDevice::TypefaceUse* current) { |
352 //CreateFontPackage wants unsigned short. | 352 //CreateFontPackage wants unsigned short. |
353 //Microsoft, Y U NO stdint.h? | 353 //Microsoft, Y U NO stdint.h? |
354 SkTDArray<unsigned short> keepList; | 354 SkTDArray<unsigned short> keepList; |
355 current->glyphsUsed->exportTo(&keepList); | 355 current->glyphsUsed->exportTo(&keepList); |
356 | 356 |
357 int ttcCount = (current->ttcIndex + 1); | 357 int ttcCount = (current->ttcIndex + 1); |
358 | 358 |
359 //The following are declared with the types required by CreateFontPackage. | 359 //The following are declared with the types required by CreateFontPackage. |
360 unsigned char *fontPackageBufferRaw = NULL; | 360 unsigned char *fontPackageBufferRaw = nullptr; |
361 unsigned long fontPackageBufferSize; | 361 unsigned long fontPackageBufferSize; |
362 unsigned long bytesWritten; | 362 unsigned long bytesWritten; |
363 unsigned long result = CreateFontPackage( | 363 unsigned long result = CreateFontPackage( |
364 (unsigned char *) current->fontData->getMemoryBase(), | 364 (unsigned char *) current->fontData->getMemoryBase(), |
365 (unsigned long) current->fontData->getLength(), | 365 (unsigned long) current->fontData->getLength(), |
366 &fontPackageBufferRaw, | 366 &fontPackageBufferRaw, |
367 &fontPackageBufferSize, | 367 &fontPackageBufferSize, |
368 &bytesWritten, | 368 &bytesWritten, |
369 TTFCFP_FLAGS_SUBSET | TTFCFP_FLAGS_GLYPHLIST | (ttcCount > 0 ? TTFCFP_FL
AGS_TTC : 0), | 369 TTFCFP_FLAGS_SUBSET | TTFCFP_FLAGS_GLYPHLIST | (ttcCount > 0 ? TTFCFP_FL
AGS_TTC : 0), |
370 current->ttcIndex, | 370 current->ttcIndex, |
371 TTFCFP_SUBSET, | 371 TTFCFP_SUBSET, |
372 0, | 372 0, |
373 0, | 373 0, |
374 0, | 374 0, |
375 keepList.begin(), | 375 keepList.begin(), |
376 keepList.count(), | 376 keepList.count(), |
377 sk_malloc_throw, | 377 sk_malloc_throw, |
378 sk_realloc_throw, | 378 sk_realloc_throw, |
379 sk_free, | 379 sk_free, |
380 NULL); | 380 nullptr); |
381 SkAutoTMalloc<unsigned char> fontPackageBuffer(fontPackageBufferRaw); | 381 SkAutoTMalloc<unsigned char> fontPackageBuffer(fontPackageBufferRaw); |
382 if (result != NO_ERROR) { | 382 if (result != NO_ERROR) { |
383 SkDEBUGF(("CreateFontPackage Error %lu", result)); | 383 SkDEBUGF(("CreateFontPackage Error %lu", result)); |
384 return E_UNEXPECTED; | 384 return E_UNEXPECTED; |
385 } | 385 } |
386 | 386 |
387 // If it was originally a ttc, keep it a ttc. | 387 // If it was originally a ttc, keep it a ttc. |
388 // CreateFontPackage over-allocates, realloc usually decreases the size subs
tantially. | 388 // CreateFontPackage over-allocates, realloc usually decreases the size subs
tantially. |
389 size_t extra; | 389 size_t extra; |
390 if (ttcCount > 0) { | 390 if (ttcCount > 0) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 + (stopTransformed.fY - startTransformed.fY); | 528 + (stopTransformed.fY - startTransformed.fY); |
529 //Percentage along transformed line. | 529 //Percentage along transformed line. |
530 stopOffsets[i] = startToStop / startToEnd; | 530 stopOffsets[i] = startToStop / startToEnd; |
531 } | 531 } |
532 } | 532 } |
533 | 533 |
534 HRESULT SkXPSDevice::createXpsTransform(const SkMatrix& matrix, | 534 HRESULT SkXPSDevice::createXpsTransform(const SkMatrix& matrix, |
535 IXpsOMMatrixTransform** xpsTransform) { | 535 IXpsOMMatrixTransform** xpsTransform) { |
536 SkScalar affine[6]; | 536 SkScalar affine[6]; |
537 if (!matrix.asAffine(affine)) { | 537 if (!matrix.asAffine(affine)) { |
538 *xpsTransform = NULL; | 538 *xpsTransform = nullptr; |
539 return S_FALSE; | 539 return S_FALSE; |
540 } | 540 } |
541 XPS_MATRIX rawXpsMatrix = { | 541 XPS_MATRIX rawXpsMatrix = { |
542 SkScalarToFLOAT(affine[SkMatrix::kAScaleX]), | 542 SkScalarToFLOAT(affine[SkMatrix::kAScaleX]), |
543 SkScalarToFLOAT(affine[SkMatrix::kASkewY]), | 543 SkScalarToFLOAT(affine[SkMatrix::kASkewY]), |
544 SkScalarToFLOAT(affine[SkMatrix::kASkewX]), | 544 SkScalarToFLOAT(affine[SkMatrix::kASkewX]), |
545 SkScalarToFLOAT(affine[SkMatrix::kAScaleY]), | 545 SkScalarToFLOAT(affine[SkMatrix::kAScaleY]), |
546 SkScalarToFLOAT(affine[SkMatrix::kATransX]), | 546 SkScalarToFLOAT(affine[SkMatrix::kATransX]), |
547 SkScalarToFLOAT(affine[SkMatrix::kATransY]), | 547 SkScalarToFLOAT(affine[SkMatrix::kATransY]), |
548 }; | 548 }; |
(...skipping 19 matching lines...) Expand all Loading... |
568 | 568 |
569 HRM(visuals->Append(*path), "Could not add path to visuals."); | 569 HRM(visuals->Append(*path), "Could not add path to visuals."); |
570 return S_OK; | 570 return S_OK; |
571 } | 571 } |
572 | 572 |
573 HRESULT SkXPSDevice::createXpsSolidColorBrush(const SkColor skColor, | 573 HRESULT SkXPSDevice::createXpsSolidColorBrush(const SkColor skColor, |
574 const SkAlpha alpha, | 574 const SkAlpha alpha, |
575 IXpsOMBrush** xpsBrush) { | 575 IXpsOMBrush** xpsBrush) { |
576 XPS_COLOR xpsColor = xps_color(skColor); | 576 XPS_COLOR xpsColor = xps_color(skColor); |
577 SkTScopedComPtr<IXpsOMSolidColorBrush> solidBrush; | 577 SkTScopedComPtr<IXpsOMSolidColorBrush> solidBrush; |
578 HRM(this->fXpsFactory->CreateSolidColorBrush(&xpsColor, NULL, &solidBrush), | 578 HRM(this->fXpsFactory->CreateSolidColorBrush(&xpsColor, nullptr, &solidBrush
), |
579 "Could not create solid color brush."); | 579 "Could not create solid color brush."); |
580 HRM(solidBrush->SetOpacity(alpha / 255.0f), "Could not set opacity."); | 580 HRM(solidBrush->SetOpacity(alpha / 255.0f), "Could not set opacity."); |
581 HRM(solidBrush->QueryInterface<IXpsOMBrush>(xpsBrush), "QI Fail."); | 581 HRM(solidBrush->QueryInterface<IXpsOMBrush>(xpsBrush), "QI Fail."); |
582 return S_OK; | 582 return S_OK; |
583 } | 583 } |
584 | 584 |
585 HRESULT SkXPSDevice::sideOfClamp(const SkRect& areaToFill, | 585 HRESULT SkXPSDevice::sideOfClamp(const SkRect& areaToFill, |
586 const XPS_RECT& imageViewBox, | 586 const XPS_RECT& imageViewBox, |
587 IXpsOMImageResource* image, | 587 IXpsOMImageResource* image, |
588 IXpsOMVisualCollection* visuals) { | 588 IXpsOMVisualCollection* visuals) { |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 } | 833 } |
834 | 834 |
835 return S_OK; | 835 return S_OK; |
836 } | 836 } |
837 | 837 |
838 HRESULT SkXPSDevice::createXpsGradientStop(const SkColor skColor, | 838 HRESULT SkXPSDevice::createXpsGradientStop(const SkColor skColor, |
839 const SkScalar offset, | 839 const SkScalar offset, |
840 IXpsOMGradientStop** xpsGradStop) { | 840 IXpsOMGradientStop** xpsGradStop) { |
841 XPS_COLOR gradStopXpsColor = xps_color(skColor); | 841 XPS_COLOR gradStopXpsColor = xps_color(skColor); |
842 HRM(this->fXpsFactory->CreateGradientStop(&gradStopXpsColor, | 842 HRM(this->fXpsFactory->CreateGradientStop(&gradStopXpsColor, |
843 NULL, | 843 nullptr, |
844 SkScalarToFLOAT(offset), | 844 SkScalarToFLOAT(offset), |
845 xpsGradStop), | 845 xpsGradStop), |
846 "Could not create gradient stop."); | 846 "Could not create gradient stop."); |
847 return S_OK; | 847 return S_OK; |
848 } | 848 } |
849 | 849 |
850 HRESULT SkXPSDevice::createXpsLinearGradient(SkShader::GradientInfo info, | 850 HRESULT SkXPSDevice::createXpsLinearGradient(SkShader::GradientInfo info, |
851 const SkAlpha alpha, | 851 const SkAlpha alpha, |
852 const SkMatrix& localMatrix, | 852 const SkMatrix& localMatrix, |
853 IXpsOMMatrixTransform* xpsMatrix, | 853 IXpsOMMatrixTransform* xpsMatrix, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 "Could not set opacity of radial gradient brush."); | 983 "Could not set opacity of radial gradient brush."); |
984 HRM(gradientBrush->QueryInterface<IXpsOMBrush>(xpsBrush), "QI failed."); | 984 HRM(gradientBrush->QueryInterface<IXpsOMBrush>(xpsBrush), "QI failed."); |
985 | 985 |
986 return S_OK; | 986 return S_OK; |
987 } | 987 } |
988 | 988 |
989 HRESULT SkXPSDevice::createXpsBrush(const SkPaint& skPaint, | 989 HRESULT SkXPSDevice::createXpsBrush(const SkPaint& skPaint, |
990 IXpsOMBrush** brush, | 990 IXpsOMBrush** brush, |
991 const SkMatrix* parentTransform) { | 991 const SkMatrix* parentTransform) { |
992 const SkShader *shader = skPaint.getShader(); | 992 const SkShader *shader = skPaint.getShader(); |
993 if (NULL == shader) { | 993 if (nullptr == shader) { |
994 HR(this->createXpsSolidColorBrush(skPaint.getColor(), 0xFF, brush)); | 994 HR(this->createXpsSolidColorBrush(skPaint.getColor(), 0xFF, brush)); |
995 return S_OK; | 995 return S_OK; |
996 } | 996 } |
997 | 997 |
998 //Gradient shaders. | 998 //Gradient shaders. |
999 SkShader::GradientInfo info; | 999 SkShader::GradientInfo info; |
1000 info.fColorCount = 0; | 1000 info.fColorCount = 0; |
1001 info.fColors = NULL; | 1001 info.fColors = nullptr; |
1002 info.fColorOffsets = NULL; | 1002 info.fColorOffsets = nullptr; |
1003 SkShader::GradientType gradientType = shader->asAGradient(&info); | 1003 SkShader::GradientType gradientType = shader->asAGradient(&info); |
1004 | 1004 |
1005 if (SkShader::kNone_GradientType == gradientType) { | 1005 if (SkShader::kNone_GradientType == gradientType) { |
1006 //Nothing to see, move along. | 1006 //Nothing to see, move along. |
1007 | 1007 |
1008 } else if (SkShader::kColor_GradientType == gradientType) { | 1008 } else if (SkShader::kColor_GradientType == gradientType) { |
1009 SkASSERT(1 == info.fColorCount); | 1009 SkASSERT(1 == info.fColorCount); |
1010 SkColor color; | 1010 SkColor color; |
1011 info.fColors = &color; | 1011 info.fColors = &color; |
1012 shader->asAGradient(&info); | 1012 shader->asAGradient(&info); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 const SkRect& r, | 1193 const SkRect& r, |
1194 const SkPaint& paint) { | 1194 const SkPaint& paint) { |
1195 this->internalDrawRect(d, r, true, paint); | 1195 this->internalDrawRect(d, r, true, paint); |
1196 } | 1196 } |
1197 | 1197 |
1198 void SkXPSDevice::drawRRect(const SkDraw& d, | 1198 void SkXPSDevice::drawRRect(const SkDraw& d, |
1199 const SkRRect& rr, | 1199 const SkRRect& rr, |
1200 const SkPaint& paint) { | 1200 const SkPaint& paint) { |
1201 SkPath path; | 1201 SkPath path; |
1202 path.addRRect(rr); | 1202 path.addRRect(rr); |
1203 this->drawPath(d, path, paint, NULL, true); | 1203 this->drawPath(d, path, paint, nullptr, true); |
1204 } | 1204 } |
1205 | 1205 |
1206 void SkXPSDevice::internalDrawRect(const SkDraw& d, | 1206 void SkXPSDevice::internalDrawRect(const SkDraw& d, |
1207 const SkRect& r, | 1207 const SkRect& r, |
1208 bool transformRect, | 1208 bool transformRect, |
1209 const SkPaint& paint) { | 1209 const SkPaint& paint) { |
1210 //Exit early if there is nothing to draw. | 1210 //Exit early if there is nothing to draw. |
1211 if (d.fClip->isEmpty() || | 1211 if (d.fClip->isEmpty() || |
1212 (paint.getAlpha() == 0 && paint.getXfermode() == NULL)) { | 1212 (paint.getAlpha() == 0 && paint.getXfermode() == nullptr)) { |
1213 return; | 1213 return; |
1214 } | 1214 } |
1215 | 1215 |
1216 //Path the rect if we can't optimize it. | 1216 //Path the rect if we can't optimize it. |
1217 if (rect_must_be_pathed(paint, *d.fMatrix)) { | 1217 if (rect_must_be_pathed(paint, *d.fMatrix)) { |
1218 SkPath tmp; | 1218 SkPath tmp; |
1219 tmp.addRect(r); | 1219 tmp.addRect(r); |
1220 tmp.setFillType(SkPath::kWinding_FillType); | 1220 tmp.setFillType(SkPath::kWinding_FillType); |
1221 this->drawPath(d, tmp, paint, NULL, true); | 1221 this->drawPath(d, tmp, paint, nullptr, true); |
1222 return; | 1222 return; |
1223 } | 1223 } |
1224 | 1224 |
1225 //Create the shaded path. | 1225 //Create the shaded path. |
1226 SkTScopedComPtr<IXpsOMPath> shadedPath; | 1226 SkTScopedComPtr<IXpsOMPath> shadedPath; |
1227 HRVM(this->fXpsFactory->CreatePath(&shadedPath), | 1227 HRVM(this->fXpsFactory->CreatePath(&shadedPath), |
1228 "Could not create shaded path for rect."); | 1228 "Could not create shaded path for rect."); |
1229 | 1229 |
1230 //Create the shaded geometry. | 1230 //Create the shaded geometry. |
1231 SkTScopedComPtr<IXpsOMGeometry> shadedGeometry; | 1231 SkTScopedComPtr<IXpsOMGeometry> shadedGeometry; |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 | 1518 |
1519 void SkXPSDevice::drawPath(const SkDraw& d, | 1519 void SkXPSDevice::drawPath(const SkDraw& d, |
1520 const SkPath& platonicPath, | 1520 const SkPath& platonicPath, |
1521 const SkPaint& origPaint, | 1521 const SkPaint& origPaint, |
1522 const SkMatrix* prePathMatrix, | 1522 const SkMatrix* prePathMatrix, |
1523 bool pathIsMutable) { | 1523 bool pathIsMutable) { |
1524 SkTCopyOnFirstWrite<SkPaint> paint(origPaint); | 1524 SkTCopyOnFirstWrite<SkPaint> paint(origPaint); |
1525 | 1525 |
1526 // nothing to draw | 1526 // nothing to draw |
1527 if (d.fClip->isEmpty() || | 1527 if (d.fClip->isEmpty() || |
1528 (paint->getAlpha() == 0 && paint->getXfermode() == NULL)) { | 1528 (paint->getAlpha() == 0 && paint->getXfermode() == nullptr)) { |
1529 return; | 1529 return; |
1530 } | 1530 } |
1531 | 1531 |
1532 SkPath modifiedPath; | 1532 SkPath modifiedPath; |
1533 const bool paintHasPathEffect = paint->getPathEffect() | 1533 const bool paintHasPathEffect = paint->getPathEffect() |
1534 || paint->getStyle() != SkPaint::kFill_Style; | 1534 || paint->getStyle() != SkPaint::kFill_Style; |
1535 | 1535 |
1536 //Apply pre-path matrix [Platonic-path -> Skeletal-path]. | 1536 //Apply pre-path matrix [Platonic-path -> Skeletal-path]. |
1537 SkMatrix matrix = *d.fMatrix; | 1537 SkMatrix matrix = *d.fMatrix; |
1538 SkPath* skeletalPath = const_cast<SkPath*>(&platonicPath); | 1538 SkPath* skeletalPath = const_cast<SkPath*>(&platonicPath); |
(...skipping 12 matching lines...) Expand all Loading... |
1551 //Apply path effect [Skeletal-path -> Fillable-path]. | 1551 //Apply path effect [Skeletal-path -> Fillable-path]. |
1552 SkPath* fillablePath = skeletalPath; | 1552 SkPath* fillablePath = skeletalPath; |
1553 if (paintHasPathEffect) { | 1553 if (paintHasPathEffect) { |
1554 if (!pathIsMutable) { | 1554 if (!pathIsMutable) { |
1555 fillablePath = &modifiedPath; | 1555 fillablePath = &modifiedPath; |
1556 pathIsMutable = true; | 1556 pathIsMutable = true; |
1557 } | 1557 } |
1558 bool fill = paint->getFillPath(*skeletalPath, fillablePath); | 1558 bool fill = paint->getFillPath(*skeletalPath, fillablePath); |
1559 | 1559 |
1560 SkPaint* writablePaint = paint.writable(); | 1560 SkPaint* writablePaint = paint.writable(); |
1561 writablePaint->setPathEffect(NULL); | 1561 writablePaint->setPathEffect(nullptr); |
1562 if (fill) { | 1562 if (fill) { |
1563 writablePaint->setStyle(SkPaint::kFill_Style); | 1563 writablePaint->setStyle(SkPaint::kFill_Style); |
1564 } else { | 1564 } else { |
1565 writablePaint->setStyle(SkPaint::kStroke_Style); | 1565 writablePaint->setStyle(SkPaint::kStroke_Style); |
1566 writablePaint->setStrokeWidth(0); | 1566 writablePaint->setStrokeWidth(0); |
1567 } | 1567 } |
1568 } | 1568 } |
1569 | 1569 |
1570 //Create the shaded path. This will be the path which is painted. | 1570 //Create the shaded path. This will be the path which is painted. |
1571 SkTScopedComPtr<IXpsOMPath> shadedPath; | 1571 SkTScopedComPtr<IXpsOMPath> shadedPath; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1603 //Rasterizer | 1603 //Rasterizer |
1604 if (rasterizer) { | 1604 if (rasterizer) { |
1605 SkIRect clipIRect; | 1605 SkIRect clipIRect; |
1606 SkVector ppuScale; | 1606 SkVector ppuScale; |
1607 this->convertToPpm(filter, | 1607 this->convertToPpm(filter, |
1608 &matrix, | 1608 &matrix, |
1609 &ppuScale, | 1609 &ppuScale, |
1610 d.fClip->getBounds(), | 1610 d.fClip->getBounds(), |
1611 &clipIRect); | 1611 &clipIRect); |
1612 | 1612 |
1613 SkMask* mask = NULL; | 1613 SkMask* mask = nullptr; |
1614 | 1614 |
1615 //[Fillable-path -> Mask] | 1615 //[Fillable-path -> Mask] |
1616 SkMask rasteredMask; | 1616 SkMask rasteredMask; |
1617 if (rasterizer->rasterize( | 1617 if (rasterizer->rasterize( |
1618 *fillablePath, | 1618 *fillablePath, |
1619 matrix, | 1619 matrix, |
1620 &clipIRect, | 1620 &clipIRect, |
1621 filter, //just to compute how much to draw. | 1621 filter, //just to compute how much to draw. |
1622 &rasteredMask, | 1622 &rasteredMask, |
1623 SkMask::kComputeBoundsAndRenderImage_CreateMode)) { | 1623 SkMask::kComputeBoundsAndRenderImage_CreateMode)) { |
1624 | 1624 |
1625 SkAutoMaskFreeImage rasteredAmi(rasteredMask.fImage); | 1625 SkAutoMaskFreeImage rasteredAmi(rasteredMask.fImage); |
1626 mask = &rasteredMask; | 1626 mask = &rasteredMask; |
1627 | 1627 |
1628 //[Mask -> Mask] | 1628 //[Mask -> Mask] |
1629 SkMask filteredMask; | 1629 SkMask filteredMask; |
1630 if (filter && | 1630 if (filter && |
1631 filter->filterMask(&filteredMask, *mask, *d.fMatrix, NULL)) { | 1631 filter->filterMask(&filteredMask, *mask, *d.fMatrix, nullptr)) { |
1632 | 1632 |
1633 mask = &filteredMask; | 1633 mask = &filteredMask; |
1634 } else { | 1634 } else { |
1635 filteredMask.fImage = NULL; | 1635 filteredMask.fImage = nullptr; |
1636 } | 1636 } |
1637 SkAutoMaskFreeImage filteredAmi(filteredMask.fImage); | 1637 SkAutoMaskFreeImage filteredAmi(filteredMask.fImage); |
1638 | 1638 |
1639 //Draw mask. | 1639 //Draw mask. |
1640 HRV(this->applyMask(d, *mask, ppuScale, shadedPath.get())); | 1640 HRV(this->applyMask(d, *mask, ppuScale, shadedPath.get())); |
1641 } | 1641 } |
1642 return; | 1642 return; |
1643 } | 1643 } |
1644 | 1644 |
1645 //Mask filter | 1645 //Mask filter |
1646 if (filter) { | 1646 if (filter) { |
1647 SkIRect clipIRect; | 1647 SkIRect clipIRect; |
1648 SkVector ppuScale; | 1648 SkVector ppuScale; |
1649 this->convertToPpm(filter, | 1649 this->convertToPpm(filter, |
1650 &matrix, | 1650 &matrix, |
1651 &ppuScale, | 1651 &ppuScale, |
1652 d.fClip->getBounds(), | 1652 d.fClip->getBounds(), |
1653 &clipIRect); | 1653 &clipIRect); |
1654 | 1654 |
1655 //[Fillable-path -> Pixel-path] | 1655 //[Fillable-path -> Pixel-path] |
1656 SkPath* pixelPath = pathIsMutable ? fillablePath : &modifiedPath; | 1656 SkPath* pixelPath = pathIsMutable ? fillablePath : &modifiedPath; |
1657 fillablePath->transform(matrix, pixelPath); | 1657 fillablePath->transform(matrix, pixelPath); |
1658 | 1658 |
1659 SkMask* mask = NULL; | 1659 SkMask* mask = nullptr; |
1660 | 1660 |
1661 //[Pixel-path -> Mask] | 1661 //[Pixel-path -> Mask] |
1662 SkMask rasteredMask; | 1662 SkMask rasteredMask; |
1663 if (SkDraw::DrawToMask( | 1663 if (SkDraw::DrawToMask( |
1664 *pixelPath, | 1664 *pixelPath, |
1665 &clipIRect, | 1665 &clipIRect, |
1666 filter, //just to compute how much to draw. | 1666 filter, //just to compute how much to draw. |
1667 &matrix, | 1667 &matrix, |
1668 &rasteredMask, | 1668 &rasteredMask, |
1669 SkMask::kComputeBoundsAndRenderImage_CreateMode, | 1669 SkMask::kComputeBoundsAndRenderImage_CreateMode, |
1670 paint->getStyle())) { | 1670 paint->getStyle())) { |
1671 | 1671 |
1672 SkAutoMaskFreeImage rasteredAmi(rasteredMask.fImage); | 1672 SkAutoMaskFreeImage rasteredAmi(rasteredMask.fImage); |
1673 mask = &rasteredMask; | 1673 mask = &rasteredMask; |
1674 | 1674 |
1675 //[Mask -> Mask] | 1675 //[Mask -> Mask] |
1676 SkMask filteredMask; | 1676 SkMask filteredMask; |
1677 if (filter->filterMask(&filteredMask, | 1677 if (filter->filterMask(&filteredMask, |
1678 rasteredMask, | 1678 rasteredMask, |
1679 matrix, | 1679 matrix, |
1680 NULL)) { | 1680 nullptr)) { |
1681 mask = &filteredMask; | 1681 mask = &filteredMask; |
1682 } else { | 1682 } else { |
1683 filteredMask.fImage = NULL; | 1683 filteredMask.fImage = nullptr; |
1684 } | 1684 } |
1685 SkAutoMaskFreeImage filteredAmi(filteredMask.fImage); | 1685 SkAutoMaskFreeImage filteredAmi(filteredMask.fImage); |
1686 | 1686 |
1687 //Draw mask. | 1687 //Draw mask. |
1688 HRV(this->applyMask(d, *mask, ppuScale, shadedPath.get())); | 1688 HRV(this->applyMask(d, *mask, ppuScale, shadedPath.get())); |
1689 } | 1689 } |
1690 return; | 1690 return; |
1691 } | 1691 } |
1692 | 1692 |
1693 //Get the figures from the shaded geometry. | 1693 //Get the figures from the shaded geometry. |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1997 HRM(glyphsEditor->SetGlyphIndices(xpsGlyphsLen, xpsGlyphs), | 1997 HRM(glyphsEditor->SetGlyphIndices(xpsGlyphsLen, xpsGlyphs), |
1998 "Could not set glyphs."); | 1998 "Could not set glyphs."); |
1999 } | 1999 } |
2000 | 2000 |
2001 HRM(glyphsEditor->ApplyEdits(), "Could not apply glyph edits."); | 2001 HRM(glyphsEditor->ApplyEdits(), "Could not apply glyph edits."); |
2002 | 2002 |
2003 SkTScopedComPtr<IXpsOMBrush> xpsFillBrush; | 2003 SkTScopedComPtr<IXpsOMBrush> xpsFillBrush; |
2004 HR(this->createXpsBrush( | 2004 HR(this->createXpsBrush( |
2005 paint, | 2005 paint, |
2006 &xpsFillBrush, | 2006 &xpsFillBrush, |
2007 useCanvasForClip ? NULL : &transform)); | 2007 useCanvasForClip ? nullptr : &transform)); |
2008 | 2008 |
2009 HRM(glyphs->SetFillBrushLocal(xpsFillBrush.get()), | 2009 HRM(glyphs->SetFillBrushLocal(xpsFillBrush.get()), |
2010 "Could not set fill brush."); | 2010 "Could not set fill brush."); |
2011 | 2011 |
2012 HRM(glyphs->SetOrigin(origin), "Could not set glyph origin."); | 2012 HRM(glyphs->SetOrigin(origin), "Could not set glyph origin."); |
2013 | 2013 |
2014 HRM(glyphs->SetFontRenderingEmSize(fontSize), | 2014 HRM(glyphs->SetFontRenderingEmSize(fontSize), |
2015 "Could not set font size."); | 2015 "Could not set font size."); |
2016 | 2016 |
2017 HRM(glyphs->SetStyleSimulations(sims), | 2017 HRM(glyphs->SetStyleSimulations(sims), |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2125 | 2125 |
2126 void SkXPSDevice::drawText(const SkDraw& d, | 2126 void SkXPSDevice::drawText(const SkDraw& d, |
2127 const void* text, size_t byteLen, | 2127 const void* text, size_t byteLen, |
2128 SkScalar x, SkScalar y, | 2128 SkScalar x, SkScalar y, |
2129 const SkPaint& paint) { | 2129 const SkPaint& paint) { |
2130 if (byteLen < 1) return; | 2130 if (byteLen < 1) return; |
2131 | 2131 |
2132 if (text_must_be_pathed(paint, *d.fMatrix)) { | 2132 if (text_must_be_pathed(paint, *d.fMatrix)) { |
2133 SkPath path; | 2133 SkPath path; |
2134 paint.getTextPath(text, byteLen, x, y, &path); | 2134 paint.getTextPath(text, byteLen, x, y, &path); |
2135 this->drawPath(d, path, paint, NULL, true); | 2135 this->drawPath(d, path, paint, nullptr, true); |
2136 //TODO: add automation "text" | 2136 //TODO: add automation "text" |
2137 return; | 2137 return; |
2138 } | 2138 } |
2139 | 2139 |
2140 TypefaceUse* typeface; | 2140 TypefaceUse* typeface; |
2141 HRV(CreateTypefaceUse(paint, &typeface)); | 2141 HRV(CreateTypefaceUse(paint, &typeface)); |
2142 | 2142 |
2143 SkDraw myDraw(d); | 2143 SkDraw myDraw(d); |
2144 myDraw.fMatrix = &SkMatrix::I(); | 2144 myDraw.fMatrix = &SkMatrix::I(); |
2145 SkXPSDrawProcs procs; | 2145 SkXPSDrawProcs procs; |
(...skipping 10 matching lines...) Expand all Loading... |
2156 procs.xpsGlyphs[0].horizontalOffset / procs.centemPerUnit, | 2156 procs.xpsGlyphs[0].horizontalOffset / procs.centemPerUnit, |
2157 procs.xpsGlyphs[0].verticalOffset / -procs.centemPerUnit, | 2157 procs.xpsGlyphs[0].verticalOffset / -procs.centemPerUnit, |
2158 }; | 2158 }; |
2159 procs.xpsGlyphs[0].horizontalOffset = 0.0f; | 2159 procs.xpsGlyphs[0].horizontalOffset = 0.0f; |
2160 procs.xpsGlyphs[0].verticalOffset = 0.0f; | 2160 procs.xpsGlyphs[0].verticalOffset = 0.0f; |
2161 | 2161 |
2162 HRV(AddGlyphs(d, | 2162 HRV(AddGlyphs(d, |
2163 this->fXpsFactory.get(), | 2163 this->fXpsFactory.get(), |
2164 this->fCurrentXpsCanvas.get(), | 2164 this->fCurrentXpsCanvas.get(), |
2165 typeface, | 2165 typeface, |
2166 NULL, | 2166 nullptr, |
2167 procs.xpsGlyphs.begin(), procs.xpsGlyphs.count(), | 2167 procs.xpsGlyphs.begin(), procs.xpsGlyphs.count(), |
2168 &origin, | 2168 &origin, |
2169 SkScalarToFLOAT(paint.getTextSize()), | 2169 SkScalarToFLOAT(paint.getTextSize()), |
2170 XPS_STYLE_SIMULATION_NONE, | 2170 XPS_STYLE_SIMULATION_NONE, |
2171 *d.fMatrix, | 2171 *d.fMatrix, |
2172 paint)); | 2172 paint)); |
2173 } | 2173 } |
2174 | 2174 |
2175 void SkXPSDevice::drawPosText(const SkDraw& d, | 2175 void SkXPSDevice::drawPosText(const SkDraw& d, |
2176 const void* text, size_t byteLen, | 2176 const void* text, size_t byteLen, |
2177 const SkScalar pos[], int scalarsPerPos, | 2177 const SkScalar pos[], int scalarsPerPos, |
2178 const SkPoint& offset, const SkPaint& paint) { | 2178 const SkPoint& offset, const SkPaint& paint) { |
2179 if (byteLen < 1) return; | 2179 if (byteLen < 1) return; |
2180 | 2180 |
2181 if (text_must_be_pathed(paint, *d.fMatrix)) { | 2181 if (text_must_be_pathed(paint, *d.fMatrix)) { |
2182 SkPath path; | 2182 SkPath path; |
2183 //TODO: make this work, Draw currently does not handle as well. | 2183 //TODO: make this work, Draw currently does not handle as well. |
2184 //paint.getTextPath(text, byteLength, x, y, &path); | 2184 //paint.getTextPath(text, byteLength, x, y, &path); |
2185 //this->drawPath(d, path, paint, NULL, true); | 2185 //this->drawPath(d, path, paint, nullptr, true); |
2186 //TODO: add automation "text" | 2186 //TODO: add automation "text" |
2187 return; | 2187 return; |
2188 } | 2188 } |
2189 | 2189 |
2190 TypefaceUse* typeface; | 2190 TypefaceUse* typeface; |
2191 HRV(CreateTypefaceUse(paint, &typeface)); | 2191 HRV(CreateTypefaceUse(paint, &typeface)); |
2192 | 2192 |
2193 SkDraw myDraw(d); | 2193 SkDraw myDraw(d); |
2194 myDraw.fMatrix = &SkMatrix::I(); | 2194 myDraw.fMatrix = &SkMatrix::I(); |
2195 SkXPSDrawProcs procs; | 2195 SkXPSDrawProcs procs; |
(...skipping 10 matching lines...) Expand all Loading... |
2206 procs.xpsGlyphs[0].horizontalOffset / procs.centemPerUnit, | 2206 procs.xpsGlyphs[0].horizontalOffset / procs.centemPerUnit, |
2207 procs.xpsGlyphs[0].verticalOffset / -procs.centemPerUnit, | 2207 procs.xpsGlyphs[0].verticalOffset / -procs.centemPerUnit, |
2208 }; | 2208 }; |
2209 procs.xpsGlyphs[0].horizontalOffset = 0.0f; | 2209 procs.xpsGlyphs[0].horizontalOffset = 0.0f; |
2210 procs.xpsGlyphs[0].verticalOffset = 0.0f; | 2210 procs.xpsGlyphs[0].verticalOffset = 0.0f; |
2211 | 2211 |
2212 HRV(AddGlyphs(d, | 2212 HRV(AddGlyphs(d, |
2213 this->fXpsFactory.get(), | 2213 this->fXpsFactory.get(), |
2214 this->fCurrentXpsCanvas.get(), | 2214 this->fCurrentXpsCanvas.get(), |
2215 typeface, | 2215 typeface, |
2216 NULL, | 2216 nullptr, |
2217 procs.xpsGlyphs.begin(), procs.xpsGlyphs.count(), | 2217 procs.xpsGlyphs.begin(), procs.xpsGlyphs.count(), |
2218 &origin, | 2218 &origin, |
2219 SkScalarToFLOAT(paint.getTextSize()), | 2219 SkScalarToFLOAT(paint.getTextSize()), |
2220 XPS_STYLE_SIMULATION_NONE, | 2220 XPS_STYLE_SIMULATION_NONE, |
2221 *d.fMatrix, | 2221 *d.fMatrix, |
2222 paint)); | 2222 paint)); |
2223 } | 2223 } |
2224 | 2224 |
2225 void SkXPSDevice::drawDevice(const SkDraw& d, SkBaseDevice* dev, | 2225 void SkXPSDevice::drawDevice(const SkDraw& d, SkBaseDevice* dev, |
2226 int x, int y, | 2226 int x, int y, |
(...skipping 19 matching lines...) Expand all Loading... |
2246 HRVM(this->fCurrentXpsCanvas->GetVisuals(¤tVisuals), | 2246 HRVM(this->fCurrentXpsCanvas->GetVisuals(¤tVisuals), |
2247 "Could not get current visuals for layer."); | 2247 "Could not get current visuals for layer."); |
2248 HRVM(currentVisuals->Append(that->fCurrentXpsCanvas.get()), | 2248 HRVM(currentVisuals->Append(that->fCurrentXpsCanvas.get()), |
2249 "Could not add layer to current visuals."); | 2249 "Could not add layer to current visuals."); |
2250 } | 2250 } |
2251 | 2251 |
2252 SkBaseDevice* SkXPSDevice::onCreateDevice(const CreateInfo& info, const SkPaint*
) { | 2252 SkBaseDevice* SkXPSDevice::onCreateDevice(const CreateInfo& info, const SkPaint*
) { |
2253 //Conditional for bug compatibility with PDF device. | 2253 //Conditional for bug compatibility with PDF device. |
2254 #if 0 | 2254 #if 0 |
2255 if (SkBaseDevice::kGeneral_Usage == info.fUsage) { | 2255 if (SkBaseDevice::kGeneral_Usage == info.fUsage) { |
2256 return NULL; | 2256 return nullptr; |
2257 SK_CRASH(); | 2257 SK_CRASH(); |
2258 //To what stream do we write? | 2258 //To what stream do we write? |
2259 //SkXPSDevice* dev = new SkXPSDevice(this); | 2259 //SkXPSDevice* dev = new SkXPSDevice(this); |
2260 //SkSize s = SkSize::Make(width, height); | 2260 //SkSize s = SkSize::Make(width, height); |
2261 //dev->BeginCanvas(s, s, SkMatrix::I()); | 2261 //dev->BeginCanvas(s, s, SkMatrix::I()); |
2262 //return dev; | 2262 //return dev; |
2263 } | 2263 } |
2264 #endif | 2264 #endif |
2265 return new SkXPSDevice(this->fXpsFactory.get()); | 2265 return new SkXPSDevice(this->fXpsFactory.get()); |
2266 } | 2266 } |
2267 | 2267 |
OLD | NEW |