OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkSVGDevice.h" | 8 #include "SkSVGDevice.h" |
9 | 9 |
10 #include "SkBase64.h" | 10 #include "SkBase64.h" |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 | 563 |
564 SkBaseDevice* SkSVGDevice::Create(const SkISize& size, SkXMLWriter* writer) { | 564 SkBaseDevice* SkSVGDevice::Create(const SkISize& size, SkXMLWriter* writer) { |
565 if (!writer) { | 565 if (!writer) { |
566 return nullptr; | 566 return nullptr; |
567 } | 567 } |
568 | 568 |
569 return new SkSVGDevice(size, writer); | 569 return new SkSVGDevice(size, writer); |
570 } | 570 } |
571 | 571 |
572 SkSVGDevice::SkSVGDevice(const SkISize& size, SkXMLWriter* writer) | 572 SkSVGDevice::SkSVGDevice(const SkISize& size, SkXMLWriter* writer) |
573 : INHERITED(SkSurfaceProps(0, kUnknown_SkPixelGeometry)) | 573 : INHERITED(SkImageInfo::MakeUnknown(size.fWidth, size.fHeight), |
| 574 SkSurfaceProps(0, kUnknown_SkPixelGeometry)) |
574 , fWriter(writer) | 575 , fWriter(writer) |
575 , fResourceBucket(new ResourceBucket) | 576 , fResourceBucket(new ResourceBucket) |
576 , fSize(size) { | 577 { |
577 SkASSERT(writer); | 578 SkASSERT(writer); |
578 | 579 |
579 fWriter->writeHeader(); | 580 fWriter->writeHeader(); |
580 | 581 |
581 // The root <svg> tag gets closed by the destructor. | 582 // The root <svg> tag gets closed by the destructor. |
582 fRootElement.reset(new AutoElement("svg", fWriter)); | 583 fRootElement.reset(new AutoElement("svg", fWriter)); |
583 | 584 |
584 fRootElement->addAttribute("xmlns", "http://www.w3.org/2000/svg"); | 585 fRootElement->addAttribute("xmlns", "http://www.w3.org/2000/svg"); |
585 fRootElement->addAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"); | 586 fRootElement->addAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"); |
586 fRootElement->addAttribute("width", size.width()); | 587 fRootElement->addAttribute("width", size.width()); |
587 fRootElement->addAttribute("height", size.height()); | 588 fRootElement->addAttribute("height", size.height()); |
588 } | 589 } |
589 | 590 |
590 SkSVGDevice::~SkSVGDevice() { | 591 SkSVGDevice::~SkSVGDevice() { |
591 } | 592 } |
592 | 593 |
593 SkImageInfo SkSVGDevice::imageInfo() const { | |
594 SkImageInfo info = SkImageInfo::MakeUnknown(fSize.fWidth, fSize.fHeight); | |
595 return info; | |
596 } | |
597 | |
598 void SkSVGDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { | 594 void SkSVGDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
599 AutoElement rect("rect", fWriter, fResourceBucket, draw, paint); | 595 AutoElement rect("rect", fWriter, fResourceBucket, draw, paint); |
600 rect.addRectAttributes(SkRect::MakeWH(SkIntToScalar(this->width()), | 596 rect.addRectAttributes(SkRect::MakeWH(SkIntToScalar(this->width()), |
601 SkIntToScalar(this->height()))); | 597 SkIntToScalar(this->height()))); |
602 } | 598 } |
603 | 599 |
604 void SkSVGDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_
t count, | 600 void SkSVGDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_
t count, |
605 const SkPoint pts[], const SkPaint& paint) { | 601 const SkPoint pts[], const SkPaint& paint) { |
606 SkPath path; | 602 SkPath path; |
607 | 603 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 const SkPaint& paint) { | 801 const SkPaint& paint) { |
806 // todo | 802 // todo |
807 SkDebugf("unsupported operation: drawVertices()\n"); | 803 SkDebugf("unsupported operation: drawVertices()\n"); |
808 } | 804 } |
809 | 805 |
810 void SkSVGDevice::drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, | 806 void SkSVGDevice::drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, |
811 const SkPaint&) { | 807 const SkPaint&) { |
812 // todo | 808 // todo |
813 SkDebugf("unsupported operation: drawDevice()\n"); | 809 SkDebugf("unsupported operation: drawDevice()\n"); |
814 } | 810 } |
OLD | NEW |