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

Side by Side Diff: dm/DMSrcSink.cpp

Issue 902583006: Add SkSVGCanvas (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: fix win warning Created 5 years, 10 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 | « no previous file | experimental/svg/SkSVGDevice.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "DMSrcSink.h" 1 #include "DMSrcSink.h"
2 #include "SamplePipeControllers.h" 2 #include "SamplePipeControllers.h"
3 #include "SkCommonFlags.h" 3 #include "SkCommonFlags.h"
4 #include "SkDocument.h" 4 #include "SkDocument.h"
5 #include "SkMultiPictureDraw.h" 5 #include "SkMultiPictureDraw.h"
6 #include "SkOSFile.h" 6 #include "SkOSFile.h"
7 #include "SkPictureRecorder.h" 7 #include "SkPictureRecorder.h"
8 #include "SkRandom.h" 8 #include "SkRandom.h"
9 #include "SkSVGDevice.h" 9 #include "SkSVGCanvas.h"
10 #include "SkStream.h" 10 #include "SkStream.h"
11 #include "SkXMLWriter.h"
11 12
12 namespace DM { 13 namespace DM {
13 14
14 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {} 15 GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {}
15 16
16 Error GMSrc::draw(SkCanvas* canvas) const { 17 Error GMSrc::draw(SkCanvas* canvas) const {
17 SkAutoTDelete<skiagm::GM> gm(fFactory(NULL)); 18 SkAutoTDelete<skiagm::GM> gm(fFactory(NULL));
18 canvas->concat(gm->getInitialTransform()); 19 canvas->concat(gm->getInitialTransform());
19 gm->draw(canvas); 20 gm->draw(canvas);
20 return ""; 21 return "";
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 SkAutoTUnref<SkPicture> pic(recorder.endRecording()); 231 SkAutoTUnref<SkPicture> pic(recorder.endRecording());
231 pic->serialize(dst); 232 pic->serialize(dst);
232 return ""; 233 return "";
233 } 234 }
234 235
235 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 236 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
236 237
237 SVGSink::SVGSink() {} 238 SVGSink::SVGSink() {}
238 239
239 Error SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const { 240 Error SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const {
240 SkAutoTUnref<SkBaseDevice> device(SkSVGDevice::Create(src.size(), dst)); 241 SkAutoTDelete<SkXMLWriter> xmlWriter(SkNEW_ARGS(SkXMLStreamWriter, (dst)));
241 SkCanvas canvas(device); 242 SkAutoTUnref<SkCanvas> canvas(SkSVGCanvas::Create(
242 return src.draw(&canvas); 243 SkRect::MakeWH(SkIntToScalar(src.size().width()), SkIntToScalar(src.size ().height())),
244 xmlWriter));
245 return src.draw(canvas);
243 } 246 }
244 247
245 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 248 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
246 249
247 RasterSink::RasterSink(SkColorType colorType) : fColorType(colorType) {} 250 RasterSink::RasterSink(SkColorType colorType) : fColorType(colorType) {}
248 251
249 Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString*) con st { 252 Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString*) con st {
250 const SkISize size = src.size(); 253 const SkISize size = src.size();
251 // If there's an appropriate alpha type for this color type, use it, otherwi se use premul. 254 // If there's an appropriate alpha type for this color type, use it, otherwi se use premul.
252 SkAlphaType alphaType = kPremul_SkAlphaType; 255 SkAlphaType alphaType = kPremul_SkAlphaType;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 surfaces.unrefAll(); 403 surfaces.unrefAll();
401 return ""; 404 return "";
402 } 405 }
403 SkISize size() const SK_OVERRIDE { return fSize; } 406 SkISize size() const SK_OVERRIDE { return fSize; }
404 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this. 407 Name name() const SK_OVERRIDE { sk_throw(); return ""; } // No one shou ld be calling this.
405 } proxy(fW, fH, pic, src.size()); 408 } proxy(fW, fH, pic, src.size());
406 return fSink->draw(proxy, bitmap, stream, log); 409 return fSink->draw(proxy, bitmap, stream, log);
407 } 410 }
408 411
409 } // namespace DM 412 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | experimental/svg/SkSVGDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698