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

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

Issue 1021033002: Some usability ideas around SkTHash. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: minor tweaks Created 5 years, 9 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/gpu/gl/GrGLCaps.h ('k') | tests/ChecksumTest.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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 tstr.printf("matrix(%g %g %g %g %g %g)", 96 tstr.printf("matrix(%g %g %g %g %g %g)",
97 t.getScaleX(), t.getSkewY(), 97 t.getScaleX(), t.getSkewY(),
98 t.getSkewX(), t.getScaleY(), 98 t.getSkewX(), t.getScaleY(),
99 t.getTranslateX(), t.getTranslateY()); 99 t.getTranslateX(), t.getTranslateY());
100 break; 100 break;
101 } 101 }
102 102
103 return tstr; 103 return tstr;
104 } 104 }
105 105
106 uint32_t hash_family_string(const SkString& family) {
107 // This is a lame hash function, but we don't really expect to see more than 1-2
108 // family names under normal circumstances.
109 return SkChecksum::Mix(SkToU32(family.size()));
110 }
111
112 struct Resources { 106 struct Resources {
113 Resources(const SkPaint& paint) 107 Resources(const SkPaint& paint)
114 : fPaintServer(svg_color(paint.getColor())) {} 108 : fPaintServer(svg_color(paint.getColor())) {}
115 109
116 SkString fPaintServer; 110 SkString fPaintServer;
117 SkString fClip; 111 SkString fClip;
118 }; 112 };
119 113
120 class SVGTextBuilder : SkNoncopyable { 114 class SVGTextBuilder : SkNoncopyable {
121 public: 115 public:
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } 525 }
532 526
533 void SkSVGDevice::AutoElement::addTextAttributes(const SkPaint& paint) { 527 void SkSVGDevice::AutoElement::addTextAttributes(const SkPaint& paint) {
534 this->addAttribute("font-size", paint.getTextSize()); 528 this->addAttribute("font-size", paint.getTextSize());
535 529
536 if (const char* textAlign = svg_text_align(paint.getTextAlign())) { 530 if (const char* textAlign = svg_text_align(paint.getTextAlign())) {
537 this->addAttribute("text-anchor", textAlign); 531 this->addAttribute("text-anchor", textAlign);
538 } 532 }
539 533
540 SkString familyName; 534 SkString familyName;
541 SkTHashSet<SkString, hash_family_string> familySet; 535 SkTHashSet<SkString> familySet;
542 SkAutoTUnref<const SkTypeface> tface(paint.getTypeface() ? 536 SkAutoTUnref<const SkTypeface> tface(paint.getTypeface() ?
543 SkRef(paint.getTypeface()) : SkTypeface::RefDefault()); 537 SkRef(paint.getTypeface()) : SkTypeface::RefDefault());
544 538
545 SkASSERT(tface); 539 SkASSERT(tface);
546 SkTypeface::Style style = tface->style(); 540 SkTypeface::Style style = tface->style();
547 if (style & SkTypeface::kItalic) { 541 if (style & SkTypeface::kItalic) {
548 this->addAttribute("font-style", "italic"); 542 this->addAttribute("font-style", "italic");
549 } 543 }
550 if (style & SkTypeface::kBold) { 544 if (style & SkTypeface::kBold) {
551 this->addAttribute("font-weight", "bold"); 545 this->addAttribute("font-weight", "bold");
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 const SkPaint& paint) { 780 const SkPaint& paint) {
787 // todo 781 // todo
788 SkDebugf("unsupported operation: drawVertices()\n"); 782 SkDebugf("unsupported operation: drawVertices()\n");
789 } 783 }
790 784
791 void SkSVGDevice::drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, 785 void SkSVGDevice::drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
792 const SkPaint&) { 786 const SkPaint&) {
793 // todo 787 // todo
794 SkDebugf("unsupported operation: drawDevice()\n"); 788 SkDebugf("unsupported operation: drawDevice()\n");
795 } 789 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | tests/ChecksumTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698