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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ContiguousContainer.h

Issue 1497683002: Make platform/graphics to use USING_FAST_MALLOC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ContiguousContainer_h 5 #ifndef ContiguousContainer_h
6 #define ContiguousContainer_h 6 #define ContiguousContainer_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "wtf/Alignment.h" 9 #include "wtf/Alignment.h"
10 #include "wtf/Allocator.h"
10 #include "wtf/Compiler.h" 11 #include "wtf/Compiler.h"
11 #include "wtf/Noncopyable.h" 12 #include "wtf/Noncopyable.h"
12 #include "wtf/OwnPtr.h" 13 #include "wtf/OwnPtr.h"
13 #include "wtf/TypeTraits.h" 14 #include "wtf/TypeTraits.h"
14 #include "wtf/Utility.h" 15 #include "wtf/Utility.h"
15 #include "wtf/Vector.h" 16 #include "wtf/Vector.h"
16 #include <cstddef> 17 #include <cstddef>
17 #include <iterator> 18 #include <iterator>
18 19
19 namespace blink { 20 namespace blink {
(...skipping 10 matching lines...) Expand all
30 // 31 //
31 // Since it stores pointers to all of the objects it allocates in a vector, it 32 // Since it stores pointers to all of the objects it allocates in a vector, it
32 // supports efficient iteration and indexing. However, for mutation the 33 // supports efficient iteration and indexing. However, for mutation the
33 // supported operations are limited to appending to, and removing from, the end 34 // supported operations are limited to appending to, and removing from, the end
34 // of the list. 35 // of the list.
35 // 36 //
36 // Clients should instantiate ContiguousContainer; ContiguousContainerBase is an 37 // Clients should instantiate ContiguousContainer; ContiguousContainerBase is an
37 // artifact of the implementation. 38 // artifact of the implementation.
38 39
39 class PLATFORM_EXPORT ContiguousContainerBase { 40 class PLATFORM_EXPORT ContiguousContainerBase {
41 DISALLOW_NEW();
40 WTF_MAKE_NONCOPYABLE(ContiguousContainerBase); 42 WTF_MAKE_NONCOPYABLE(ContiguousContainerBase);
41 protected: 43 protected:
42 explicit ContiguousContainerBase(size_t maxObjectSize, const char* typeName) ; 44 explicit ContiguousContainerBase(size_t maxObjectSize, const char* typeName) ;
43 ContiguousContainerBase(size_t maxObjectSize, size_t initialSizeBytes, const char* typeName); 45 ContiguousContainerBase(size_t maxObjectSize, size_t initialSizeBytes, const char* typeName);
44 ~ContiguousContainerBase(); 46 ~ContiguousContainerBase();
45 47
46 size_t size() const { return m_elements.size(); } 48 size_t size() const { return m_elements.size(); }
47 bool isEmpty() const { return !size(); } 49 bool isEmpty() const { return !size(); }
48 size_t capacityInBytes() const; 50 size_t capacityInBytes() const;
49 size_t usedCapacityInBytes() const; 51 size_t usedCapacityInBytes() const;
(...skipping 26 matching lines...) Expand all
76 // alignments. For small structs without pointers, it may be possible to reduce 78 // alignments. For small structs without pointers, it may be possible to reduce
77 // alignment for tighter packing. 79 // alignment for tighter packing.
78 80
79 template <class BaseElementType, unsigned alignment = sizeof(void*)> 81 template <class BaseElementType, unsigned alignment = sizeof(void*)>
80 class ContiguousContainer : public ContiguousContainerBase { 82 class ContiguousContainer : public ContiguousContainerBase {
81 private: 83 private:
82 // Declares itself as a forward iterator, but also supports a few more 84 // Declares itself as a forward iterator, but also supports a few more
83 // things. The whole random access iterator interface is a bit much. 85 // things. The whole random access iterator interface is a bit much.
84 template <typename BaseIterator, typename ValueType> 86 template <typename BaseIterator, typename ValueType>
85 class IteratorWrapper : public std::iterator<std::forward_iterator_tag, Valu eType> { 87 class IteratorWrapper : public std::iterator<std::forward_iterator_tag, Valu eType> {
88 DISALLOW_NEW();
86 public: 89 public:
87 IteratorWrapper() {} 90 IteratorWrapper() {}
88 bool operator==(const IteratorWrapper& other) const { return m_it == oth er.m_it; } 91 bool operator==(const IteratorWrapper& other) const { return m_it == oth er.m_it; }
89 bool operator!=(const IteratorWrapper& other) const { return m_it != oth er.m_it; } 92 bool operator!=(const IteratorWrapper& other) const { return m_it != oth er.m_it; }
90 ValueType& operator*() const { return *static_cast<ValueType*>(*m_it); } 93 ValueType& operator*() const { return *static_cast<ValueType*>(*m_it); }
91 ValueType* operator->() const { return &operator*(); } 94 ValueType* operator->() const { return &operator*(); }
92 IteratorWrapper operator+(std::ptrdiff_t n) const { return IteratorWrapp er(m_it + n); } 95 IteratorWrapper operator+(std::ptrdiff_t n) const { return IteratorWrapp er(m_it + n); }
93 IteratorWrapper operator++(int) { IteratorWrapper tmp = *this; ++m_it; r eturn tmp; } 96 IteratorWrapper operator++(int) { IteratorWrapper tmp = *this; ++m_it; r eturn tmp; }
94 std::ptrdiff_t operator-(const IteratorWrapper& other) const { return m_ it - other.m_it; } 97 std::ptrdiff_t operator-(const IteratorWrapper& other) const { return m_ it - other.m_it; }
95 IteratorWrapper& operator++() { ++m_it; return *this; } 98 IteratorWrapper& operator++() { ++m_it; return *this; }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 ASSERT(alignedSize % alignment == 0); 190 ASSERT(alignedSize % alignment == 0);
188 ASSERT(alignedSize >= size); 191 ASSERT(alignedSize >= size);
189 ASSERT(alignedSize < size + alignment); 192 ASSERT(alignedSize < size + alignment);
190 return alignedSize; 193 return alignedSize;
191 } 194 }
192 }; 195 };
193 196
194 } // namespace blink 197 } // namespace blink
195 198
196 #endif // ContiguousContainer_h 199 #endif // ContiguousContainer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698