| 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(SkSurfaceProps(0, kUnknown_SkPixelGeometry)) |
| 574 , fWriter(writer) | 574 , fWriter(writer) |
| 575 , fResourceBucket(new ResourceBucket) { | 575 , fResourceBucket(new ResourceBucket) |
| 576 , fSize(size) { |
| 576 SkASSERT(writer); | 577 SkASSERT(writer); |
| 577 | 578 |
| 578 fLegacyBitmap.setInfo(SkImageInfo::MakeUnknown(size.width(), size.height()))
; | |
| 579 | |
| 580 fWriter->writeHeader(); | 579 fWriter->writeHeader(); |
| 581 | 580 |
| 582 // The root <svg> tag gets closed by the destructor. | 581 // The root <svg> tag gets closed by the destructor. |
| 583 fRootElement.reset(new AutoElement("svg", fWriter)); | 582 fRootElement.reset(new AutoElement("svg", fWriter)); |
| 584 | 583 |
| 585 fRootElement->addAttribute("xmlns", "http://www.w3.org/2000/svg"); | 584 fRootElement->addAttribute("xmlns", "http://www.w3.org/2000/svg"); |
| 586 fRootElement->addAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"); | 585 fRootElement->addAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"); |
| 587 fRootElement->addAttribute("width", size.width()); | 586 fRootElement->addAttribute("width", size.width()); |
| 588 fRootElement->addAttribute("height", size.height()); | 587 fRootElement->addAttribute("height", size.height()); |
| 589 } | 588 } |
| 590 | 589 |
| 591 SkSVGDevice::~SkSVGDevice() { | 590 SkSVGDevice::~SkSVGDevice() { |
| 592 } | 591 } |
| 593 | 592 |
| 594 SkImageInfo SkSVGDevice::imageInfo() const { | 593 SkImageInfo SkSVGDevice::imageInfo() const { |
| 595 return fLegacyBitmap.info(); | 594 SkImageInfo info = SkImageInfo::MakeUnknown(fSize.fWidth, fSize.fHeight); |
| 596 } | 595 return info; |
| 597 | |
| 598 const SkBitmap& SkSVGDevice::onAccessBitmap() { | |
| 599 return fLegacyBitmap; | |
| 600 } | 596 } |
| 601 | 597 |
| 602 void SkSVGDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { | 598 void SkSVGDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { |
| 603 AutoElement rect("rect", fWriter, fResourceBucket, draw, paint); | 599 AutoElement rect("rect", fWriter, fResourceBucket, draw, paint); |
| 604 rect.addRectAttributes(SkRect::MakeWH(SkIntToScalar(this->width()), | 600 rect.addRectAttributes(SkRect::MakeWH(SkIntToScalar(this->width()), |
| 605 SkIntToScalar(this->height()))); | 601 SkIntToScalar(this->height()))); |
| 606 } | 602 } |
| 607 | 603 |
| 608 void SkSVGDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_
t count, | 604 void SkSVGDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_
t count, |
| 609 const SkPoint pts[], const SkPaint& paint) { | 605 const SkPoint pts[], const SkPaint& paint) { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 const SkPaint& paint) { | 805 const SkPaint& paint) { |
| 810 // todo | 806 // todo |
| 811 SkDebugf("unsupported operation: drawVertices()\n"); | 807 SkDebugf("unsupported operation: drawVertices()\n"); |
| 812 } | 808 } |
| 813 | 809 |
| 814 void SkSVGDevice::drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, | 810 void SkSVGDevice::drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, |
| 815 const SkPaint&) { | 811 const SkPaint&) { |
| 816 // todo | 812 // todo |
| 817 SkDebugf("unsupported operation: drawDevice()\n"); | 813 SkDebugf("unsupported operation: drawDevice()\n"); |
| 818 } | 814 } |
| OLD | NEW |