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

Unified Diff: Source/core/dom/TypedFlexibleArrayBufferView.h

Issue 1269443002: Introduce FlexibleArrayBufferView and TypedFlexibleArrayBufferView (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed typo Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/FlexibleArrayBufferView.h ('k') | Source/modules/webgl/WebGLRenderingContextBase.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/TypedFlexibleArrayBufferView.h
diff --git a/Source/core/dom/TypedFlexibleArrayBufferView.h b/Source/core/dom/TypedFlexibleArrayBufferView.h
new file mode 100644
index 0000000000000000000000000000000000000000..814b4f2a54ed13abbe7481ec36c4981762af4f7d
--- /dev/null
+++ b/Source/core/dom/TypedFlexibleArrayBufferView.h
@@ -0,0 +1,37 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TypedFlexibleArrayBufferView_h
+#define TypedFlexibleArrayBufferView_h
+
+#include "core/CoreExport.h"
+#include "core/dom/FlexibleArrayBufferView.h"
+#include "wtf/Noncopyable.h"
+
+namespace blink {
+
+template<typename WTFTypedArray>
+class CORE_TEMPLATE_CLASS_EXPORT TypedFlexibleArrayBufferView final : public FlexibleArrayBufferView {
+ STACK_ALLOCATED();
+ WTF_MAKE_NONCOPYABLE(TypedFlexibleArrayBufferView);
+public:
+ using ValueType = typename WTFTypedArray::ValueType;
+
+ TypedFlexibleArrayBufferView() : FlexibleArrayBufferView() {}
+
+ ValueType* dataMaybeOnStack() const { return static_cast<ValueType*>(baseAddressMaybeOnStack()); }
+
+ unsigned length() const
+ {
+ ASSERT(byteLength() % sizeof(ValueType) == 0);
+ return byteLength() / sizeof(ValueType);
+ }
+};
+
+using FlexibleInt32ArrayView = TypedFlexibleArrayBufferView<WTF::Int32Array>;
+using FlexibleFloat32ArrayView = TypedFlexibleArrayBufferView<WTF::Float32Array>;
+
+} // namespace blink
+
+#endif // TypedFlexibleArrayBufferView_h
« no previous file with comments | « Source/core/dom/FlexibleArrayBufferView.h ('k') | Source/modules/webgl/WebGLRenderingContextBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698