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

Side by Side Diff: Source/core/html/canvas/DataView.cpp

Issue 928103002: Remove some unused functions in core (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: git cl try 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 | « Source/core/html/canvas/DataView.h ('k') | Source/core/layout/style/AppliedTextDecoration.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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 25 matching lines...) Expand all
36 template<typename T> 36 template<typename T>
37 union Value { 37 union Value {
38 T data; 38 T data;
39 char bytes[sizeof(T)]; 39 char bytes[sizeof(T)];
40 }; 40 };
41 41
42 } 42 }
43 43
44 namespace blink { 44 namespace blink {
45 45
46 PassRefPtr<DataView> DataView::create(unsigned length)
47 {
48 RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(length, sizeof(uint8_t));
49 return create(buffer.release(), 0, length);
50 }
51
52 PassRefPtr<DataView> DataView::create(PassRefPtr<ArrayBuffer> buffer, unsigned b yteOffset, unsigned byteLength) 46 PassRefPtr<DataView> DataView::create(PassRefPtr<ArrayBuffer> buffer, unsigned b yteOffset, unsigned byteLength)
53 { 47 {
54 RELEASE_ASSERT(byteOffset <= buffer->byteLength()); 48 RELEASE_ASSERT(byteOffset <= buffer->byteLength());
55 CheckedInt<uint32_t> checkedOffset(byteOffset); 49 CheckedInt<uint32_t> checkedOffset(byteOffset);
56 CheckedInt<uint32_t> checkedLength(byteLength); 50 CheckedInt<uint32_t> checkedLength(byteLength);
57 CheckedInt<uint32_t> checkedMax = checkedOffset + checkedLength; 51 CheckedInt<uint32_t> checkedMax = checkedOffset + checkedLength;
58 RELEASE_ASSERT(checkedMax.isValid()); 52 RELEASE_ASSERT(checkedMax.isValid());
59 RELEASE_ASSERT(checkedMax.value() <= buffer->byteLength()); 53 RELEASE_ASSERT(checkedMax.value() <= buffer->byteLength());
60 return adoptRef(new DataView(buffer, byteOffset, byteLength)); 54 return adoptRef(new DataView(buffer, byteOffset, byteLength));
61 } 55 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return; 142 return;
149 } 143 }
150 144
151 // We do not want to store the data directly since it would cause a bus erro r on architectures that don't support unaligned stores. 145 // We do not want to store the data directly since it would cause a bus erro r on architectures that don't support unaligned stores.
152 Value<T> tempValue; 146 Value<T> tempValue;
153 tempValue.data = value; 147 tempValue.data = value;
154 flipBytesIfNeeded(tempValue.bytes, sizeof(T), littleEndian); 148 flipBytesIfNeeded(tempValue.bytes, sizeof(T), littleEndian);
155 memcpy(static_cast<char*>(m_baseAddress) + byteOffset, tempValue.bytes, size of(T)); 149 memcpy(static_cast<char*>(m_baseAddress) + byteOffset, tempValue.bytes, size of(T));
156 } 150 }
157 151
158 int8_t DataView::getInt8(unsigned byteOffset, ExceptionState& exceptionState)
159 {
160 return getData<int8_t>(byteOffset, false, exceptionState);
161 }
162
163 uint8_t DataView::getUint8(unsigned byteOffset, ExceptionState& exceptionState)
164 {
165 return getData<uint8_t>(byteOffset, false, exceptionState);
166 }
167
168 int16_t DataView::getInt16(unsigned byteOffset, bool littleEndian, ExceptionStat e& exceptionState) 152 int16_t DataView::getInt16(unsigned byteOffset, bool littleEndian, ExceptionStat e& exceptionState)
169 { 153 {
170 return getData<int16_t>(byteOffset, littleEndian, exceptionState); 154 return getData<int16_t>(byteOffset, littleEndian, exceptionState);
171 } 155 }
172 156
173 uint16_t DataView::getUint16(unsigned byteOffset, bool littleEndian, ExceptionSt ate& exceptionState) 157 uint16_t DataView::getUint16(unsigned byteOffset, bool littleEndian, ExceptionSt ate& exceptionState)
174 { 158 {
175 return getData<uint16_t>(byteOffset, littleEndian, exceptionState); 159 return getData<uint16_t>(byteOffset, littleEndian, exceptionState);
176 } 160 }
177 161
(...skipping 10 matching lines...) Expand all
188 float DataView::getFloat32(unsigned byteOffset, bool littleEndian, ExceptionStat e& exceptionState) 172 float DataView::getFloat32(unsigned byteOffset, bool littleEndian, ExceptionStat e& exceptionState)
189 { 173 {
190 return getData<float>(byteOffset, littleEndian, exceptionState); 174 return getData<float>(byteOffset, littleEndian, exceptionState);
191 } 175 }
192 176
193 double DataView::getFloat64(unsigned byteOffset, bool littleEndian, ExceptionSta te& exceptionState) 177 double DataView::getFloat64(unsigned byteOffset, bool littleEndian, ExceptionSta te& exceptionState)
194 { 178 {
195 return getData<double>(byteOffset, littleEndian, exceptionState); 179 return getData<double>(byteOffset, littleEndian, exceptionState);
196 } 180 }
197 181
198 void DataView::setInt8(unsigned byteOffset, int8_t value, ExceptionState& except ionState)
199 {
200 setData<int8_t>(byteOffset, value, false, exceptionState);
201 }
202
203 void DataView::setUint8(unsigned byteOffset, uint8_t value, ExceptionState& exce ptionState)
204 {
205 setData<uint8_t>(byteOffset, value, false, exceptionState);
206 }
207
208 void DataView::setInt16(unsigned byteOffset, short value, bool littleEndian, Exc eptionState& exceptionState) 182 void DataView::setInt16(unsigned byteOffset, short value, bool littleEndian, Exc eptionState& exceptionState)
209 { 183 {
210 setData<int16_t>(byteOffset, value, littleEndian, exceptionState); 184 setData<int16_t>(byteOffset, value, littleEndian, exceptionState);
211 } 185 }
212 186
213 void DataView::setUint16(unsigned byteOffset, uint16_t value, bool littleEndian, ExceptionState& exceptionState) 187 void DataView::setUint16(unsigned byteOffset, uint16_t value, bool littleEndian, ExceptionState& exceptionState)
214 { 188 {
215 setData<uint16_t>(byteOffset, value, littleEndian, exceptionState); 189 setData<uint16_t>(byteOffset, value, littleEndian, exceptionState);
216 } 190 }
217 191
(...skipping 17 matching lines...) Expand all
235 setData<double>(byteOffset, value, littleEndian, exceptionState); 209 setData<double>(byteOffset, value, littleEndian, exceptionState);
236 } 210 }
237 211
238 void DataView::neuter() 212 void DataView::neuter()
239 { 213 {
240 ArrayBufferView::neuter(); 214 ArrayBufferView::neuter();
241 m_byteLength = 0; 215 m_byteLength = 0;
242 } 216 }
243 217
244 } // namespace blink 218 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/canvas/DataView.h ('k') | Source/core/layout/style/AppliedTextDecoration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698