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

Side by Side Diff: src/svg/SkSVGDevice.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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 | « src/svg/SkSVGDevice.h ('k') | src/svg/parser/SkSVGClipPath.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 20 matching lines...) Expand all
31 SkColorGetG(color), 31 SkColorGetG(color),
32 SkColorGetB(color)); 32 SkColorGetB(color));
33 } 33 }
34 34
35 static SkScalar svg_opacity(SkColor color) { 35 static SkScalar svg_opacity(SkColor color) {
36 return SkIntToScalar(SkColorGetA(color)) / SK_AlphaOPAQUE; 36 return SkIntToScalar(SkColorGetA(color)) / SK_AlphaOPAQUE;
37 } 37 }
38 38
39 // Keep in sync with SkPaint::Cap 39 // Keep in sync with SkPaint::Cap
40 static const char* cap_map[] = { 40 static const char* cap_map[] = {
41 NULL, // kButt_Cap (default) 41 nullptr, // kButt_Cap (default)
42 "round", // kRound_Cap 42 "round", // kRound_Cap
43 "square" // kSquare_Cap 43 "square" // kSquare_Cap
44 }; 44 };
45 static_assert(SK_ARRAY_COUNT(cap_map) == SkPaint::kCapCount, "missing_cap_map_en try"); 45 static_assert(SK_ARRAY_COUNT(cap_map) == SkPaint::kCapCount, "missing_cap_map_en try");
46 46
47 static const char* svg_cap(SkPaint::Cap cap) { 47 static const char* svg_cap(SkPaint::Cap cap) {
48 SkASSERT(cap < SK_ARRAY_COUNT(cap_map)); 48 SkASSERT(cap < SK_ARRAY_COUNT(cap_map));
49 return cap_map[cap]; 49 return cap_map[cap];
50 } 50 }
51 51
52 // Keep in sync with SkPaint::Join 52 // Keep in sync with SkPaint::Join
53 static const char* join_map[] = { 53 static const char* join_map[] = {
54 NULL, // kMiter_Join (default) 54 nullptr, // kMiter_Join (default)
55 "round", // kRound_Join 55 "round", // kRound_Join
56 "bevel" // kBevel_Join 56 "bevel" // kBevel_Join
57 }; 57 };
58 static_assert(SK_ARRAY_COUNT(join_map) == SkPaint::kJoinCount, "missing_join_map _entry"); 58 static_assert(SK_ARRAY_COUNT(join_map) == SkPaint::kJoinCount, "missing_join_map _entry");
59 59
60 static const char* svg_join(SkPaint::Join join) { 60 static const char* svg_join(SkPaint::Join join) {
61 SkASSERT(join < SK_ARRAY_COUNT(join_map)); 61 SkASSERT(join < SK_ARRAY_COUNT(join_map));
62 return join_map[join]; 62 return join_map[join];
63 } 63 }
64 64
65 // Keep in sync with SkPaint::Align 65 // Keep in sync with SkPaint::Align
66 static const char* text_align_map[] = { 66 static const char* text_align_map[] = {
67 NULL, // kLeft_Align (default) 67 nullptr, // kLeft_Align (default)
68 "middle", // kCenter_Align 68 "middle", // kCenter_Align
69 "end" // kRight_Align 69 "end" // kRight_Align
70 }; 70 };
71 static_assert(SK_ARRAY_COUNT(text_align_map) == SkPaint::kAlignCount, 71 static_assert(SK_ARRAY_COUNT(text_align_map) == SkPaint::kAlignCount,
72 "missing_text_align_map_entry"); 72 "missing_text_align_map_entry");
73 static const char* svg_text_align(SkPaint::Align align) { 73 static const char* svg_text_align(SkPaint::Align align) {
74 SkASSERT(align < SK_ARRAY_COUNT(text_align_map)); 74 SkASSERT(align < SK_ARRAY_COUNT(text_align_map));
75 return text_align_map[align]; 75 return text_align_map[align];
76 } 76 }
77 77
(...skipping 30 matching lines...) Expand all
108 Resources(const SkPaint& paint) 108 Resources(const SkPaint& paint)
109 : fPaintServer(svg_color(paint.getColor())) {} 109 : fPaintServer(svg_color(paint.getColor())) {}
110 110
111 SkString fPaintServer; 111 SkString fPaintServer;
112 SkString fClip; 112 SkString fClip;
113 }; 113 };
114 114
115 class SVGTextBuilder : SkNoncopyable { 115 class SVGTextBuilder : SkNoncopyable {
116 public: 116 public:
117 SVGTextBuilder(const void* text, size_t byteLen, const SkPaint& paint, const SkPoint& offset, 117 SVGTextBuilder(const void* text, size_t byteLen, const SkPaint& paint, const SkPoint& offset,
118 unsigned scalarsPerPos, const SkScalar pos[] = NULL) 118 unsigned scalarsPerPos, const SkScalar pos[] = nullptr)
119 : fOffset(offset) 119 : fOffset(offset)
120 , fScalarsPerPos(scalarsPerPos) 120 , fScalarsPerPos(scalarsPerPos)
121 , fPos(pos) 121 , fPos(pos)
122 , fLastCharWasWhitespace(true) // start off in whitespace mode to strip all leading space 122 , fLastCharWasWhitespace(true) // start off in whitespace mode to strip all leading space
123 { 123 {
124 SkASSERT(scalarsPerPos <= 2); 124 SkASSERT(scalarsPerPos <= 2);
125 SkASSERT(scalarsPerPos == 0 || SkToBool(pos)); 125 SkASSERT(scalarsPerPos == 0 || SkToBool(pos));
126 126
127 int count = paint.countText(text, byteLen); 127 int count = paint.countText(text, byteLen);
128 128
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 uint32_t fGradientCount; 270 uint32_t fGradientCount;
271 uint32_t fClipCount; 271 uint32_t fClipCount;
272 uint32_t fPathCount; 272 uint32_t fPathCount;
273 uint32_t fImageCount; 273 uint32_t fImageCount;
274 }; 274 };
275 275
276 class SkSVGDevice::AutoElement : ::SkNoncopyable { 276 class SkSVGDevice::AutoElement : ::SkNoncopyable {
277 public: 277 public:
278 AutoElement(const char name[], SkXMLWriter* writer) 278 AutoElement(const char name[], SkXMLWriter* writer)
279 : fWriter(writer) 279 : fWriter(writer)
280 , fResourceBucket(NULL) { 280 , fResourceBucket(nullptr) {
281 fWriter->startElement(name); 281 fWriter->startElement(name);
282 } 282 }
283 283
284 AutoElement(const char name[], SkXMLWriter* writer, ResourceBucket* bucket, 284 AutoElement(const char name[], SkXMLWriter* writer, ResourceBucket* bucket,
285 const SkDraw& draw, const SkPaint& paint) 285 const SkDraw& draw, const SkPaint& paint)
286 : fWriter(writer) 286 : fWriter(writer)
287 , fResourceBucket(bucket) { 287 , fResourceBucket(bucket) {
288 288
289 Resources res = this->addResources(draw, paint); 289 Resources res = this->addResources(draw, paint);
290 if (!res.fClip.isEmpty()) { 290 if (!res.fClip.isEmpty()) {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 familyName.appendf((familyName.isEmpty() ? "%s" : ", %s"), familyString. fString.c_str()); 556 familyName.appendf((familyName.isEmpty() ? "%s" : ", %s"), familyString. fString.c_str());
557 } 557 }
558 558
559 if (!familyName.isEmpty()) { 559 if (!familyName.isEmpty()) {
560 this->addAttribute("font-family", familyName); 560 this->addAttribute("font-family", familyName);
561 } 561 }
562 } 562 }
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 NULL; 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 SkASSERT(writer); 576 SkASSERT(writer);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 } 663 }
664 664
665 void SkSVGDevice::drawBitmapCommon(const SkDraw& draw, const SkBitmap& bm, 665 void SkSVGDevice::drawBitmapCommon(const SkDraw& draw, const SkBitmap& bm,
666 const SkPaint& paint) { 666 const SkPaint& paint) {
667 SkAutoTUnref<const SkData> pngData( 667 SkAutoTUnref<const SkData> pngData(
668 SkImageEncoder::EncodeData(bm, SkImageEncoder::kPNG_Type, SkImageEncoder ::kDefaultQuality)); 668 SkImageEncoder::EncodeData(bm, SkImageEncoder::kPNG_Type, SkImageEncoder ::kDefaultQuality));
669 if (!pngData) { 669 if (!pngData) {
670 return; 670 return;
671 } 671 }
672 672
673 size_t b64Size = SkBase64::Encode(pngData->data(), pngData->size(), NULL); 673 size_t b64Size = SkBase64::Encode(pngData->data(), pngData->size(), nullptr) ;
674 SkAutoTMalloc<char> b64Data(b64Size); 674 SkAutoTMalloc<char> b64Data(b64Size);
675 SkBase64::Encode(pngData->data(), pngData->size(), b64Data.get()); 675 SkBase64::Encode(pngData->data(), pngData->size(), b64Data.get());
676 676
677 SkString svgImageData("data:image/png;base64,"); 677 SkString svgImageData("data:image/png;base64,");
678 svgImageData.append(b64Data.get(), b64Size); 678 svgImageData.append(b64Data.get(), b64Size);
679 679
680 SkString imageID = fResourceBucket->addImage(); 680 SkString imageID = fResourceBucket->addImage();
681 { 681 {
682 AutoElement defs("defs", fWriter); 682 AutoElement defs("defs", fWriter);
683 { 683 {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 const SkPaint& paint) { 809 const SkPaint& paint) {
810 // todo 810 // todo
811 SkDebugf("unsupported operation: drawVertices()\n"); 811 SkDebugf("unsupported operation: drawVertices()\n");
812 } 812 }
813 813
814 void SkSVGDevice::drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, 814 void SkSVGDevice::drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
815 const SkPaint&) { 815 const SkPaint&) {
816 // todo 816 // todo
817 SkDebugf("unsupported operation: drawDevice()\n"); 817 SkDebugf("unsupported operation: drawDevice()\n");
818 } 818 }
OLDNEW
« no previous file with comments | « src/svg/SkSVGDevice.h ('k') | src/svg/parser/SkSVGClipPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698