| OLD | NEW |
| 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 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 public: | 30 public: |
| 31 CoalescingBuffer(SVGPathByteStream& byteStream) | 31 CoalescingBuffer(SVGPathByteStream& byteStream) |
| 32 : m_currentOffset(0), m_byteStream(byteStream) {} | 32 : m_currentOffset(0), m_byteStream(byteStream) {} |
| 33 ~CoalescingBuffer() { m_byteStream.append(m_bytes, m_currentOffset); } | 33 ~CoalescingBuffer() { m_byteStream.append(m_bytes, m_currentOffset); } |
| 34 | 34 |
| 35 template <typename DataType> | 35 template <typename DataType> |
| 36 void writeType(DataType value) { | 36 void writeType(DataType value) { |
| 37 ByteType<DataType> data; | 37 ByteType<DataType> data; |
| 38 data.value = value; | 38 data.value = value; |
| 39 size_t typeSize = sizeof(ByteType<DataType>); | 39 size_t typeSize = sizeof(ByteType<DataType>); |
| 40 ASSERT(m_currentOffset + typeSize <= sizeof(m_bytes)); | 40 DCHECK_LE(m_currentOffset + typeSize, sizeof(m_bytes)); |
| 41 memcpy(m_bytes + m_currentOffset, data.bytes, typeSize); | 41 memcpy(m_bytes + m_currentOffset, data.bytes, typeSize); |
| 42 m_currentOffset += typeSize; | 42 m_currentOffset += typeSize; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void writeFlag(bool value) { writeType<bool>(value); } | 45 void writeFlag(bool value) { writeType<bool>(value); } |
| 46 void writeFloat(float value) { writeType<float>(value); } | 46 void writeFloat(float value) { writeType<float>(value); } |
| 47 void writeFloatPoint(const FloatPoint& point) { | 47 void writeFloatPoint(const FloatPoint& point) { |
| 48 writeType<float>(point.x()); | 48 writeType<float>(point.x()); |
| 49 writeType<float>(point.y()); | 49 writeType<float>(point.y()); |
| 50 } | 50 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 buffer.writeFlag(segment.arcLarge); | 110 buffer.writeFlag(segment.arcLarge); |
| 111 buffer.writeFlag(segment.arcSweep); | 111 buffer.writeFlag(segment.arcSweep); |
| 112 buffer.writeFloatPoint(segment.targetPoint); | 112 buffer.writeFloatPoint(segment.targetPoint); |
| 113 break; | 113 break; |
| 114 default: | 114 default: |
| 115 ASSERT_NOT_REACHED(); | 115 ASSERT_NOT_REACHED(); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace blink | 119 } // namespace blink |
| OLD | NEW |