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

Side by Side Diff: Source/core/svg/SVGPathByteStream.h

Issue 130563014: Get rid of the *Byte types used for (de)serializing to SVGPathByteStream (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/svg/SVGPathByteStreamBuilder.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 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #ifndef SVGPathByteStream_h 20 #ifndef SVGPathByteStream_h
21 #define SVGPathByteStream_h 21 #define SVGPathByteStream_h
22 22
23 #include "wtf/Noncopyable.h" 23 #include "wtf/Noncopyable.h"
24 #include "wtf/PassOwnPtr.h" 24 #include "wtf/PassOwnPtr.h"
25 #include "wtf/Vector.h" 25 #include "wtf/Vector.h"
26 26
27 namespace WebCore { 27 namespace WebCore {
28 28
29 // Type definitions for the byte stream data 29 template<typename DataType>
30 typedef union { 30 union ByteType {
31 bool value; 31 DataType value;
32 unsigned char bytes[sizeof(bool)]; 32 unsigned char bytes[sizeof(DataType)];
33 } BoolByte; 33 };
34
35 typedef union {
36 float value;
37 unsigned char bytes[sizeof(float)];
38 } FloatByte;
39
40 typedef union {
41 unsigned short value;
42 unsigned char bytes[sizeof(unsigned short)];
43 } UnsignedShortByte;
44 34
45 class SVGPathByteStream { 35 class SVGPathByteStream {
46 WTF_MAKE_FAST_ALLOCATED; 36 WTF_MAKE_FAST_ALLOCATED;
47 public: 37 public:
48 static PassOwnPtr<SVGPathByteStream> create() 38 static PassOwnPtr<SVGPathByteStream> create()
49 { 39 {
50 return adoptPtr(new SVGPathByteStream); 40 return adoptPtr(new SVGPathByteStream);
51 } 41 }
52 42
53 PassOwnPtr<SVGPathByteStream> copy() 43 PassOwnPtr<SVGPathByteStream> copy()
54 { 44 {
55 return adoptPtr(new SVGPathByteStream(m_data)); 45 return adoptPtr(new SVGPathByteStream(m_data));
56 } 46 }
57 47
58 typedef Vector<unsigned char> Data; 48 typedef Vector<unsigned char> Data;
59 typedef Data::const_iterator DataIterator; 49 typedef Data::const_iterator DataIterator;
60 50
61 DataIterator begin() { return m_data.begin(); } 51 DataIterator begin() { return m_data.begin(); }
62 DataIterator end() { return m_data.end(); } 52 DataIterator end() { return m_data.end(); }
63 void append(unsigned char byte) { m_data.append(byte); } 53 void append(unsigned char byte) { m_data.append(byte); }
64 void append(SVGPathByteStream* other) 54 void append(SVGPathByteStream* other) { m_data.append(other->m_data); }
65 {
66 for (DataIterator it = other->begin(); it != other->end(); ++it)
67 append(*it);
68 }
69 void clear() { m_data.clear(); } 55 void clear() { m_data.clear(); }
70 void reserveInitialCapacity(size_t size) { m_data.reserveInitialCapacity(siz e); } 56 void reserveInitialCapacity(size_t size) { m_data.reserveInitialCapacity(siz e); }
71 void shrinkToFit() { m_data.shrinkToFit(); } 57 void shrinkToFit() { m_data.shrinkToFit(); }
72 bool isEmpty() const { return !m_data.size(); } 58 bool isEmpty() const { return m_data.isEmpty(); }
73 unsigned size() const { return m_data.size(); } 59 unsigned size() const { return m_data.size(); }
74 60
75 // Only defined to let SVGAnimatedPathAnimator use the standard list code pa ths - this method is never called. 61 // Only defined to let SVGAnimatedPathAnimator use the standard list code pa ths - this method is never called.
76 void resize(unsigned) { } 62 void resize(unsigned) { }
77 63
78 private: 64 private:
79 SVGPathByteStream() { } 65 SVGPathByteStream() { }
80 SVGPathByteStream(Data& data) 66 SVGPathByteStream(Data& data)
81 : m_data(data) 67 : m_data(data)
82 { 68 {
83 } 69 }
84 70
85 Data m_data; 71 Data m_data;
86 }; 72 };
87 73
88 } // namespace WebCore 74 } // namespace WebCore
89 75
90 #endif // SVGPathByteStream_h 76 #endif // SVGPathByteStream_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/svg/SVGPathByteStreamBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698