summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjbroman <jbroman@chromium.org>2015-09-09 17:35:57 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-10 00:36:37 +0000
commit061ab9b8b18517ea32f6d75bda4dc8dbe388378d (patch)
tree89f3eac399d4017b3a4e1faf82d032a7761d50e4
parent96994584c0279e7732b2f39a1ae6c607ae9ed559 (diff)
downloadchromium_src-061ab9b8b18517ea32f6d75bda4dc8dbe388378d.zip
chromium_src-061ab9b8b18517ea32f6d75bda4dc8dbe388378d.tar.gz
chromium_src-061ab9b8b18517ea32f6d75bda4dc8dbe388378d.tar.bz2
cc: Delete SidecarListContainer.
Using its features to support Blink display item lists is not longer part of the plan of record. BUG=529859 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1319973013 Cr-Commit-Position: refs/heads/master@{#348051}
-rw-r--r--cc/BUILD.gn1
-rw-r--r--cc/base/BUILD.gn1
-rw-r--r--cc/base/sidecar_list_container.h97
-rw-r--r--cc/base/sidecar_list_container_unittest.cc198
-rw-r--r--cc/cc.gyp1
-rw-r--r--cc/cc_tests.gyp1
-rw-r--r--cc/playback/display_item_list.cc9
-rw-r--r--cc/playback/display_item_list.h10
-rw-r--r--cc/playback/display_item_list_settings.cc5
-rw-r--r--cc/playback/display_item_list_settings.h4
10 files changed, 5 insertions, 322 deletions
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index 1f9fe77..6eab5c8 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -729,7 +729,6 @@ test("cc_unittests") {
"base/region_unittest.cc",
"base/rolling_time_delta_history_unittest.cc",
"base/scoped_ptr_vector_unittest.cc",
- "base/sidecar_list_container_unittest.cc",
"base/simple_enclosed_region_unittest.cc",
"base/tiling_data_unittest.cc",
"base/unique_notifier_unittest.cc",
diff --git a/cc/base/BUILD.gn b/cc/base/BUILD.gn
index 98a5d4a..d02b900 100644
--- a/cc/base/BUILD.gn
+++ b/cc/base/BUILD.gn
@@ -25,7 +25,6 @@ source_set("base") {
"scoped_ptr_algorithm.h",
"scoped_ptr_deque.h",
"scoped_ptr_vector.h",
- "sidecar_list_container.h",
"simple_enclosed_region.cc",
"simple_enclosed_region.h",
"switches.cc",
diff --git a/cc/base/sidecar_list_container.h b/cc/base/sidecar_list_container.h
deleted file mode 100644
index 5135ab1..0000000
--- a/cc/base/sidecar_list_container.h
+++ /dev/null
@@ -1,97 +0,0 @@
-// 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 CC_BASE_SIDECAR_LIST_CONTAINER_H_
-#define CC_BASE_SIDECAR_LIST_CONTAINER_H_
-
-#include "base/logging.h"
-#include "cc/base/list_container.h"
-
-namespace cc {
-
-// This is a container, based on ListContainer, which allocates space in a
-// contiguous block for objects subclassing BaseElementType, as well as an
-// additional "sidecar" of opaque type.
-//
-// It takes a pointer to a function for tearing down sidecar objects, which must
-// free any resources held by it as its memory will be deallocated by the
-// container afterwards. When an element is constructed, callers are expected to
-// immediately construct the sidecar as well (such that the sidecar destroyer
-// will run safely and successfully).
-//
-// TODO(jbroman): It would be nice to be clear about the memory alignment
-// constraints here, but that probably requires closer inspection of
-// ListContainer first.
-template <class BaseElementType>
-class SidecarListContainer {
- public:
- using SidecarDestroyer = void (*)(void* sidecar);
- using Iterator = typename ListContainer<BaseElementType>::Iterator;
- using ConstIterator = typename ListContainer<BaseElementType>::ConstIterator;
- using ReverseIterator =
- typename ListContainer<BaseElementType>::ReverseIterator;
- using ConstReverseIterator =
- typename ListContainer<BaseElementType>::ConstReverseIterator;
-
- explicit SidecarListContainer(size_t max_size_for_derived_class,
- size_t max_size_for_sidecar,
- size_t num_of_elements_to_reserve_for,
- SidecarDestroyer destroyer)
- : list_(max_size_for_derived_class + max_size_for_sidecar,
- num_of_elements_to_reserve_for),
- destroyer_(destroyer),
- sidecar_offset_(max_size_for_derived_class) {}
- ~SidecarListContainer() { DestroyAllSidecars(); }
-
- // Forward most of the reading logic to ListContainer.
- bool empty() const { return list_.empty(); }
- size_t size() const { return list_.size(); }
- size_t GetCapacityInBytes() const { return list_.GetCapacityInBytes(); }
- ConstIterator begin() const { return list_.begin(); }
- ConstIterator end() const { return list_.end(); }
-
- template <typename DerivedElementType>
- DerivedElementType* AllocateAndConstruct() {
- return list_.template AllocateAndConstruct<DerivedElementType>();
- }
- template <typename DerivedElementType>
- DerivedElementType* AllocateAndCopyFrom(const DerivedElementType* source) {
- return list_.template AllocateAndCopyFrom<DerivedElementType>(source);
- }
-
- void clear() {
- DestroyAllSidecars();
- list_.clear();
- }
-
- void RemoveLast() {
- destroyer_(GetSidecar(*list_.rbegin()));
- list_.RemoveLast();
- }
-
- // This permits a client to exchange a pointer to an element to a pointer to
- // its corresponding sidecar.
- void* GetSidecar(BaseElementType* element) {
- DCHECK_GT(sidecar_offset_, 0u);
- return reinterpret_cast<char*>(element) + sidecar_offset_;
- }
- const void* GetSidecar(const BaseElementType* element) {
- DCHECK_GT(sidecar_offset_, 0u);
- return reinterpret_cast<const char*>(element) + sidecar_offset_;
- }
-
- private:
- void DestroyAllSidecars() {
- for (auto* element : list_)
- destroyer_(GetSidecar(element));
- }
-
- ListContainer<BaseElementType> list_;
- SidecarDestroyer destroyer_;
- size_t sidecar_offset_;
-};
-
-} // namespace cc
-
-#endif // CC_BASE_SIDECAR_LIST_CONTAINER_H_
diff --git a/cc/base/sidecar_list_container_unittest.cc b/cc/base/sidecar_list_container_unittest.cc
deleted file mode 100644
index 0012014..0000000
--- a/cc/base/sidecar_list_container_unittest.cc
+++ /dev/null
@@ -1,198 +0,0 @@
-// 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.
-
-#include "cc/base/sidecar_list_container.h"
-
-#include <algorithm>
-
-#include "base/logging.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace cc {
-namespace {
-
-const size_t kNumInitiallyReservedElements = 2;
-const size_t kNumElementsForTest = 100;
-
-class DestructionNotifier {
- public:
- DestructionNotifier() : flag_(nullptr) {}
- explicit DestructionNotifier(bool* flag) { set_flag(flag); }
- ~DestructionNotifier() {
- if (flag_)
- *flag_ = true;
- }
- void set_flag(bool* flag) {
- if (flag)
- DCHECK(!*flag);
- flag_ = flag;
- }
-
- private:
- bool* flag_;
-};
-
-class TestElement {
- public:
- TestElement() {}
- virtual ~TestElement() {}
- void set_destruction_flag(bool* flag) { notifier_.set_flag(flag); }
-
- private:
- DestructionNotifier notifier_;
-};
-
-class DerivedTestElement : public TestElement {
- public:
- int additional_field = 0;
-};
-
-class TestSidecar {
- public:
- TestSidecar() {}
- explicit TestSidecar(bool* destruction_flag) : notifier_(destruction_flag) {}
-
- static void Destroy(void* sidecar) {
- static_cast<TestSidecar*>(sidecar)->~TestSidecar();
- }
-
- protected:
- virtual ~TestSidecar() {}
-
- private:
- DestructionNotifier notifier_;
-};
-
-class DerivedTestSidecar : public TestSidecar {
- public:
- DerivedTestSidecar() {}
- explicit DerivedTestSidecar(bool* destruction_flag)
- : TestSidecar(destruction_flag) {}
- int additional_field = 0;
-
- private:
- ~DerivedTestSidecar() override {}
-};
-
-class TestContainer : public SidecarListContainer<TestElement> {
- public:
- TestContainer()
- : SidecarListContainer(
- std::max(sizeof(TestElement), sizeof(DerivedTestElement)),
- std::max(sizeof(TestSidecar), sizeof(DerivedTestSidecar)),
- kNumInitiallyReservedElements,
- &TestSidecar::Destroy) {}
-};
-
-TEST(SidecarListContainerTest, Destructor) {
- bool element_destroyed = false;
- bool sidecar_destroyed = false;
-
- {
- TestContainer container;
-
- TestElement* element = container.AllocateAndConstruct<TestElement>();
- TestSidecar* sidecar =
- new (container.GetSidecar(element)) TestSidecar(&sidecar_destroyed);
- element->set_destruction_flag(&element_destroyed);
-
- // They shouldn't be destroyed yet. And they shouldn't overlap in memory.
- ASSERT_FALSE(element_destroyed);
- ASSERT_FALSE(sidecar_destroyed);
- ASSERT_GE(reinterpret_cast<char*>(sidecar),
- reinterpret_cast<char*>(element) + sizeof(TestElement));
- }
-
- // They should, however, be destroyed when going out of scope.
- ASSERT_TRUE(element_destroyed);
- ASSERT_TRUE(sidecar_destroyed);
-}
-
-TEST(SidecarListContainerTest, Clear) {
- bool element_destroyed = false;
- bool sidecar_destroyed = false;
-
- TestContainer container;
-
- TestElement* element = container.AllocateAndConstruct<TestElement>();
- new (container.GetSidecar(element)) TestSidecar(&sidecar_destroyed);
- element->set_destruction_flag(&element_destroyed);
-
- // They shouldn't be destroyed yet.
- ASSERT_FALSE(element_destroyed);
- ASSERT_FALSE(sidecar_destroyed);
-
- // They should, however, be destroyed after clearing.
- container.clear();
- EXPECT_TRUE(element_destroyed);
- EXPECT_TRUE(sidecar_destroyed);
-}
-
-TEST(SidecarListContainerTest, DerivedTypes) {
- bool element_destroyed = false;
- bool sidecar_destroyed = false;
-
- {
- TestContainer container;
-
- DerivedTestElement* element =
- container.AllocateAndConstruct<DerivedTestElement>();
- DerivedTestSidecar* sidecar = new (container.GetSidecar(element))
- DerivedTestSidecar(&sidecar_destroyed);
- element->set_destruction_flag(&element_destroyed);
- element->additional_field = 12;
- sidecar->additional_field = 13;
-
- // They shouldn't be destroyed yet.
- ASSERT_FALSE(element_destroyed);
- ASSERT_FALSE(sidecar_destroyed);
- }
-
- // They should, however, be destroyed when going out of scope.
- EXPECT_TRUE(element_destroyed);
- EXPECT_TRUE(sidecar_destroyed);
-}
-
-TEST(SidecarListContainerTest, AddingAndRemovingElements) {
- TestContainer container;
- EXPECT_TRUE(container.empty());
- EXPECT_EQ(0u, container.size());
- EXPECT_EQ(container.end(), container.begin());
-
- for (size_t i = 1; i <= kNumElementsForTest; i++) {
- TestElement* element = container.AllocateAndConstruct<TestElement>();
- new (container.GetSidecar(element)) TestSidecar();
-
- ASSERT_FALSE(container.empty());
- ASSERT_EQ(i, container.size());
- ASSERT_NE(container.end(), container.begin());
- }
-
- size_t num_elements = 0;
- for (const auto* element : container) {
- (void)element;
- num_elements++;
- }
- EXPECT_EQ(kNumElementsForTest, num_elements);
-
- container.clear();
- EXPECT_TRUE(container.empty());
- EXPECT_EQ(0u, container.size());
- EXPECT_EQ(container.end(), container.begin());
-}
-
-TEST(SidecarListContainerTest, RemoveLast) {
- // We need only ensure that the sidecar is also destroyed on RemoveLast.
- // The rest is logic already present in ListContainer.
- bool sidecar_destroyed = false;
- TestContainer container;
- TestElement* element = container.AllocateAndConstruct<TestElement>();
- new (container.GetSidecar(element)) TestSidecar(&sidecar_destroyed);
- ASSERT_FALSE(sidecar_destroyed);
- container.RemoveLast();
- ASSERT_TRUE(sidecar_destroyed);
-}
-
-} // namespace
-} // namespace cc
diff --git a/cc/cc.gyp b/cc/cc.gyp
index c0fb72f..df9f9bd 100644
--- a/cc/cc.gyp
+++ b/cc/cc.gyp
@@ -92,7 +92,6 @@
'base/scoped_ptr_algorithm.h',
'base/scoped_ptr_deque.h',
'base/scoped_ptr_vector.h',
- 'base/sidecar_list_container.h',
'base/simple_enclosed_region.cc',
'base/simple_enclosed_region.h',
'base/switches.cc',
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp
index c824da0..deb7d32 100644
--- a/cc/cc_tests.gyp
+++ b/cc/cc_tests.gyp
@@ -25,7 +25,6 @@
'base/region_unittest.cc',
'base/rolling_time_delta_history_unittest.cc',
'base/scoped_ptr_vector_unittest.cc',
- 'base/sidecar_list_container_unittest.cc',
'base/simple_enclosed_region_unittest.cc',
'base/tiling_data_unittest.cc',
'base/unique_notifier_unittest.cc',
diff --git a/cc/playback/display_item_list.cc b/cc/playback/display_item_list.cc
index 6959c69..73e8762 100644
--- a/cc/playback/display_item_list.cc
+++ b/cc/playback/display_item_list.cc
@@ -43,10 +43,7 @@ const int kDefaultNumDisplayItemsToReserve = 100;
DisplayItemList::DisplayItemList(gfx::Rect layer_rect,
const DisplayItemListSettings& settings,
bool retain_individual_display_items)
- : items_(LargestDisplayItemSize(),
- settings.max_sidecar_size,
- kDefaultNumDisplayItemsToReserve,
- settings.sidecar_destroyer),
+ : items_(LargestDisplayItemSize(), kDefaultNumDisplayItemsToReserve),
use_cached_picture_(settings.use_cached_picture),
retain_individual_display_items_(retain_individual_display_items),
layer_rect_(layer_rect),
@@ -305,8 +302,4 @@ void DisplayItemList::GatherDiscardableImages(const gfx::Size& grid_cell_size) {
images_->GatherImagesFromPicture(picture_.get(), layer_rect_);
}
-void* DisplayItemList::GetSidecar(DisplayItem* display_item) {
- return items_.GetSidecar(display_item);
-}
-
} // namespace cc
diff --git a/cc/playback/display_item_list.h b/cc/playback/display_item_list.h
index 92a423e..e85fe10 100644
--- a/cc/playback/display_item_list.h
+++ b/cc/playback/display_item_list.h
@@ -10,8 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/trace_event/trace_event.h"
#include "cc/base/cc_export.h"
-#include "cc/base/scoped_ptr_vector.h"
-#include "cc/base/sidecar_list_container.h"
+#include "cc/base/list_container.h"
#include "cc/playback/discardable_image_map.h"
#include "cc/playback/display_item.h"
#include "skia/ext/refptr.h"
@@ -32,7 +31,7 @@ class CC_EXPORT DisplayItemList
const DisplayItemListSettings& settings);
// Creates a display item list with the given cull rect (if picture caching
- // is used). The resulting display list will not support sidecar data.
+ // is used).
static scoped_refptr<DisplayItemList> Create(gfx::Rect layer_rect,
bool use_cached_picture);
@@ -82,9 +81,6 @@ class CC_EXPORT DisplayItemList
void GatherDiscardableImages(const gfx::Size& grid_cell_size);
- // Finds the sidecar for a display item in this list.
- void* GetSidecar(DisplayItem* display_item);
-
private:
DisplayItemList(gfx::Rect layer_rect,
const DisplayItemListSettings& display_list_settings,
@@ -104,7 +100,7 @@ class CC_EXPORT DisplayItemList
bool ProcessAppendedItemsCalled() const { return true; }
#endif
- SidecarListContainer<DisplayItem> items_;
+ ListContainer<DisplayItem> items_;
skia::RefPtr<SkPicture> picture_;
scoped_ptr<SkPictureRecorder> recorder_;
diff --git a/cc/playback/display_item_list_settings.cc b/cc/playback/display_item_list_settings.cc
index e471d7e..c71d9ee 100644
--- a/cc/playback/display_item_list_settings.cc
+++ b/cc/playback/display_item_list_settings.cc
@@ -7,10 +7,7 @@
namespace cc {
DisplayItemListSettings::DisplayItemListSettings()
- : use_cached_picture(false),
- max_sidecar_size(0),
- sidecar_destroyer([](void* sidecar) {}) {
-}
+ : use_cached_picture(false) {}
DisplayItemListSettings::~DisplayItemListSettings() {
}
diff --git a/cc/playback/display_item_list_settings.h b/cc/playback/display_item_list_settings.h
index 277a2ea..85fe8db 100644
--- a/cc/playback/display_item_list_settings.h
+++ b/cc/playback/display_item_list_settings.h
@@ -18,10 +18,6 @@ class CC_EXPORT DisplayItemListSettings {
// If set, a picture will be cached inside the DisplayItemList.
bool use_cached_picture;
-
- // Settings that control sidecar data.
- size_t max_sidecar_size;
- void (*sidecar_destroyer)(void* sidecar);
};
} // namespace cc