summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-26 18:06:10 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-26 18:06:10 +0000
commitadb08548d49107d17ccd2caea44c7fc8bc106680 (patch)
treeb04645bbd04bbca91d41a4badad5528e2f29b9ad
parentab3b99de93676e6b18a0b58d2de141694c2ab79a (diff)
downloadchromium_src-adb08548d49107d17ccd2caea44c7fc8bc106680.zip
chromium_src-adb08548d49107d17ccd2caea44c7fc8bc106680.tar.gz
chromium_src-adb08548d49107d17ccd2caea44c7fc8bc106680.tar.bz2
This fixes all lint issues (except for false positives) in:
cc/base/ cc/debug/ cc/resources/ cc/quads/ BUG=144577 Review URL: https://codereview.chromium.org/13051003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190715 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/base/completion_event.h2
-rw-r--r--cc/base/hash_pair.h69
-rw-r--r--cc/base/hash_pair_unittest.cc37
-rw-r--r--cc/base/math_util.h1
-rw-r--r--cc/base/region_unittest.cc2
-rw-r--r--cc/base/scoped_ptr_deque.h2
-rw-r--r--cc/base/scoped_ptr_hash_map.h6
-rw-r--r--cc/base/scoped_ptr_vector.h5
-rw-r--r--cc/base/tiling_data.cc6
-rw-r--r--cc/base/tiling_data.h7
-rw-r--r--cc/base/tiling_data_unittest.cc2
-rw-r--r--cc/base/worker_pool.cc5
-rw-r--r--cc/base/worker_pool.h2
-rw-r--r--cc/debug/debug_colors.cc231
-rw-r--r--cc/debug/debug_colors.h3
-rw-r--r--cc/debug/devtools_instrumentation.h6
-rw-r--r--cc/debug/fake_web_graphics_context_3d.h4
-rw-r--r--cc/debug/frame_rate_counter.cc1
-rw-r--r--cc/debug/overdraw_metrics.h6
-rw-r--r--cc/debug/rendering_stats_instrumentation.h6
-rw-r--r--cc/debug/ring_buffer.h26
-rw-r--r--cc/layers/layer_unittest.cc2
-rw-r--r--cc/layers/picture_layer_impl.h6
-rw-r--r--cc/quads/checkerboard_draw_quad.h3
-rw-r--r--cc/quads/debug_border_draw_quad.h3
-rw-r--r--cc/quads/draw_quad.cc4
-rw-r--r--cc/quads/draw_quad.h2
-rw-r--r--cc/quads/draw_quad_unittest.cc16
-rw-r--r--cc/quads/io_surface_draw_quad.cc2
-rw-r--r--cc/quads/io_surface_draw_quad.h3
-rw-r--r--cc/quads/render_pass.h9
-rw-r--r--cc/quads/render_pass_draw_quad.cc10
-rw-r--r--cc/quads/render_pass_draw_quad.h2
-rw-r--r--cc/quads/render_pass_unittest.cc3
-rw-r--r--cc/quads/shared_quad_state.h2
-rw-r--r--cc/quads/solid_color_draw_quad.h3
-rw-r--r--cc/quads/stream_video_draw_quad.h3
-rw-r--r--cc/quads/texture_draw_quad.h3
-rw-r--r--cc/quads/tile_draw_quad.h3
-rw-r--r--cc/quads/yuv_video_draw_quad.h3
-rw-r--r--cc/resources/caching_bitmap_content_layer_updater.cc4
-rw-r--r--cc/resources/image_layer_updater.cc2
-rw-r--r--cc/resources/layer_quad.h19
-rw-r--r--cc/resources/layer_tiling_data.cc2
-rw-r--r--cc/resources/layer_tiling_data.h2
-rw-r--r--cc/resources/managed_memory_policy.cc4
-rw-r--r--cc/resources/managed_memory_policy.h2
-rw-r--r--cc/resources/managed_tile_state.cc2
-rw-r--r--cc/resources/memory_history.cc2
-rw-r--r--cc/resources/picture.cc5
-rw-r--r--cc/resources/picture.h2
-rw-r--r--cc/resources/picture_layer_tiling.cc4
-rw-r--r--cc/resources/picture_layer_tiling.h8
-rw-r--r--cc/resources/picture_layer_tiling_set.h2
-rw-r--r--cc/resources/picture_layer_tiling_set_unittest.cc2
-rw-r--r--cc/resources/picture_layer_tiling_unittest.cc1
-rw-r--r--cc/resources/picture_pile.cc6
-rw-r--r--cc/resources/picture_pile_base.cc3
-rw-r--r--cc/resources/picture_pile_base.h3
-rw-r--r--cc/resources/picture_pile_impl.cc4
-rw-r--r--cc/resources/picture_pile_impl.h3
-rw-r--r--cc/resources/prioritized_resource_manager.cc1
-rw-r--r--cc/resources/prioritized_resource_manager.h4
-rw-r--r--cc/resources/prioritized_resource_unittest.cc1375
-rw-r--r--cc/resources/priority_calculator.cc2
-rw-r--r--cc/resources/priority_calculator.h2
-rw-r--r--cc/resources/resource_pool.h4
-rw-r--r--cc/resources/resource_provider.cc5
-rw-r--r--cc/resources/resource_provider.h2
-rw-r--r--cc/resources/resource_provider_unittest.cc14
-rw-r--r--cc/resources/resource_update.h2
-rw-r--r--cc/resources/resource_update_controller_unittest.cc13
-rw-r--r--cc/resources/resource_update_queue.h2
-rw-r--r--cc/resources/scoped_resource.h4
-rw-r--r--cc/resources/scoped_resource_unittest.cc2
-rw-r--r--cc/resources/tile.h4
-rw-r--r--cc/resources/tile_manager.cc7
-rw-r--r--cc/resources/tile_manager.h9
-rw-r--r--cc/resources/tile_priority.cc20
-rw-r--r--cc/resources/tile_priority.h7
80 files changed, 1126 insertions, 946 deletions
diff --git a/cc/base/completion_event.h b/cc/base/completion_event.h
index f7fa5b1..759ce9c 100644
--- a/cc/base/completion_event.h
+++ b/cc/base/completion_event.h
@@ -58,6 +58,6 @@ class CompletionEvent {
#endif
};
-}
+} // namespace cc
#endif // CC_BASE_COMPLETION_EVENT_H_
diff --git a/cc/base/hash_pair.h b/cc/base/hash_pair.h
index e8602d2..5e0aa08 100644
--- a/cc/base/hash_pair.h
+++ b/cc/base/hash_pair.h
@@ -7,6 +7,9 @@
#ifndef CC_BASE_HASH_PAIR_H_
#define CC_BASE_HASH_PAIR_H_
+#include <utility>
+
+#include "base/basictypes.h"
#include "base/hash_tables.h"
#if defined(COMPILER_MSVC)
@@ -30,7 +33,7 @@
#else
#error define DEFINE_PAIR_HASH_FUNCTION_START for your compiler
-#endif // COMPILER
+#endif // COMPILER
namespace BASE_HASH_NAMESPACE {
@@ -61,22 +64,22 @@ namespace BASE_HASH_NAMESPACE {
} \
DEFINE_PAIR_HASH_FUNCTION_END();
-DEFINE_32BIT_PAIR_HASH(short, short);
-DEFINE_32BIT_PAIR_HASH(short, unsigned short);
-DEFINE_32BIT_PAIR_HASH(short, int);
-DEFINE_32BIT_PAIR_HASH(short, unsigned);
-DEFINE_32BIT_PAIR_HASH(unsigned short, short);
-DEFINE_32BIT_PAIR_HASH(unsigned short, unsigned short);
-DEFINE_32BIT_PAIR_HASH(unsigned short, int);
-DEFINE_32BIT_PAIR_HASH(unsigned short, unsigned);
-DEFINE_32BIT_PAIR_HASH(int, short);
-DEFINE_32BIT_PAIR_HASH(int, unsigned short);
-DEFINE_32BIT_PAIR_HASH(int, int);
-DEFINE_32BIT_PAIR_HASH(int, unsigned);
-DEFINE_32BIT_PAIR_HASH(unsigned, short);
-DEFINE_32BIT_PAIR_HASH(unsigned, unsigned short);
-DEFINE_32BIT_PAIR_HASH(unsigned, int);
-DEFINE_32BIT_PAIR_HASH(unsigned, unsigned);
+DEFINE_32BIT_PAIR_HASH(int16, int16);
+DEFINE_32BIT_PAIR_HASH(int16, uint16);
+DEFINE_32BIT_PAIR_HASH(int16, int32);
+DEFINE_32BIT_PAIR_HASH(int16, uint32);
+DEFINE_32BIT_PAIR_HASH(uint16, int16);
+DEFINE_32BIT_PAIR_HASH(uint16, uint16);
+DEFINE_32BIT_PAIR_HASH(uint16, int32);
+DEFINE_32BIT_PAIR_HASH(uint16, uint32);
+DEFINE_32BIT_PAIR_HASH(int32, int16);
+DEFINE_32BIT_PAIR_HASH(int32, uint16);
+DEFINE_32BIT_PAIR_HASH(int32, int32);
+DEFINE_32BIT_PAIR_HASH(int32, uint32);
+DEFINE_32BIT_PAIR_HASH(uint32, int16);
+DEFINE_32BIT_PAIR_HASH(uint32, uint16);
+DEFINE_32BIT_PAIR_HASH(uint32, int32);
+DEFINE_32BIT_PAIR_HASH(uint32, uint32);
#undef DEFINE_32BIT_PAIR_HASH
@@ -120,24 +123,24 @@ DEFINE_32BIT_PAIR_HASH(unsigned, unsigned);
} \
DEFINE_PAIR_HASH_FUNCTION_END();
-DEFINE_64BIT_PAIR_HASH(short, int64);
-DEFINE_64BIT_PAIR_HASH(short, uint64);
-DEFINE_64BIT_PAIR_HASH(unsigned short, int64);
-DEFINE_64BIT_PAIR_HASH(unsigned short, uint64);
-DEFINE_64BIT_PAIR_HASH(int, int64);
-DEFINE_64BIT_PAIR_HASH(int, uint64);
-DEFINE_64BIT_PAIR_HASH(unsigned, int64);
-DEFINE_64BIT_PAIR_HASH(unsigned, uint64);
-DEFINE_64BIT_PAIR_HASH(int64, short);
-DEFINE_64BIT_PAIR_HASH(int64, unsigned short);
-DEFINE_64BIT_PAIR_HASH(int64, int);
-DEFINE_64BIT_PAIR_HASH(int64, unsigned);
+DEFINE_64BIT_PAIR_HASH(int16, int64);
+DEFINE_64BIT_PAIR_HASH(int16, uint64);
+DEFINE_64BIT_PAIR_HASH(uint16, int64);
+DEFINE_64BIT_PAIR_HASH(uint16, uint64);
+DEFINE_64BIT_PAIR_HASH(int32, int64);
+DEFINE_64BIT_PAIR_HASH(int32, uint64);
+DEFINE_64BIT_PAIR_HASH(uint32, int64);
+DEFINE_64BIT_PAIR_HASH(uint32, uint64);
+DEFINE_64BIT_PAIR_HASH(int64, int16);
+DEFINE_64BIT_PAIR_HASH(int64, uint16);
+DEFINE_64BIT_PAIR_HASH(int64, int32);
+DEFINE_64BIT_PAIR_HASH(int64, uint32);
DEFINE_64BIT_PAIR_HASH(int64, int64);
DEFINE_64BIT_PAIR_HASH(int64, uint64);
-DEFINE_64BIT_PAIR_HASH(uint64, short);
-DEFINE_64BIT_PAIR_HASH(uint64, unsigned short);
-DEFINE_64BIT_PAIR_HASH(uint64, int);
-DEFINE_64BIT_PAIR_HASH(uint64, unsigned);
+DEFINE_64BIT_PAIR_HASH(uint64, int16);
+DEFINE_64BIT_PAIR_HASH(uint64, uint16);
+DEFINE_64BIT_PAIR_HASH(uint64, int32);
+DEFINE_64BIT_PAIR_HASH(uint64, uint32);
DEFINE_64BIT_PAIR_HASH(uint64, int64);
DEFINE_64BIT_PAIR_HASH(uint64, uint64);
diff --git a/cc/base/hash_pair_unittest.cc b/cc/base/hash_pair_unittest.cc
index 685e935..ad16761 100644
--- a/cc/base/hash_pair_unittest.cc
+++ b/cc/base/hash_pair_unittest.cc
@@ -22,46 +22,29 @@ class HashPairTest : public testing::Test {
// Verify that a hash_map can be constructed for pairs of integers of various
// sizes.
TEST_F(HashPairTest, IntegerPairs) {
- typedef std::pair<short, short> ShortShortPair;
- typedef std::pair<short, int> ShortIntPair;
- typedef std::pair<short, int32> ShortInt32Pair;
- typedef std::pair<short, int64> ShortInt64Pair;
+ typedef std::pair<int16, int16> Int16Int16Pair;
+ typedef std::pair<int16, int32> Int16Int32Pair;
+ typedef std::pair<int16, int64> Int16Int64Pair;
- INSERT_PAIR_TEST(ShortShortPair, 4, 6);
- INSERT_PAIR_TEST(ShortIntPair, 7, (1 << 30) + 4342);
- INSERT_PAIR_TEST(ShortInt32Pair, 9, (1 << 29) + 378128932);
- INSERT_PAIR_TEST(ShortInt64Pair, 10,
+ INSERT_PAIR_TEST(Int16Int16Pair, 4, 6);
+ INSERT_PAIR_TEST(Int16Int32Pair, 9, (1 << 29) + 378128932);
+ INSERT_PAIR_TEST(Int16Int64Pair, 10,
(GG_INT64_C(1) << 60) + GG_INT64_C(78931732321));
- typedef std::pair<int, short> IntShortPair;
- typedef std::pair<int, int> IntIntPair;
- typedef std::pair<int, int32> IntInt32Pair;
- typedef std::pair<int, int64> IntInt64Pair;
-
- INSERT_PAIR_TEST(IntShortPair, 4, 6);
- INSERT_PAIR_TEST(IntIntPair, 7, (1 << 30) + 4342);
- INSERT_PAIR_TEST(IntInt32Pair, 9, (1 << 29) + 378128932);
- INSERT_PAIR_TEST(IntInt64Pair, 10,
- (GG_INT64_C(1) << 60) + GG_INT64_C(78931732321));
-
- typedef std::pair<int32, short> Int32ShortPair;
- typedef std::pair<int32, int> Int32IntPair;
+ typedef std::pair<int32, int16> Int32Int16Pair;
typedef std::pair<int32, int32> Int32Int32Pair;
typedef std::pair<int32, int64> Int32Int64Pair;
- INSERT_PAIR_TEST(Int32ShortPair, 4, 6);
- INSERT_PAIR_TEST(Int32IntPair, 7, (1 << 30) + 4342);
+ INSERT_PAIR_TEST(Int32Int16Pair, 4, 6);
INSERT_PAIR_TEST(Int32Int32Pair, 9, (1 << 29) + 378128932);
INSERT_PAIR_TEST(Int32Int64Pair, 10,
(GG_INT64_C(1) << 60) + GG_INT64_C(78931732321));
- typedef std::pair<int64, short> Int64ShortPair;
- typedef std::pair<int64, int> Int64IntPair;
+ typedef std::pair<int64, int16> Int64Int16Pair;
typedef std::pair<int64, int32> Int64Int32Pair;
typedef std::pair<int64, int64> Int64Int64Pair;
- INSERT_PAIR_TEST(Int64ShortPair, 4, 6);
- INSERT_PAIR_TEST(Int64IntPair, 7, (1 << 30) + 4342);
+ INSERT_PAIR_TEST(Int64Int16Pair, 4, 6);
INSERT_PAIR_TEST(Int64Int32Pair, 9, (1 << 29) + 378128932);
INSERT_PAIR_TEST(Int64Int64Pair, 10,
(GG_INT64_C(1) << 60) + GG_INT64_C(78931732321));
diff --git a/cc/base/math_util.h b/cc/base/math_util.h
index dc9110f..1736444 100644
--- a/cc/base/math_util.h
+++ b/cc/base/math_util.h
@@ -152,7 +152,6 @@ class CC_EXPORT MathUtil {
// If the value is inf, returns max double/float representation.
static scoped_ptr<base::Value> AsValueSafely(double value);
static scoped_ptr<base::Value> AsValueSafely(float value);
-
};
} // namespace cc
diff --git a/cc/base/region_unittest.cc b/cc/base/region_unittest.cc
index 737ae27..20379ba 100644
--- a/cc/base/region_unittest.cc
+++ b/cc/base/region_unittest.cc
@@ -71,7 +71,7 @@ TEST(RegionTest, ContainsPoint) {
TEST_BOTTOM_OF_RECT(r, 31, 40, 10, 10);
r.Union(gfx::Rect(42, 40, 10, 10));
-
+
TEST_INSIDE_RECT(r, 42, 40, 10, 10);
TEST_LEFT_OF_RECT(r, 42, 40, 10, 10);
TEST_RIGHT_OF_RECT(r, 42, 40, 10, 10);
diff --git a/cc/base/scoped_ptr_deque.h b/cc/base/scoped_ptr_deque.h
index b1e9d0e..35289f1 100644
--- a/cc/base/scoped_ptr_deque.h
+++ b/cc/base/scoped_ptr_deque.h
@@ -5,7 +5,9 @@
#ifndef CC_BASE_SCOPED_PTR_DEQUE_H_
#define CC_BASE_SCOPED_PTR_DEQUE_H_
+#include <algorithm>
#include <deque>
+
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
diff --git a/cc/base/scoped_ptr_hash_map.h b/cc/base/scoped_ptr_hash_map.h
index 734fb8a..3a749a5 100644
--- a/cc/base/scoped_ptr_hash_map.h
+++ b/cc/base/scoped_ptr_hash_map.h
@@ -5,6 +5,9 @@
#ifndef CC_BASE_SCOPED_PTR_HASH_MAP_H_
#define CC_BASE_SCOPED_PTR_HASH_MAP_H_
+#include <algorithm>
+#include <utility>
+
#include "base/basictypes.h"
#include "base/hash_tables.h"
#include "base/logging.h"
@@ -14,11 +17,12 @@
namespace cc {
// This type acts like a hash_map<K, scoped_ptr<V> >, based on top of
-// std::hash_map. The ScopedPtrHashMap has ownership of all values in the data
+// base::hash_map. The ScopedPtrHashMap has ownership of all values in the data
// structure.
template <typename Key, typename Value>
class ScopedPtrHashMap {
typedef base::hash_map<Key, Value*> Container;
+
public:
typedef typename Container::iterator iterator;
typedef typename Container::const_iterator const_iterator;
diff --git a/cc/base/scoped_ptr_vector.h b/cc/base/scoped_ptr_vector.h
index 1e69b16..01f4d3d 100644
--- a/cc/base/scoped_ptr_vector.h
+++ b/cc/base/scoped_ptr_vector.h
@@ -5,6 +5,9 @@
#ifndef CC_BASE_SCOPED_PTR_VECTOR_H_
#define CC_BASE_SCOPED_PTR_VECTOR_H_
+#include <algorithm>
+#include <vector>
+
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -142,7 +145,7 @@ class ScopedPtrVector {
template<class Compare>
inline void sort(Compare comp) {
- std::sort(data_.begin(), data_.end(), comp);
+ std::sort(data_.begin(), data_.end(), comp);
}
iterator begin() { return static_cast<iterator>(data_.begin()); }
diff --git a/cc/base/tiling_data.cc b/cc/base/tiling_data.cc
index f734b35..ba6aaa8 100644
--- a/cc/base/tiling_data.cc
+++ b/cc/base/tiling_data.cc
@@ -256,8 +256,10 @@ gfx::Vector2d TilingData::TextureOffset(int x_index, int y_index) const {
}
void TilingData::RecomputeNumTiles() {
- num_tiles_x_ = ComputeNumTiles(max_texture_size_.width(), total_size_.width(), border_texels_);
- num_tiles_y_ = ComputeNumTiles(max_texture_size_.height(), total_size_.height(), border_texels_);
+ num_tiles_x_ = ComputeNumTiles(
+ max_texture_size_.width(), total_size_.width(), border_texels_);
+ num_tiles_y_ = ComputeNumTiles(
+ max_texture_size_.height(), total_size_.height(), border_texels_);
}
TilingData::BaseIterator::BaseIterator(const TilingData* tiling_data)
diff --git a/cc/base/tiling_data.h b/cc/base/tiling_data.h
index fc71409e..3bf9809 100644
--- a/cc/base/tiling_data.h
+++ b/cc/base/tiling_data.h
@@ -5,6 +5,8 @@
#ifndef CC_BASE_TILING_DATA_H_
#define CC_BASE_TILING_DATA_H_
+#include <utility>
+
#include "base/basictypes.h"
#include "base/logging.h"
#include "cc/base/cc_export.h"
@@ -74,7 +76,10 @@ class CC_EXPORT TilingData {
protected:
explicit BaseIterator(const TilingData* tiling_data);
- void done() { index_x_ = -1; index_y_ = -1; }
+ void done() {
+ index_x_ = -1;
+ index_y_ = -1;
+ }
const TilingData* tiling_data_;
int index_x_;
diff --git a/cc/base/tiling_data_unittest.cc b/cc/base/tiling_data_unittest.cc
index f24dc6a..ea141ad 100644
--- a/cc/base/tiling_data_unittest.cc
+++ b/cc/base/tiling_data_unittest.cc
@@ -4,6 +4,8 @@
#include "cc/base/tiling_data.h"
+#include <vector>
+
#include "cc/test/geometry_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/cc/base/worker_pool.cc b/cc/base/worker_pool.cc
index 469f67c6..d276529 100644
--- a/cc/base/worker_pool.cc
+++ b/cc/base/worker_pool.cc
@@ -4,6 +4,8 @@
#include "cc/base/worker_pool.h"
+#include <algorithm>
+
#include "base/bind.h"
#include "base/debug/trace_event.h"
#include "base/stringprintf.h"
@@ -344,10 +346,9 @@ void WorkerPool::Inner::OnIdleOnOriginThread() {
void WorkerPool::Inner::Run() {
#if defined(OS_ANDROID)
// TODO(epenner): Move thread priorities to base. (crbug.com/170549)
- int nice_value = 10; // Idle priority.
+ int nice_value = 10; // Idle priority.
setpriority(PRIO_PROCESS, base::PlatformThread::CurrentId(), nice_value);
#endif
-
{
base::AutoLock lock(lock_);
diff --git a/cc/base/worker_pool.h b/cc/base/worker_pool.h
index af130f3..172165c 100644
--- a/cc/base/worker_pool.h
+++ b/cc/base/worker_pool.h
@@ -31,7 +31,7 @@ class WorkerPoolTask {
void DidComplete();
protected:
- WorkerPoolTask(const base::Closure& reply);
+ explicit WorkerPoolTask(const base::Closure& reply);
const base::Closure reply_;
};
diff --git a/cc/debug/debug_colors.cc b/cc/debug/debug_colors.cc
index 462fca7..cc43480 100644
--- a/cc/debug/debug_colors.cc
+++ b/cc/debug/debug_colors.cc
@@ -15,110 +15,217 @@ static const float Scale(float width, const LayerTreeImpl* tree_impl) {
// ======= Layer border colors =======
// Tiled content layers are orange.
-SkColor DebugColors::TiledContentLayerBorderColor() { return SkColorSetARGB(128, 255, 128, 0); }
-int DebugColors::TiledContentLayerBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
+SkColor DebugColors::TiledContentLayerBorderColor() {
+ return SkColorSetARGB(128, 255, 128, 0);
+}
+int DebugColors::TiledContentLayerBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
// Image layers are olive.
-SkColor DebugColors::ImageLayerBorderColor() { return SkColorSetARGB(128, 128, 128, 0); }
-int DebugColors::ImageLayerBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
+SkColor DebugColors::ImageLayerBorderColor() {
+ return SkColorSetARGB(128, 128, 128, 0);
+}
+int DebugColors::ImageLayerBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
// Non-tiled content layers area green.
-SkColor DebugColors::ContentLayerBorderColor() { return SkColorSetARGB(128, 0, 128, 32); }
-int DebugColors::ContentLayerBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
+SkColor DebugColors::ContentLayerBorderColor() {
+ return SkColorSetARGB(128, 0, 128, 32);
+}
+int DebugColors::ContentLayerBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
// Masking layers are pale blue and wide.
-SkColor DebugColors::MaskingLayerBorderColor() { return SkColorSetARGB(48, 128, 255, 255); }
-int DebugColors::MaskingLayerBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(20, tree_impl); }
+SkColor DebugColors::MaskingLayerBorderColor() {
+ return SkColorSetARGB(48, 128, 255, 255);
+}
+int DebugColors::MaskingLayerBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(20, tree_impl);
+}
// Other container layers are yellow.
-SkColor DebugColors::ContainerLayerBorderColor() { return SkColorSetARGB(192, 255, 255, 0); }
-int DebugColors::ContainerLayerBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
+SkColor DebugColors::ContainerLayerBorderColor() {
+ return SkColorSetARGB(192, 255, 255, 0);
+}
+int DebugColors::ContainerLayerBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
// Render surfaces are blue.
-SkColor DebugColors::SurfaceBorderColor() { return SkColorSetARGB(100, 0, 0, 255); }
-int DebugColors::SurfaceBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
+SkColor DebugColors::SurfaceBorderColor() {
+ return SkColorSetARGB(100, 0, 0, 255);
+}
+int DebugColors::SurfaceBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
// Replicas of render surfaces are purple.
-SkColor DebugColors::SurfaceReplicaBorderColor() { return SkColorSetARGB(100, 160, 0, 255); }
-int DebugColors::SurfaceReplicaBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
+SkColor DebugColors::SurfaceReplicaBorderColor() {
+ return SkColorSetARGB(100, 160, 0, 255);
+}
+int DebugColors::SurfaceReplicaBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
// ======= Tile colors =======
// High-res tile borders are cyan.
-SkColor DebugColors::HighResTileBorderColor() { return SkColorSetARGB(100, 80, 200, 200); }
-int DebugColors::HighResTileBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(1, tree_impl); }
+SkColor DebugColors::HighResTileBorderColor() {
+ return SkColorSetARGB(100, 80, 200, 200);
+}
+int DebugColors::HighResTileBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(1, tree_impl);
+}
// Low-res tile borders are purple.
-SkColor DebugColors::LowResTileBorderColor() { return SkColorSetARGB(100, 212, 83, 192); }
-int DebugColors::LowResTileBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
+SkColor DebugColors::LowResTileBorderColor() {
+ return SkColorSetARGB(100, 212, 83, 192);
+}
+int DebugColors::LowResTileBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
// Other high-resolution tile borders are yellow.
-SkColor DebugColors::ExtraHighResTileBorderColor() { return SkColorSetARGB(100, 239, 231, 20); }
-int DebugColors::ExtraHighResTileBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
+SkColor DebugColors::ExtraHighResTileBorderColor() {
+ return SkColorSetARGB(100, 239, 231, 20);
+}
+int DebugColors::ExtraHighResTileBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
// Other low-resolution tile borders are green.
-SkColor DebugColors::ExtraLowResTileBorderColor() { return SkColorSetARGB(100, 93, 186, 18); }
-int DebugColors::ExtraLowResTileBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
+SkColor DebugColors::ExtraLowResTileBorderColor() {
+ return SkColorSetARGB(100, 93, 186, 18);
+}
+int DebugColors::ExtraLowResTileBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
// Missing tile borders are red.
-SkColor DebugColors::MissingTileBorderColor() { return SkColorSetARGB(100, 255, 0, 0); }
-int DebugColors::MissingTileBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(1, tree_impl); }
+SkColor DebugColors::MissingTileBorderColor() {
+ return SkColorSetARGB(100, 255, 0, 0);
+}
+int DebugColors::MissingTileBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(1, tree_impl);
+}
// Culled tile borders are brown.
-SkColor DebugColors::CulledTileBorderColor() { return SkColorSetARGB(120, 160, 100, 0); }
-int DebugColors::CulledTileBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(1, tree_impl); }
+SkColor DebugColors::CulledTileBorderColor() {
+ return SkColorSetARGB(120, 160, 100, 0);
+}
+int DebugColors::CulledTileBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(1, tree_impl);
+}
// Solid color tile borders are grey.
-SkColor DebugColors::SolidColorTileBorderColor() { return SkColorSetARGB(128, 128, 128, 128); }
-int DebugColors::SolidColorTileBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(1, tree_impl); }
+SkColor DebugColors::SolidColorTileBorderColor() {
+ return SkColorSetARGB(128, 128, 128, 128);
+}
+int DebugColors::SolidColorTileBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(1, tree_impl);
+}
// ======= Checkerboard colors =======
// Non-debug checkerboards are grey.
-SkColor DebugColors::DefaultCheckerboardColor() { return SkColorSetRGB(241, 241, 241); }
+SkColor DebugColors::DefaultCheckerboardColor() {
+ return SkColorSetRGB(241, 241, 241);
+}
// Invalidated tiles get sky blue checkerboards.
-SkColor DebugColors::InvalidatedTileCheckerboardColor() { return SkColorSetRGB(128, 200, 245); }
+SkColor DebugColors::InvalidatedTileCheckerboardColor() {
+ return SkColorSetRGB(128, 200, 245);
+}
// Evicted tiles get pale red checkerboards.
-SkColor DebugColors::EvictedTileCheckerboardColor() { return SkColorSetRGB(255, 200, 200); }
+SkColor DebugColors::EvictedTileCheckerboardColor() {
+ return SkColorSetRGB(255, 200, 200);
+}
// ======= Debug rect colors =======
// Paint rects in red.
-SkColor DebugColors::PaintRectBorderColor() { return SkColorSetARGB(255, 255, 0, 0); }
-int DebugColors::PaintRectBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
-SkColor DebugColors::PaintRectFillColor() { return SkColorSetARGB(30, 255, 0, 0); }
+SkColor DebugColors::PaintRectBorderColor() {
+ return SkColorSetARGB(255, 255, 0, 0);
+}
+int DebugColors::PaintRectBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
+SkColor DebugColors::PaintRectFillColor() {
+ return SkColorSetARGB(30, 255, 0, 0);
+}
// Property-changed rects in blue.
-SkColor DebugColors::PropertyChangedRectBorderColor() { return SkColorSetARGB(255, 0, 0, 255); }
-int DebugColors::PropertyChangedRectBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
-SkColor DebugColors::PropertyChangedRectFillColor() { return SkColorSetARGB(30, 0, 0, 255); }
+SkColor DebugColors::PropertyChangedRectBorderColor() {
+ return SkColorSetARGB(255, 0, 0, 255);
+}
+int DebugColors::PropertyChangedRectBorderWidth(
+ const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
+SkColor DebugColors::PropertyChangedRectFillColor() {
+ return SkColorSetARGB(30, 0, 0, 255);
+}
// Surface damage rects in yellow-orange.
-SkColor DebugColors::SurfaceDamageRectBorderColor() { return SkColorSetARGB(255, 200, 100, 0); }
-int DebugColors::SurfaceDamageRectBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
-SkColor DebugColors::SurfaceDamageRectFillColor() { return SkColorSetARGB(30, 200, 100, 0); }
+SkColor DebugColors::SurfaceDamageRectBorderColor() {
+ return SkColorSetARGB(255, 200, 100, 0);
+}
+int DebugColors::SurfaceDamageRectBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
+SkColor DebugColors::SurfaceDamageRectFillColor() {
+ return SkColorSetARGB(30, 200, 100, 0);
+}
// Surface replica screen space rects in green.
-SkColor DebugColors::ScreenSpaceLayerRectBorderColor() { return SkColorSetARGB(255, 100, 200, 0); }
-int DebugColors::ScreenSpaceLayerRectBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
-SkColor DebugColors::ScreenSpaceLayerRectFillColor() { return SkColorSetARGB(30, 100, 200, 0); }
+SkColor DebugColors::ScreenSpaceLayerRectBorderColor() {
+ return SkColorSetARGB(255, 100, 200, 0);
+}
+int DebugColors::ScreenSpaceLayerRectBorderWidth(
+ const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
+SkColor DebugColors::ScreenSpaceLayerRectFillColor() {
+ return SkColorSetARGB(30, 100, 200, 0);
+}
// Layer screen space rects in purple.
-SkColor DebugColors::ScreenSpaceSurfaceReplicaRectBorderColor() { return SkColorSetARGB(255, 100, 0, 200); }
-int DebugColors::ScreenSpaceSurfaceReplicaRectBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
-SkColor DebugColors::ScreenSpaceSurfaceReplicaRectFillColor() { return SkColorSetARGB(10, 100, 0, 200); }
+SkColor DebugColors::ScreenSpaceSurfaceReplicaRectBorderColor() {
+ return SkColorSetARGB(255, 100, 0, 200);
+}
+int DebugColors::ScreenSpaceSurfaceReplicaRectBorderWidth(
+ const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
+SkColor DebugColors::ScreenSpaceSurfaceReplicaRectFillColor() {
+ return SkColorSetARGB(10, 100, 0, 200);
+}
// Occluding rects in pink.
-SkColor DebugColors::OccludingRectBorderColor() { return SkColorSetARGB(255, 245, 136, 255); }
-int DebugColors::OccludingRectBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
-SkColor DebugColors::OccludingRectFillColor() { return SkColorSetARGB(10, 245, 136, 255); }
+SkColor DebugColors::OccludingRectBorderColor() {
+ return SkColorSetARGB(255, 245, 136, 255);
+}
+int DebugColors::OccludingRectBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
+SkColor DebugColors::OccludingRectFillColor() {
+ return SkColorSetARGB(10, 245, 136, 255);
+}
// Non-Occluding rects in a reddish color.
-SkColor DebugColors::NonOccludingRectBorderColor() { return SkColorSetARGB(255, 200, 0, 100); }
-int DebugColors::NonOccludingRectBorderWidth(const LayerTreeImpl* tree_impl) { return Scale(2, tree_impl); }
-SkColor DebugColors::NonOccludingRectFillColor() { return SkColorSetARGB(10, 200, 0, 100); }
+SkColor DebugColors::NonOccludingRectBorderColor() {
+ return SkColorSetARGB(255, 200, 0, 100);
+}
+int DebugColors::NonOccludingRectBorderWidth(const LayerTreeImpl* tree_impl) {
+ return Scale(2, tree_impl);
+}
+SkColor DebugColors::NonOccludingRectFillColor() {
+ return SkColorSetARGB(10, 200, 0, 100);
+}
// Non-Painted rects in cyan.
SkColor DebugColors::NonPaintedFillColor() { return SK_ColorCYAN; }
@@ -128,15 +235,25 @@ SkColor DebugColors::MissingPictureFillColor() { return SK_ColorMAGENTA; }
// ======= HUD widget colors =======
-SkColor DebugColors::HUDBackgroundColor() { return SkColorSetARGB(215, 17, 17, 17); }
-SkColor DebugColors::HUDSeparatorLineColor() { return SkColorSetARGB(255, 130, 130, 130); }
-SkColor DebugColors::HUDIndicatorLineColor() { return SkColorSetARGB(255, 80, 80, 80); }
+SkColor DebugColors::HUDBackgroundColor() {
+ return SkColorSetARGB(215, 17, 17, 17);
+}
+SkColor DebugColors::HUDSeparatorLineColor() {
+ return SkColorSetARGB(255, 130, 130, 130);
+}
+SkColor DebugColors::HUDIndicatorLineColor() {
+ return SkColorSetARGB(255, 80, 80, 80);
+}
SkColor DebugColors::PlatformLayerTreeTextColor() { return SK_ColorRED; }
SkColor DebugColors::FPSDisplayTextAndGraphColor() { return SK_ColorRED; }
-SkColor DebugColors::MemoryDisplayTextColor() { return SkColorSetARGB(255, 220, 220, 220); }
+SkColor DebugColors::MemoryDisplayTextColor() {
+ return SkColorSetARGB(255, 220, 220, 220);
+}
// Paint time display in green (similar to paint times in the WebInspector)
-SkColor DebugColors::PaintTimeDisplayTextAndGraphColor() { return SkColorSetRGB(75, 155, 55); }
+SkColor DebugColors::PaintTimeDisplayTextAndGraphColor() {
+ return SkColorSetRGB(75, 155, 55);
+}
} // namespace cc
diff --git a/cc/debug/debug_colors.h b/cc/debug/debug_colors.h
index 4b9fe1a..ba5f8b6 100644
--- a/cc/debug/debug_colors.h
+++ b/cc/debug/debug_colors.h
@@ -77,7 +77,8 @@ class DebugColors {
static SkColor ScreenSpaceLayerRectFillColor();
static SkColor ScreenSpaceSurfaceReplicaRectBorderColor();
- static int ScreenSpaceSurfaceReplicaRectBorderWidth(const LayerTreeImpl* tree_impl);
+ static int ScreenSpaceSurfaceReplicaRectBorderWidth(
+ const LayerTreeImpl* tree_impl);
static SkColor ScreenSpaceSurfaceReplicaRectFillColor();
static SkColor OccludingRectBorderColor();
diff --git a/cc/debug/devtools_instrumentation.h b/cc/debug/devtools_instrumentation.h
index cfdd7dc..4b21366 100644
--- a/cc/debug/devtools_instrumentation.h
+++ b/cc/debug/devtools_instrumentation.h
@@ -18,7 +18,7 @@ const char kRasterTask[] = "RasterTask";
}
struct ScopedPaintLayer {
- ScopedPaintLayer(int layer_id) {
+ explicit ScopedPaintLayer(int layer_id) {
TRACE_EVENT_BEGIN1(internal::kCategory, internal::kPaintLayer,
internal::kLayerId, layer_id);
}
@@ -30,7 +30,7 @@ struct ScopedPaintLayer {
};
struct ScopedRasterTask {
- ScopedRasterTask(int layer_id) {
+ explicit ScopedRasterTask(int layer_id) {
TRACE_EVENT_BEGIN1(internal::kCategory, internal::kRasterTask,
internal::kLayerId, layer_id);
}
@@ -43,7 +43,7 @@ struct ScopedRasterTask {
struct ScopedLayerObjectTracker
: public base::debug::TraceScopedTrackableObject<int> {
- ScopedLayerObjectTracker(int layer_id)
+ explicit ScopedLayerObjectTracker(int layer_id)
: base::debug::TraceScopedTrackableObject<int>(
internal::kCategory,
internal::kLayerId,
diff --git a/cc/debug/fake_web_graphics_context_3d.h b/cc/debug/fake_web_graphics_context_3d.h
index dc0ea99..a1ccc05 100644
--- a/cc/debug/fake_web_graphics_context_3d.h
+++ b/cc/debug/fake_web_graphics_context_3d.h
@@ -13,8 +13,8 @@ namespace cc {
// WebGraphicsContext3D base class for use in unit tests.
// All operations are no-ops (returning 0 if necessary).
-class CC_EXPORT FakeWebGraphicsContext3D :
- public NON_EXPORTED_BASE(WebKit::WebGraphicsContext3D) {
+class CC_EXPORT FakeWebGraphicsContext3D
+ : public NON_EXPORTED_BASE(WebKit::WebGraphicsContext3D) {
public:
FakeWebGraphicsContext3D();
virtual ~FakeWebGraphicsContext3D();
diff --git a/cc/debug/frame_rate_counter.cc b/cc/debug/frame_rate_counter.cc
index bcd31b0..8a829ff 100644
--- a/cc/debug/frame_rate_counter.cc
+++ b/cc/debug/frame_rate_counter.cc
@@ -4,6 +4,7 @@
#include "cc/debug/frame_rate_counter.h"
+#include <algorithm>
#include <limits>
#include "base/metrics/histogram.h"
diff --git a/cc/debug/overdraw_metrics.h b/cc/debug/overdraw_metrics.h
index fcbd6ff..43bd19ba 100644
--- a/cc/debug/overdraw_metrics.h
+++ b/cc/debug/overdraw_metrics.h
@@ -21,7 +21,7 @@ class OverdrawMetrics {
public:
static scoped_ptr<OverdrawMetrics> Create(bool record_metrics_for_frame) {
return make_scoped_ptr(new OverdrawMetrics(record_metrics_for_frame));
- }
+ }
// These methods are used for saving metrics during update/commit.
@@ -93,9 +93,9 @@ class OverdrawMetrics {
// Count of tiles that were invalidated but not uploaded.
int tiles_culled_for_upload_;
// Count the number of bytes in contents textures.
- unsigned long long contents_texture_use_bytes_;
+ uint64 contents_texture_use_bytes_;
// Count the number of bytes in RenderSurfaceImpl textures.
- unsigned long long render_surface_texture_use_bytes_;
+ uint64 render_surface_texture_use_bytes_;
// These values are used for saving metrics during draw.
diff --git a/cc/debug/rendering_stats_instrumentation.h b/cc/debug/rendering_stats_instrumentation.h
index 63401c0..c3ec320 100644
--- a/cc/debug/rendering_stats_instrumentation.h
+++ b/cc/debug/rendering_stats_instrumentation.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CC_RENDERING_STATS_INSTRUMENTATION_H_
-#define CC_RENDERING_STATS_INSTRUMENTATION_H_
+#ifndef CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_
+#define CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
@@ -71,4 +71,4 @@ class CC_EXPORT RenderingStatsInstrumentation {
} // namespace cc
-#endif // CC_RENDERING_STATS_INSTRUMENTATION_H_
+#endif // CC_DEBUG_RENDERING_STATS_INSTRUMENTATION_H_
diff --git a/cc/debug/ring_buffer.h b/cc/debug/ring_buffer.h
index d9bf3f6..74da2d9 100644
--- a/cc/debug/ring_buffer.h
+++ b/cc/debug/ring_buffer.h
@@ -9,7 +9,7 @@
namespace cc {
-template<typename T, size_t size>
+template<typename T, size_t kSize>
class RingBuffer {
public:
explicit RingBuffer()
@@ -17,7 +17,7 @@ class RingBuffer {
}
size_t BufferSize() const {
- return size;
+ return kSize;
}
size_t CurrentIndex() const {
@@ -60,7 +60,7 @@ class RingBuffer {
Iterator& operator++() {
index_++;
- if (index_ == size)
+ if (index_ == kSize)
out_of_range_ = true;
return *this;
}
@@ -77,41 +77,41 @@ class RingBuffer {
}
private:
- Iterator(const RingBuffer<T, size>& buffer, size_t index)
+ Iterator(const RingBuffer<T, kSize>& buffer, size_t index)
: buffer_(buffer),
index_(index),
out_of_range_(false) {
}
- const RingBuffer<T, size>& buffer_;
+ const RingBuffer<T, kSize>& buffer_;
size_t index_;
bool out_of_range_;
- friend class RingBuffer<T, size>;
+ friend class RingBuffer<T, kSize>;
};
// Returns an Iterator pointing to the oldest value in the buffer.
// Example usage (iterate from oldest to newest value):
- // for (RingBuffer<T, size>::Iterator it = ring_buffer.Begin(); it; ++it) ...
+ // for (RingBuffer<T, kSize>::Iterator it = ring_buffer.Begin(); it; ++it) {}
Iterator Begin() const {
- if (current_index_ < size)
- return Iterator(*this, size - current_index_);
+ if (current_index_ < kSize)
+ return Iterator(*this, kSize - current_index_);
return Iterator(*this, 0);
}
// Returns an Iterator pointing to the newest value in the buffer.
// Example usage (iterate backwards from newest to oldest value):
- // for (RingBuffer<T, size>::Iterator it = ring_buffer.End(); it; --it) ...
+ // for (RingBuffer<T, kSize>::Iterator it = ring_buffer.End(); it; --it) {}
Iterator End() const {
- return Iterator(*this, size - 1);
+ return Iterator(*this, kSize - 1);
}
private:
inline size_t BufferIndex(size_t n) const {
- return (current_index_ + n) % size;
+ return (current_index_ + n) % kSize;
}
- T buffer_[size];
+ T buffer_[kSize];
size_t current_index_;
};
diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc
index 8a93c52..4184e0b 100644
--- a/cc/layers/layer_unittest.cc
+++ b/cc/layers/layer_unittest.cc
@@ -551,7 +551,7 @@ TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) {
gfx::Vector2d(10, 10)));
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetShouldScrollOnMainThread(true));
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetNonFastScrollableRegion(
- gfx::Rect(1, 1, 2, 2)));
+ Region(gfx::Rect(1, 1, 2, 2))));
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetHaveWheelEventHandlers(true));
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(
gfx::Transform(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)));
diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h
index 4a85691..c94d275 100644
--- a/cc/layers/picture_layer_impl.h
+++ b/cc/layers/picture_layer_impl.h
@@ -5,6 +5,7 @@
#ifndef CC_LAYERS_PICTURE_LAYER_IMPL_H_
#define CC_LAYERS_PICTURE_LAYER_IMPL_H_
+#include "cc/base/cc_export.h"
#include "cc/base/scoped_ptr_vector.h"
#include "cc/layers/layer_impl.h"
#include "cc/resources/picture_layer_tiling.h"
@@ -18,8 +19,9 @@ namespace cc {
struct AppendQuadsData;
class QuadSink;
-class CC_EXPORT PictureLayerImpl : public LayerImpl,
- public PictureLayerTilingClient {
+class CC_EXPORT PictureLayerImpl
+ : public LayerImpl,
+ NON_EXPORTED_BASE(public PictureLayerTilingClient) {
public:
static scoped_ptr<PictureLayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
return make_scoped_ptr(new PictureLayerImpl(tree_impl, id));
diff --git a/cc/quads/checkerboard_draw_quad.h b/cc/quads/checkerboard_draw_quad.h
index 53d1c5e..b2ed876 100644
--- a/cc/quads/checkerboard_draw_quad.h
+++ b/cc/quads/checkerboard_draw_quad.h
@@ -33,10 +33,11 @@ class CC_EXPORT CheckerboardDrawQuad : public DrawQuad {
OVERRIDE;
static const CheckerboardDrawQuad* MaterialCast(const DrawQuad*);
+
private:
CheckerboardDrawQuad();
};
-}
+} // namespace cc
#endif // CC_QUADS_CHECKERBOARD_DRAW_QUAD_H_
diff --git a/cc/quads/debug_border_draw_quad.h b/cc/quads/debug_border_draw_quad.h
index 80484368..2f4b3ca 100644
--- a/cc/quads/debug_border_draw_quad.h
+++ b/cc/quads/debug_border_draw_quad.h
@@ -36,10 +36,11 @@ class CC_EXPORT DebugBorderDrawQuad : public DrawQuad {
OVERRIDE;
static const DebugBorderDrawQuad* MaterialCast(const DrawQuad*);
+
private:
DebugBorderDrawQuad();
};
-}
+} // namespace cc
#endif // CC_QUADS_DEBUG_BORDER_DRAW_QUAD_H_
diff --git a/cc/quads/draw_quad.cc b/cc/quads/draw_quad.cc
index 22271d6..0250481 100644
--- a/cc/quads/draw_quad.cc
+++ b/cc/quads/draw_quad.cc
@@ -16,12 +16,10 @@
#include "cc/quads/yuv_video_draw_quad.h"
namespace {
-
template<typename T> T* TypedCopy(const cc::DrawQuad* other) {
return new T(*T::MaterialCast(other));
}
-
-}
+} // namespace
namespace cc {
diff --git a/cc/quads/draw_quad.h b/cc/quads/draw_quad.h
index 2636a07..05924f1 100644
--- a/cc/quads/draw_quad.h
+++ b/cc/quads/draw_quad.h
@@ -114,6 +114,6 @@ class CC_EXPORT DrawQuad {
bool needs_blending);
};
-}
+} // namespace cc
#endif // CC_QUADS_DRAW_QUAD_H_
diff --git a/cc/quads/draw_quad_unittest.cc b/cc/quads/draw_quad_unittest.cc
index 281da3b..3eefdc9 100644
--- a/cc/quads/draw_quad_unittest.cc
+++ b/cc/quads/draw_quad_unittest.cc
@@ -4,6 +4,8 @@
#include "cc/quads/draw_quad.h"
+#include <algorithm>
+
#include "base/bind.h"
#include "cc/base/math_util.h"
#include "cc/quads/checkerboard_draw_quad.h"
@@ -497,13 +499,13 @@ TEST(DrawQuadTest, ClipTextureDrawQuad) {
shared_state->clip_rect = gfx::Rect(50, 70, 30, 20);
// The original quad is 'ABCD', the clipped quad is 'abcd':
- //40 50 90
- // B--:-------C 60
- // | b----c -|-70
- // | | | |
- // | a----d -|-90
- // | |
- // A----------D 120
+ // 40 50 90
+ // B--:-------C 60
+ // | b----c -|-70
+ // | | | |
+ // | a----d -|-90
+ // | |
+ // A----------D 120
// UV and vertex opacity are stored per vertex on the parent rectangle 'ABCD'.
// This is the UV value for vertex 'B'.
diff --git a/cc/quads/io_surface_draw_quad.cc b/cc/quads/io_surface_draw_quad.cc
index ac107c1..eb4aa20 100644
--- a/cc/quads/io_surface_draw_quad.cc
+++ b/cc/quads/io_surface_draw_quad.cc
@@ -26,7 +26,7 @@ void IOSurfaceDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
gfx::Rect visible_rect = rect;
bool needs_blending = false;
DrawQuad::SetAll(shared_quad_state, DrawQuad::IO_SURFACE_CONTENT, rect,
- opaque_rect, visible_rect, needs_blending);
+ opaque_rect, visible_rect, needs_blending);
this->io_surface_size = io_surface_size;
this->io_surface_texture_id = io_surface_texture_id;
this->orientation = orientation;
diff --git a/cc/quads/io_surface_draw_quad.h b/cc/quads/io_surface_draw_quad.h
index d0559e2..38dabf8 100644
--- a/cc/quads/io_surface_draw_quad.h
+++ b/cc/quads/io_surface_draw_quad.h
@@ -45,10 +45,11 @@ class CC_EXPORT IOSurfaceDrawQuad : public DrawQuad {
OVERRIDE;
static const IOSurfaceDrawQuad* MaterialCast(const DrawQuad*);
+
private:
IOSurfaceDrawQuad();
};
-}
+} // namespace cc
#endif // CC_QUADS_IO_SURFACE_DRAW_QUAD_H_
diff --git a/cc/quads/render_pass.h b/cc/quads/render_pass.h
index 154b02c5..bfd0d83 100644
--- a/cc/quads/render_pass.h
+++ b/cc/quads/render_pass.h
@@ -5,6 +5,7 @@
#ifndef CC_QUADS_RENDER_PASS_H_
#define CC_QUADS_RENDER_PASS_H_
+#include <utility>
#include <vector>
#include "base/basictypes.h"
@@ -45,7 +46,7 @@ class CC_EXPORT RenderPass {
int layer_id;
int index;
- Id(int layer_id, int index) : layer_id(layer_id), index(index) {}
+ Id(int layer_id, int index) : layer_id(layer_id), index(index) {}
bool operator==(const Id& other) const {
return layer_id == other.layer_id && index == other.index;
@@ -105,7 +106,7 @@ class CC_EXPORT RenderPass {
DISALLOW_COPY_AND_ASSIGN(RenderPass);
};
-} // namespace cc
+} // namespace cc
namespace BASE_HASH_NAMESPACE {
#if defined(COMPILER_MSVC)
@@ -124,12 +125,12 @@ struct hash<cc::RenderPass::Id> {
};
#else
#error define a hash function for your compiler
-#endif // COMPILER
+#endif // COMPILER
}
namespace cc {
typedef ScopedPtrVector<RenderPass> RenderPassList;
typedef base::hash_map<RenderPass::Id, RenderPass*> RenderPassIdHashMap;
-} // namespace cc
+} // namespace cc
#endif // CC_QUADS_RENDER_PASS_H_
diff --git a/cc/quads/render_pass_draw_quad.cc b/cc/quads/render_pass_draw_quad.cc
index b4ec337..7ee1a88 100644
--- a/cc/quads/render_pass_draw_quad.cc
+++ b/cc/quads/render_pass_draw_quad.cc
@@ -40,8 +40,8 @@ void RenderPassDrawQuad::SetNew(
const WebKit::WebFilterOperations& filters,
skia::RefPtr<SkImageFilter> filter,
const WebKit::WebFilterOperations& background_filters) {
- DCHECK(render_pass_id.layer_id > 0);
- DCHECK(render_pass_id.index >= 0);
+ DCHECK_GT(render_pass_id.layer_id, 0);
+ DCHECK_GE(render_pass_id.index, 0);
gfx::Rect opaque_rect;
gfx::Rect visible_rect = rect;
@@ -66,8 +66,8 @@ void RenderPassDrawQuad::SetAll(
const WebKit::WebFilterOperations& filters,
skia::RefPtr<SkImageFilter> filter,
const WebKit::WebFilterOperations& background_filters) {
- DCHECK(render_pass_id.layer_id > 0);
- DCHECK(render_pass_id.index >= 0);
+ DCHECK_GT(render_pass_id.layer_id, 0);
+ DCHECK_GE(render_pass_id.index, 0);
DrawQuad::SetAll(shared_quad_state, DrawQuad::RENDER_PASS, rect, opaque_rect,
visible_rect, needs_blending);
@@ -88,7 +88,7 @@ void RenderPassDrawQuad::IterateResources(
const RenderPassDrawQuad* RenderPassDrawQuad::MaterialCast(
const DrawQuad* quad) {
- DCHECK(quad->material == DrawQuad::RENDER_PASS);
+ DCHECK_EQ(quad->material, DrawQuad::RENDER_PASS);
return static_cast<const RenderPassDrawQuad*>(quad);
}
diff --git a/cc/quads/render_pass_draw_quad.h b/cc/quads/render_pass_draw_quad.h
index ca79755..303750f 100644
--- a/cc/quads/render_pass_draw_quad.h
+++ b/cc/quads/render_pass_draw_quad.h
@@ -74,6 +74,6 @@ class CC_EXPORT RenderPassDrawQuad : public DrawQuad {
RenderPassDrawQuad();
};
-}
+} // namespace cc
#endif // CC_QUADS_RENDER_PASS_DRAW_QUAD_H_
diff --git a/cc/quads/render_pass_unittest.cc b/cc/quads/render_pass_unittest.cc
index e487784..f2271b5 100644
--- a/cc/quads/render_pass_unittest.cc
+++ b/cc/quads/render_pass_unittest.cc
@@ -19,7 +19,8 @@ namespace cc {
namespace {
struct RenderPassSize {
- // If you add a new field to this class, make sure to add it to the copy() tests.
+ // If you add a new field to this class, make sure to add it to the
+ // Copy() tests.
RenderPass::Id id;
QuadList quad_list;
SharedQuadStateList shared_quad_state_list;
diff --git a/cc/quads/shared_quad_state.h b/cc/quads/shared_quad_state.h
index c7c1bc0..384fa81 100644
--- a/cc/quads/shared_quad_state.h
+++ b/cc/quads/shared_quad_state.h
@@ -39,6 +39,6 @@ class CC_EXPORT SharedQuadState {
SharedQuadState();
};
-}
+} // namespace cc
#endif // CC_QUADS_SHARED_QUAD_STATE_H_
diff --git a/cc/quads/solid_color_draw_quad.h b/cc/quads/solid_color_draw_quad.h
index a300063..690f816 100644
--- a/cc/quads/solid_color_draw_quad.h
+++ b/cc/quads/solid_color_draw_quad.h
@@ -33,10 +33,11 @@ class CC_EXPORT SolidColorDrawQuad : public DrawQuad {
OVERRIDE;
static const SolidColorDrawQuad* MaterialCast(const DrawQuad*);
+
private:
SolidColorDrawQuad();
};
-}
+} // namespace cc
#endif // CC_QUADS_SOLID_COLOR_DRAW_QUAD_H_
diff --git a/cc/quads/stream_video_draw_quad.h b/cc/quads/stream_video_draw_quad.h
index bfbcdf4..e6a46b4 100644
--- a/cc/quads/stream_video_draw_quad.h
+++ b/cc/quads/stream_video_draw_quad.h
@@ -37,10 +37,11 @@ class CC_EXPORT StreamVideoDrawQuad : public DrawQuad {
OVERRIDE;
static const StreamVideoDrawQuad* MaterialCast(const DrawQuad*);
+
private:
StreamVideoDrawQuad();
};
-}
+} // namespace cc
#endif // CC_QUADS_STREAM_VIDEO_DRAW_QUAD_H_
diff --git a/cc/quads/texture_draw_quad.h b/cc/quads/texture_draw_quad.h
index c888eca..0b35568 100644
--- a/cc/quads/texture_draw_quad.h
+++ b/cc/quads/texture_draw_quad.h
@@ -51,10 +51,11 @@ class CC_EXPORT TextureDrawQuad : public DrawQuad {
static const TextureDrawQuad* MaterialCast(const DrawQuad*);
bool PerformClipping();
+
private:
TextureDrawQuad();
};
-}
+} // namespace cc
#endif // CC_QUADS_TEXTURE_DRAW_QUAD_H_
diff --git a/cc/quads/tile_draw_quad.h b/cc/quads/tile_draw_quad.h
index 74c3698..e39a281 100644
--- a/cc/quads/tile_draw_quad.h
+++ b/cc/quads/tile_draw_quad.h
@@ -45,10 +45,11 @@ class CC_EXPORT TileDrawQuad : public DrawQuad {
OVERRIDE;
static const TileDrawQuad* MaterialCast(const DrawQuad*);
+
private:
TileDrawQuad();
};
-}
+} // namespace cc
#endif // CC_QUADS_TILE_DRAW_QUAD_H_
diff --git a/cc/quads/yuv_video_draw_quad.h b/cc/quads/yuv_video_draw_quad.h
index dde1459..8885a5a 100644
--- a/cc/quads/yuv_video_draw_quad.h
+++ b/cc/quads/yuv_video_draw_quad.h
@@ -46,10 +46,11 @@ class CC_EXPORT YUVVideoDrawQuad : public DrawQuad {
OVERRIDE;
static const YUVVideoDrawQuad* MaterialCast(const DrawQuad*);
+
private:
YUVVideoDrawQuad();
};
-}
+} // namespace cc
#endif // CC_QUADS_YUV_VIDEO_DRAW_QUAD_H_
diff --git a/cc/resources/caching_bitmap_content_layer_updater.cc b/cc/resources/caching_bitmap_content_layer_updater.cc
index f6bb426..78f6097 100644
--- a/cc/resources/caching_bitmap_content_layer_updater.cc
+++ b/cc/resources/caching_bitmap_content_layer_updater.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "caching_bitmap_content_layer_updater.h"
+#include "cc/resources/caching_bitmap_content_layer_updater.h"
#include "base/logging.h"
#include "cc/resources/layer_painter.h"
@@ -38,7 +38,7 @@ void CachingBitmapContentLayerUpdater::PrepareToUpdate(
const SkBitmap& new_bitmap = canvas_->getDevice()->accessBitmap(false);
SkAutoLockPixels lock(new_bitmap);
- DCHECK(new_bitmap.bytesPerPixel() > 0);
+ DCHECK_GT(new_bitmap.bytesPerPixel(), 0);
pixels_did_change_ = new_bitmap.config() != cached_bitmap_.config() ||
new_bitmap.height() != cached_bitmap_.height() ||
new_bitmap.width() != cached_bitmap_.width() ||
diff --git a/cc/resources/image_layer_updater.cc b/cc/resources/image_layer_updater.cc
index 4422bc4..378490d 100644
--- a/cc/resources/image_layer_updater.cc
+++ b/cc/resources/image_layer_updater.cc
@@ -57,4 +57,4 @@ void ImageLayerUpdater::UpdateTexture(ResourceUpdateQueue* queue,
queue->AppendFullUpload(upload);
}
-}
+} // namespace cc
diff --git a/cc/resources/layer_quad.h b/cc/resources/layer_quad.h
index 9c5a116..8098c20 100644
--- a/cc/resources/layer_quad.h
+++ b/cc/resources/layer_quad.h
@@ -73,16 +73,25 @@ class CC_EXPORT LayerQuad {
const Edge& top,
const Edge& right,
const Edge& bottom);
- LayerQuad(const gfx::QuadF& quad);
+ explicit LayerQuad(const gfx::QuadF& quad);
Edge left() const { return left_; }
Edge top() const { return top_; }
Edge right() const { return right_; }
Edge bottom() const { return bottom_; }
- void InflateX(float dx) { left_.move_z(dx); right_.move_z(dx); }
- void InflateY(float dy) { top_.move_z(dy); bottom_.move_z(dy); }
- void Inflate(float d) { InflateX(d); InflateY(d); }
+ void InflateX(float dx) {
+ left_.move_z(dx);
+ right_.move_z(dx);
+ }
+ void InflateY(float dy) {
+ top_.move_z(dy);
+ bottom_.move_z(dy);
+ }
+ void Inflate(float d) {
+ InflateX(d);
+ InflateY(d);
+ }
void InflateAntiAliasingDistance() {
Inflate(kAntiAliasingInflateDistance);
}
@@ -100,6 +109,6 @@ class CC_EXPORT LayerQuad {
DISALLOW_COPY_AND_ASSIGN(LayerQuad);
};
-}
+} // namespace cc
#endif // CC_RESOURCES_LAYER_QUAD_H_
diff --git a/cc/resources/layer_tiling_data.cc b/cc/resources/layer_tiling_data.cc
index eda05e3..0356985 100644
--- a/cc/resources/layer_tiling_data.cc
+++ b/cc/resources/layer_tiling_data.cc
@@ -4,6 +4,8 @@
#include "cc/resources/layer_tiling_data.h"
+#include <vector>
+
#include "base/logging.h"
namespace cc {
diff --git a/cc/resources/layer_tiling_data.h b/cc/resources/layer_tiling_data.h
index 255bbdc8..74cea06 100644
--- a/cc/resources/layer_tiling_data.h
+++ b/cc/resources/layer_tiling_data.h
@@ -5,6 +5,8 @@
#ifndef CC_RESOURCES_LAYER_TILING_DATA_H_
#define CC_RESOURCES_LAYER_TILING_DATA_H_
+#include <utility>
+
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "cc/base/cc_export.h"
diff --git a/cc/resources/managed_memory_policy.cc b/cc/resources/managed_memory_policy.cc
index ab4c091..3571d7a 100644
--- a/cc/resources/managed_memory_policy.cc
+++ b/cc/resources/managed_memory_policy.cc
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "managed_memory_policy.h"
+#include "cc/resources/managed_memory_policy.h"
#include "base/logging.h"
-#include "priority_calculator.h"
+#include "cc/resources/priority_calculator.h"
namespace cc {
diff --git a/cc/resources/managed_memory_policy.h b/cc/resources/managed_memory_policy.h
index 5b0787a..dd8ac25 100644
--- a/cc/resources/managed_memory_policy.h
+++ b/cc/resources/managed_memory_policy.h
@@ -19,7 +19,7 @@ struct CC_EXPORT ManagedMemoryPolicy {
CUTOFF_ALLOW_EVERYTHING,
};
- ManagedMemoryPolicy(size_t bytes_limit_when_visible);
+ explicit ManagedMemoryPolicy(size_t bytes_limit_when_visible);
ManagedMemoryPolicy(size_t bytes_limit_when_visible,
PriorityCutoff priority_cutoff_when_visible,
size_t bytes_limit_when_not_visible,
diff --git a/cc/resources/managed_tile_state.cc b/cc/resources/managed_tile_state.cc
index fe8b192..f428f95 100644
--- a/cc/resources/managed_tile_state.cc
+++ b/cc/resources/managed_tile_state.cc
@@ -4,6 +4,8 @@
#include "cc/resources/managed_tile_state.h"
+#include <limits>
+
#include "cc/base/math_util.h"
namespace cc {
diff --git a/cc/resources/memory_history.cc b/cc/resources/memory_history.cc
index 13b71c7..a2f8b6e 100644
--- a/cc/resources/memory_history.cc
+++ b/cc/resources/memory_history.cc
@@ -4,6 +4,8 @@
#include "cc/resources/memory_history.h"
+#include <limits>
+
namespace cc {
// static
diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc
index 701d8ac..d3ddc53 100644
--- a/cc/resources/picture.cc
+++ b/cc/resources/picture.cc
@@ -30,8 +30,7 @@ class DisableLCDTextFilter : public SkDrawFilter {
return true;
}
};
-
-}
+} // namespace
namespace cc {
@@ -169,7 +168,7 @@ void Picture::GatherPixelRefs(const gfx::Rect& layer_rect,
}
SkPixelRef** refs = reinterpret_cast<SkPixelRef**>(data);
- for (unsigned int i = 0; i < pixel_refs->size() / sizeof(SkPixelRef*); ++i) {
+ for (size_t i = 0; i < pixel_refs->size() / sizeof(*refs); ++i) {
if (*refs && (*refs)->getURI() && !strncmp(
(*refs)->getURI(), kLabelLazyDecoded, 4)) {
pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs));
diff --git a/cc/resources/picture.h b/cc/resources/picture.h
index 3cb6791..8598fbf 100644
--- a/cc/resources/picture.h
+++ b/cc/resources/picture.h
@@ -60,7 +60,7 @@ class CC_EXPORT Picture
std::list<skia::LazyPixelRef*>& pixel_ref_list);
private:
- Picture(gfx::Rect layer_rect);
+ explicit Picture(gfx::Rect layer_rect);
// This constructor assumes SkPicture is already ref'd and transfers
// ownership to this picture.
Picture(const skia::RefPtr<SkPicture>&,
diff --git a/cc/resources/picture_layer_tiling.cc b/cc/resources/picture_layer_tiling.cc
index b1fa9a8..fd4ce83 100644
--- a/cc/resources/picture_layer_tiling.cc
+++ b/cc/resources/picture_layer_tiling.cc
@@ -4,6 +4,7 @@
#include "cc/resources/picture_layer_tiling.h"
+#include <algorithm>
#include <cmath>
#include "base/debug/trace_event.h"
@@ -131,7 +132,6 @@ void PictureLayerTiling::Invalidate(const Region& layer_invalidation) {
for (Region::Iterator region_iter(layer_invalidation);
region_iter.has_rect();
region_iter.next()) {
-
gfx::Rect layer_invalidation = region_iter.rect();
layer_invalidation.Intersect(gfx::Rect(layer_bounds_));
gfx::Rect rect =
@@ -522,7 +522,7 @@ gfx::Rect PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy(
gfx::Rect bounding_rect) {
DCHECK(!starting_rect.IsEmpty());
DCHECK(!bounding_rect.IsEmpty());
- DCHECK(target_area > 0);
+ DCHECK_GT(target_area, 0);
gfx::Rect rect = IntersectRects(starting_rect, bounding_rect);
if (rect.IsEmpty())
diff --git a/cc/resources/picture_layer_tiling.h b/cc/resources/picture_layer_tiling.h
index 7a71fa8..bc61321 100644
--- a/cc/resources/picture_layer_tiling.h
+++ b/cc/resources/picture_layer_tiling.h
@@ -5,6 +5,9 @@
#ifndef CC_RESOURCES_PICTURE_LAYER_TILING_H_
#define CC_RESOURCES_PICTURE_LAYER_TILING_H_
+#include <utility>
+#include <vector>
+
#include "base/basictypes.h"
#include "base/hash_tables.h"
#include "base/memory/scoped_ptr.h"
@@ -31,6 +34,9 @@ class PictureLayerTilingClient {
virtual gfx::Size CalculateTileSize(
gfx::Size current_tile_size,
gfx::Size content_bounds) = 0;
+
+ protected:
+ virtual ~PictureLayerTilingClient() {}
};
class CC_EXPORT PictureLayerTiling {
@@ -145,7 +151,7 @@ class CC_EXPORT PictureLayerTiling {
typedef std::pair<int, int> TileMapKey;
typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap;
- PictureLayerTiling(float contents_scale);
+ explicit PictureLayerTiling(float contents_scale);
Tile* TileAt(int, int) const;
void CreateTilesFromContentRect(gfx::Rect layer_rect);
void CreateTile(int i, int j);
diff --git a/cc/resources/picture_layer_tiling_set.h b/cc/resources/picture_layer_tiling_set.h
index 5e4d92f..901bb9b 100644
--- a/cc/resources/picture_layer_tiling_set.h
+++ b/cc/resources/picture_layer_tiling_set.h
@@ -29,7 +29,7 @@ class CC_EXPORT PictureLayerTilingSet {
void SetLayerBounds(gfx::Size layer_bounds);
gfx::Size LayerBounds() const;
- void Invalidate(const Region& layer_invalidation);
+ void Invalidate(const Region& layer_invalidation);
PictureLayerTiling* AddTiling(float contents_scale);
size_t num_tilings() const { return tilings_.size(); }
diff --git a/cc/resources/picture_layer_tiling_set_unittest.cc b/cc/resources/picture_layer_tiling_set_unittest.cc
index cb38d1b..ce10998 100644
--- a/cc/resources/picture_layer_tiling_set_unittest.cc
+++ b/cc/resources/picture_layer_tiling_set_unittest.cc
@@ -4,6 +4,8 @@
#include "cc/resources/picture_layer_tiling_set.h"
+#include <vector>
+
#include "cc/resources/resource_pool.h"
#include "cc/resources/resource_provider.h"
#include "cc/test/fake_output_surface.h"
diff --git a/cc/resources/picture_layer_tiling_unittest.cc b/cc/resources/picture_layer_tiling_unittest.cc
index fd69926..4f3c656 100644
--- a/cc/resources/picture_layer_tiling_unittest.cc
+++ b/cc/resources/picture_layer_tiling_unittest.cc
@@ -45,7 +45,6 @@ class PictureLayerTilingIteratorTest : public testing::Test {
request_rect);
iter;
++iter) {
-
// Geometry cannot overlap previous geometry at all
gfx::Rect geometry = iter.geometry_rect();
EXPECT_TRUE(expect_rect.Contains(geometry));
diff --git a/cc/resources/picture_pile.cc b/cc/resources/picture_pile.cc
index e57a103..85a2e9b 100644
--- a/cc/resources/picture_pile.cc
+++ b/cc/resources/picture_pile.cc
@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "cc/resources/picture_pile.h"
+
#include <algorithm>
+#include <vector>
#include "cc/base/region.h"
-#include "cc/resources/picture_pile.h"
#include "cc/resources/picture_pile_impl.h"
namespace {
@@ -112,7 +114,7 @@ void PicturePile::Update(
class FullyContainedPredicate {
public:
- FullyContainedPredicate(gfx::Rect rect) : layer_rect_(rect) {}
+ explicit FullyContainedPredicate(gfx::Rect rect) : layer_rect_(rect) {}
bool operator()(const scoped_refptr<Picture>& picture) {
return layer_rect_.Contains(picture->LayerRect());
}
diff --git a/cc/resources/picture_pile_base.cc b/cc/resources/picture_pile_base.cc
index f650f1c..4bb99af 100644
--- a/cc/resources/picture_pile_base.cc
+++ b/cc/resources/picture_pile_base.cc
@@ -4,6 +4,9 @@
#include "cc/resources/picture_pile_base.h"
+#include <algorithm>
+#include <vector>
+
#include "base/logging.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/rect_conversions.h"
diff --git a/cc/resources/picture_pile_base.h b/cc/resources/picture_pile_base.h
index 7014107..35b3f11 100644
--- a/cc/resources/picture_pile_base.h
+++ b/cc/resources/picture_pile_base.h
@@ -6,6 +6,7 @@
#define CC_RESOURCES_PICTURE_PILE_BASE_H_
#include <list>
+#include <utility>
#include "base/hash_tables.h"
#include "base/memory/ref_counted.h"
@@ -21,7 +22,7 @@ namespace cc {
class CC_EXPORT PicturePileBase : public base::RefCounted<PicturePileBase> {
public:
PicturePileBase();
- PicturePileBase(const PicturePileBase* other);
+ explicit PicturePileBase(const PicturePileBase* other);
PicturePileBase(const PicturePileBase* other, unsigned thread_index);
void Resize(gfx::Size size);
diff --git a/cc/resources/picture_pile_impl.cc b/cc/resources/picture_pile_impl.cc
index 76e6d56..4e425e5 100644
--- a/cc/resources/picture_pile_impl.cc
+++ b/cc/resources/picture_pile_impl.cc
@@ -249,8 +249,8 @@ void PicturePileImpl::AnalyzeInRect(const gfx::Rect& content_rect,
canvas.consumeLazyPixelRefs(&analysis->lazy_pixel_refs);
}
-PicturePileImpl::Analysis::Analysis() :
- is_solid_color(false),
+PicturePileImpl::Analysis::Analysis()
+ : is_solid_color(false),
is_transparent(false),
is_cheap_to_raster(false) {
}
diff --git a/cc/resources/picture_pile_impl.h b/cc/resources/picture_pile_impl.h
index 6584d7f..34364bd 100644
--- a/cc/resources/picture_pile_impl.h
+++ b/cc/resources/picture_pile_impl.h
@@ -7,6 +7,7 @@
#include <list>
#include <map>
+#include <vector>
#include "cc/base/cc_export.h"
#include "cc/resources/picture_pile_base.h"
@@ -62,7 +63,7 @@ class CC_EXPORT PicturePileImpl : public PicturePileBase {
protected:
friend class PicturePile;
- PicturePileImpl(bool enable_lcd_text);
+ explicit PicturePileImpl(bool enable_lcd_text);
PicturePileImpl(const PicturePileBase* other, bool enable_lcd_text);
virtual ~PicturePileImpl();
diff --git a/cc/resources/prioritized_resource_manager.cc b/cc/resources/prioritized_resource_manager.cc
index 2c406df..9659a4f 100644
--- a/cc/resources/prioritized_resource_manager.cc
+++ b/cc/resources/prioritized_resource_manager.cc
@@ -416,7 +416,6 @@ void PrioritizedResourceManager::RegisterTexture(PrioritizedResource* texture) {
texture->set_manager_internal(this);
textures_.insert(texture);
-
}
void PrioritizedResourceManager::UnregisterTexture(
diff --git a/cc/resources/prioritized_resource_manager.h b/cc/resources/prioritized_resource_manager.h
index b1f013d..51571fe 100644
--- a/cc/resources/prioritized_resource_manager.h
+++ b/cc/resources/prioritized_resource_manager.h
@@ -47,7 +47,7 @@ class CC_EXPORT PrioritizedResourceManager {
typedef std::list<PrioritizedResource::Backing*> BackingList;
- // TODO (epenner): (http://crbug.com/137094) This 64MB default is a straggler
+ // TODO(epenner): (http://crbug.com/137094) This 64MB default is a straggler
// from the old texture manager and is just to give us a default memory
// allocation before we get a callback from the GPU memory manager. We
// should probaby either:
@@ -171,7 +171,7 @@ class CC_EXPORT PrioritizedResourceManager {
return a < b;
}
- PrioritizedResourceManager(const Proxy* proxy);
+ explicit PrioritizedResourceManager(const Proxy* proxy);
bool EvictBackingsToReduceMemory(size_t limit_bytes,
int priority_cutoff,
diff --git a/cc/resources/prioritized_resource_unittest.cc b/cc/resources/prioritized_resource_unittest.cc
index 98e4985..58a938d 100644
--- a/cc/resources/prioritized_resource_unittest.cc
+++ b/cc/resources/prioritized_resource_unittest.cc
@@ -16,773 +16,776 @@ namespace cc {
class PrioritizedResourceTest : public testing::Test {
public:
- PrioritizedResourceTest()
- : proxy_(scoped_ptr<Thread>(NULL)),
- texture_size_(256, 256),
- texture_format_(GL_RGBA),
- output_surface_(CreateFakeOutputSurface()) {
- DebugScopedSetImplThread impl_thread(&proxy_);
- resource_provider_ = cc::ResourceProvider::Create(output_surface_.get());
- }
-
- virtual ~PrioritizedResourceTest() {
- DebugScopedSetImplThread impl_thread(&proxy_);
- resource_provider_.reset();
- }
-
- size_t TexturesMemorySize(size_t texture_count) {
- return Resource::MemorySizeBytes(texture_size_, texture_format_) *
- texture_count;
- }
-
- scoped_ptr<PrioritizedResourceManager> CreateManager(size_t max_textures) {
- scoped_ptr<PrioritizedResourceManager> manager =
- PrioritizedResourceManager::Create(&proxy_);
- manager->SetMaxMemoryLimitBytes(TexturesMemorySize(max_textures));
- return manager.Pass();
- }
-
- bool ValidateTexture(scoped_ptr<PrioritizedResource>& texture,
- bool request_late) {
- ResourceManagerAssertInvariants(texture->resource_manager());
- if (request_late)
- texture->RequestLate();
- ResourceManagerAssertInvariants(texture->resource_manager());
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- bool success = texture->can_acquire_backing_texture();
- if (success)
- texture->AcquireBackingTexture(ResourceProvider());
- return success;
- }
-
- void PrioritizeTexturesAndBackings(
- PrioritizedResourceManager* resource_manager) {
- resource_manager->PrioritizeTextures();
- ResourceManagerUpdateBackingsPriorities(resource_manager);
- }
-
- void ResourceManagerUpdateBackingsPriorities(
- PrioritizedResourceManager* resource_manager) {
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->PushTexturePrioritiesToBackings();
- }
-
- cc::ResourceProvider* ResourceProvider() { return resource_provider_.get(); }
-
- void ResourceManagerAssertInvariants(
- PrioritizedResourceManager* resource_manager) {
+ PrioritizedResourceTest()
+ : proxy_(scoped_ptr<Thread>(NULL)),
+ texture_size_(256, 256),
+ texture_format_(GL_RGBA),
+ output_surface_(CreateFakeOutputSurface()) {
+ DebugScopedSetImplThread impl_thread(&proxy_);
+ resource_provider_ = cc::ResourceProvider::Create(output_surface_.get());
+ }
+
+ virtual ~PrioritizedResourceTest() {
+ DebugScopedSetImplThread impl_thread(&proxy_);
+ resource_provider_.reset();
+ }
+
+ size_t TexturesMemorySize(size_t texture_count) {
+ return Resource::MemorySizeBytes(texture_size_, texture_format_) *
+ texture_count;
+ }
+
+ scoped_ptr<PrioritizedResourceManager> CreateManager(size_t max_textures) {
+ scoped_ptr<PrioritizedResourceManager> manager =
+ PrioritizedResourceManager::Create(&proxy_);
+ manager->SetMaxMemoryLimitBytes(TexturesMemorySize(max_textures));
+ return manager.Pass();
+ }
+
+ bool ValidateTexture(PrioritizedResource* texture,
+ bool request_late) {
+ ResourceManagerAssertInvariants(texture->resource_manager());
+ if (request_late)
+ texture->RequestLate();
+ ResourceManagerAssertInvariants(texture->resource_manager());
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ bool success = texture->can_acquire_backing_texture();
+ if (success)
+ texture->AcquireBackingTexture(ResourceProvider());
+ return success;
+ }
+
+ void PrioritizeTexturesAndBackings(
+ PrioritizedResourceManager* resource_manager) {
+ resource_manager->PrioritizeTextures();
+ ResourceManagerUpdateBackingsPriorities(resource_manager);
+ }
+
+ void ResourceManagerUpdateBackingsPriorities(
+ PrioritizedResourceManager* resource_manager) {
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->PushTexturePrioritiesToBackings();
+ }
+
+ cc::ResourceProvider* ResourceProvider() { return resource_provider_.get(); }
+
+ void ResourceManagerAssertInvariants(
+ PrioritizedResourceManager* resource_manager) {
#ifndef NDEBUG
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->AssertInvariants();
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->AssertInvariants();
#endif
- }
+ }
- bool TextureBackingIsAbovePriorityCutoff(PrioritizedResource* texture) {
- return texture->backing()->
- was_above_priority_cutoff_at_last_priority_update();
- }
+ bool TextureBackingIsAbovePriorityCutoff(PrioritizedResource* texture) {
+ return texture->backing()->
+ was_above_priority_cutoff_at_last_priority_update();
+ }
- size_t EvictedBackingCount(PrioritizedResourceManager* resource_manager) {
- return resource_manager->evicted_backings_.size();
- }
+ size_t EvictedBackingCount(PrioritizedResourceManager* resource_manager) {
+ return resource_manager->evicted_backings_.size();
+ }
protected:
- FakeProxy proxy_;
- const gfx::Size texture_size_;
- const GLenum texture_format_;
- scoped_ptr<OutputSurface> output_surface_;
- scoped_ptr<cc::ResourceProvider> resource_provider_;
+ FakeProxy proxy_;
+ const gfx::Size texture_size_;
+ const GLenum texture_format_;
+ scoped_ptr<OutputSurface> output_surface_;
+ scoped_ptr<cc::ResourceProvider> resource_provider_;
};
namespace {
TEST_F(PrioritizedResourceTest, RequestTextureExceedingMaxLimit) {
- const size_t max_textures = 8;
- scoped_ptr<PrioritizedResourceManager> resource_manager =
- CreateManager(max_textures);
-
- // Create textures for double our memory limit.
- scoped_ptr<PrioritizedResource> textures[max_textures * 2];
-
- for (size_t i = 0; i < max_textures * 2; ++i)
- textures[i] =
- resource_manager->CreateTexture(texture_size_, texture_format_);
-
- // Set decreasing priorities
- for (size_t i = 0; i < max_textures * 2; ++i)
- textures[i]->set_request_priority(100 + i);
-
- // Only lower half should be available.
- PrioritizeTexturesAndBackings(resource_manager.get());
- EXPECT_TRUE(ValidateTexture(textures[0], false));
- EXPECT_TRUE(ValidateTexture(textures[7], false));
- EXPECT_FALSE(ValidateTexture(textures[8], false));
- EXPECT_FALSE(ValidateTexture(textures[15], false));
-
- // Set increasing priorities
- for (size_t i = 0; i < max_textures * 2; ++i)
- textures[i]->set_request_priority(100 - i);
-
- // Only upper half should be available.
- PrioritizeTexturesAndBackings(resource_manager.get());
- EXPECT_FALSE(ValidateTexture(textures[0], false));
- EXPECT_FALSE(ValidateTexture(textures[7], false));
- EXPECT_TRUE(ValidateTexture(textures[8], false));
- EXPECT_TRUE(ValidateTexture(textures[15], false));
-
- EXPECT_EQ(TexturesMemorySize(max_textures),
- resource_manager->MemoryAboveCutoffBytes());
- EXPECT_LE(resource_manager->MemoryUseBytes(),
- resource_manager->MemoryAboveCutoffBytes());
+ const size_t kMaxTextures = 8;
+ scoped_ptr<PrioritizedResourceManager> resource_manager =
+ CreateManager(kMaxTextures);
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ClearAllMemory(ResourceProvider());
+ // Create textures for double our memory limit.
+ scoped_ptr<PrioritizedResource> textures[kMaxTextures * 2];
+
+ for (size_t i = 0; i < kMaxTextures * 2; ++i)
+ textures[i] =
+ resource_manager->CreateTexture(texture_size_, texture_format_);
+
+ // Set decreasing priorities
+ for (size_t i = 0; i < kMaxTextures * 2; ++i)
+ textures[i]->set_request_priority(100 + i);
+
+ // Only lower half should be available.
+ PrioritizeTexturesAndBackings(resource_manager.get());
+ EXPECT_TRUE(ValidateTexture(textures[0].get(), false));
+ EXPECT_TRUE(ValidateTexture(textures[7].get(), false));
+ EXPECT_FALSE(ValidateTexture(textures[8].get(), false));
+ EXPECT_FALSE(ValidateTexture(textures[15].get(), false));
+
+ // Set increasing priorities
+ for (size_t i = 0; i < kMaxTextures * 2; ++i)
+ textures[i]->set_request_priority(100 - i);
+
+ // Only upper half should be available.
+ PrioritizeTexturesAndBackings(resource_manager.get());
+ EXPECT_FALSE(ValidateTexture(textures[0].get(), false));
+ EXPECT_FALSE(ValidateTexture(textures[7].get(), false));
+ EXPECT_TRUE(ValidateTexture(textures[8].get(), false));
+ EXPECT_TRUE(ValidateTexture(textures[15].get(), false));
+
+ EXPECT_EQ(TexturesMemorySize(kMaxTextures),
+ resource_manager->MemoryAboveCutoffBytes());
+ EXPECT_LE(resource_manager->MemoryUseBytes(),
+ resource_manager->MemoryAboveCutoffBytes());
+
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ClearAllMemory(ResourceProvider());
}
TEST_F(PrioritizedResourceTest, ChangeMemoryLimits) {
- const size_t max_textures = 8;
- scoped_ptr<PrioritizedResourceManager> resource_manager =
- CreateManager(max_textures);
- scoped_ptr<PrioritizedResource> textures[max_textures];
-
- for (size_t i = 0; i < max_textures; ++i)
- textures[i] =
- resource_manager->CreateTexture(texture_size_, texture_format_);
- for (size_t i = 0; i < max_textures; ++i)
- textures[i]->set_request_priority(100 + i);
-
- // Set max limit to 8 textures
- resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(8));
- PrioritizeTexturesAndBackings(resource_manager.get());
- for (size_t i = 0; i < max_textures; ++i)
- ValidateTexture(textures[i], false); {
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ReduceMemory(ResourceProvider());
- }
-
- EXPECT_EQ(TexturesMemorySize(8),
- resource_manager->MemoryAboveCutoffBytes());
- EXPECT_LE(resource_manager->MemoryUseBytes(),
- resource_manager->MemoryAboveCutoffBytes());
-
- // Set max limit to 5 textures
- resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(5));
- PrioritizeTexturesAndBackings(resource_manager.get());
- for (size_t i = 0; i < max_textures; ++i)
- EXPECT_EQ(ValidateTexture(textures[i], false), i < 5); {
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ReduceMemory(ResourceProvider());
- }
-
- EXPECT_EQ(TexturesMemorySize(5),
- resource_manager->MemoryAboveCutoffBytes());
- EXPECT_LE(resource_manager->MemoryUseBytes(),
- resource_manager->MemoryAboveCutoffBytes());
-
- // Set max limit to 4 textures
- resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(4));
- PrioritizeTexturesAndBackings(resource_manager.get());
- for (size_t i = 0; i < max_textures; ++i)
- EXPECT_EQ(ValidateTexture(textures[i], false), i < 4); {
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ReduceMemory(ResourceProvider());
- }
-
- EXPECT_EQ(TexturesMemorySize(4),
- resource_manager->MemoryAboveCutoffBytes());
- EXPECT_LE(resource_manager->MemoryUseBytes(),
- resource_manager->MemoryAboveCutoffBytes());
+ const size_t kMaxTextures = 8;
+ scoped_ptr<PrioritizedResourceManager> resource_manager =
+ CreateManager(kMaxTextures);
+ scoped_ptr<PrioritizedResource> textures[kMaxTextures];
+ for (size_t i = 0; i < kMaxTextures; ++i) {
+ textures[i] =
+ resource_manager->CreateTexture(texture_size_, texture_format_);
+ }
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ textures[i]->set_request_priority(100 + i);
+
+ // Set max limit to 8 textures
+ resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(8));
+ PrioritizeTexturesAndBackings(resource_manager.get());
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ ValidateTexture(textures[i].get(), false);
+ {
DebugScopedSetImplThreadAndMainThreadBlocked
impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ClearAllMemory(ResourceProvider());
+ resource_manager->ReduceMemory(ResourceProvider());
+ }
+
+ EXPECT_EQ(TexturesMemorySize(8), resource_manager->MemoryAboveCutoffBytes());
+ EXPECT_LE(resource_manager->MemoryUseBytes(),
+ resource_manager->MemoryAboveCutoffBytes());
+
+ // Set max limit to 5 textures
+ resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(5));
+ PrioritizeTexturesAndBackings(resource_manager.get());
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ EXPECT_EQ(ValidateTexture(textures[i].get(), false), i < 5);
+ {
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ReduceMemory(ResourceProvider());
+ }
+
+ EXPECT_EQ(TexturesMemorySize(5), resource_manager->MemoryAboveCutoffBytes());
+ EXPECT_LE(resource_manager->MemoryUseBytes(),
+ resource_manager->MemoryAboveCutoffBytes());
+
+ // Set max limit to 4 textures
+ resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(4));
+ PrioritizeTexturesAndBackings(resource_manager.get());
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ EXPECT_EQ(ValidateTexture(textures[i].get(), false), i < 4);
+ {
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ReduceMemory(ResourceProvider());
+ }
+
+ EXPECT_EQ(TexturesMemorySize(4), resource_manager->MemoryAboveCutoffBytes());
+ EXPECT_LE(resource_manager->MemoryUseBytes(),
+ resource_manager->MemoryAboveCutoffBytes());
+
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ClearAllMemory(ResourceProvider());
}
TEST_F(PrioritizedResourceTest, ChangePriorityCutoff) {
- const size_t max_textures = 8;
- scoped_ptr<PrioritizedResourceManager> resource_manager =
- CreateManager(max_textures);
- scoped_ptr<PrioritizedResource> textures[max_textures];
-
- for (size_t i = 0; i < max_textures; ++i)
- textures[i] =
- resource_manager->CreateTexture(texture_size_, texture_format_);
- for (size_t i = 0; i < max_textures; ++i)
- textures[i]->set_request_priority(100 + i);
-
- // Set the cutoff to drop two textures. Try to request_late on all textures,
- // and make sure that request_late doesn't work on a texture with equal
- // priority to the cutoff.
- resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(8));
- resource_manager->SetExternalPriorityCutoff(106);
- PrioritizeTexturesAndBackings(resource_manager.get());
- for (size_t i = 0; i < max_textures; ++i)
- EXPECT_EQ(ValidateTexture(textures[i], true), i < 6); {
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ReduceMemory(ResourceProvider());
- }
- EXPECT_EQ(TexturesMemorySize(6),
- resource_manager->MemoryAboveCutoffBytes());
- EXPECT_LE(resource_manager->MemoryUseBytes(),
- resource_manager->MemoryAboveCutoffBytes());
-
- // Set the cutoff to drop two more textures.
- resource_manager->SetExternalPriorityCutoff(104);
- PrioritizeTexturesAndBackings(resource_manager.get());
- for (size_t i = 0; i < max_textures; ++i)
- EXPECT_EQ(ValidateTexture(textures[i], false), i < 4); {
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ReduceMemory(ResourceProvider());
- }
- EXPECT_EQ(TexturesMemorySize(4),
- resource_manager->MemoryAboveCutoffBytes());
-
- // Do a one-time eviction for one more texture based on priority cutoff
- PrioritizedResourceManager::BackingList evicted_backings;
- resource_manager->UnlinkAndClearEvictedBackings(); {
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ReduceMemoryOnImplThread(
- TexturesMemorySize(8), 104, ResourceProvider());
- EXPECT_EQ(0, EvictedBackingCount(resource_manager.get()));
- resource_manager->ReduceMemoryOnImplThread(
- TexturesMemorySize(8), 103, ResourceProvider());
- EXPECT_EQ(1, EvictedBackingCount(resource_manager.get()));
- }
- resource_manager->UnlinkAndClearEvictedBackings();
- EXPECT_EQ(TexturesMemorySize(3), resource_manager->MemoryUseBytes());
-
- // Re-allocate the the texture after the one-time drop.
- PrioritizeTexturesAndBackings(resource_manager.get());
- for (size_t i = 0; i < max_textures; ++i)
- EXPECT_EQ(ValidateTexture(textures[i], false), i < 4); {
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ReduceMemory(ResourceProvider());
- }
- EXPECT_EQ(TexturesMemorySize(4),
- resource_manager->MemoryAboveCutoffBytes());
+ const size_t kMaxTextures = 8;
+ scoped_ptr<PrioritizedResourceManager> resource_manager =
+ CreateManager(kMaxTextures);
+ scoped_ptr<PrioritizedResource> textures[kMaxTextures];
+ for (size_t i = 0; i < kMaxTextures; ++i) {
+ textures[i] =
+ resource_manager->CreateTexture(texture_size_, texture_format_);
+ }
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ textures[i]->set_request_priority(100 + i);
+
+ // Set the cutoff to drop two textures. Try to request_late on all textures,
+ // and make sure that request_late doesn't work on a texture with equal
+ // priority to the cutoff.
+ resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(8));
+ resource_manager->SetExternalPriorityCutoff(106);
+ PrioritizeTexturesAndBackings(resource_manager.get());
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ EXPECT_EQ(ValidateTexture(textures[i].get(), true), i < 6);
+ {
DebugScopedSetImplThreadAndMainThreadBlocked
impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ClearAllMemory(ResourceProvider());
+ resource_manager->ReduceMemory(ResourceProvider());
+ }
+ EXPECT_EQ(TexturesMemorySize(6), resource_manager->MemoryAboveCutoffBytes());
+ EXPECT_LE(resource_manager->MemoryUseBytes(),
+ resource_manager->MemoryAboveCutoffBytes());
+
+ // Set the cutoff to drop two more textures.
+ resource_manager->SetExternalPriorityCutoff(104);
+ PrioritizeTexturesAndBackings(resource_manager.get());
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ EXPECT_EQ(ValidateTexture(textures[i].get(), false), i < 4);
+ {
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ReduceMemory(ResourceProvider());
+ }
+ EXPECT_EQ(TexturesMemorySize(4), resource_manager->MemoryAboveCutoffBytes());
+
+ // Do a one-time eviction for one more texture based on priority cutoff
+ PrioritizedResourceManager::BackingList evicted_backings;
+ resource_manager->UnlinkAndClearEvictedBackings();
+ {
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ReduceMemoryOnImplThread(
+ TexturesMemorySize(8), 104, ResourceProvider());
+ EXPECT_EQ(0, EvictedBackingCount(resource_manager.get()));
+ resource_manager->ReduceMemoryOnImplThread(
+ TexturesMemorySize(8), 103, ResourceProvider());
+ EXPECT_EQ(1, EvictedBackingCount(resource_manager.get()));
+ }
+ resource_manager->UnlinkAndClearEvictedBackings();
+ EXPECT_EQ(TexturesMemorySize(3), resource_manager->MemoryUseBytes());
+
+ // Re-allocate the the texture after the one-time drop.
+ PrioritizeTexturesAndBackings(resource_manager.get());
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ EXPECT_EQ(ValidateTexture(textures[i].get(), false), i < 4);
+ {
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ReduceMemory(ResourceProvider());
+ }
+ EXPECT_EQ(TexturesMemorySize(4), resource_manager->MemoryAboveCutoffBytes());
+
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ClearAllMemory(ResourceProvider());
}
TEST_F(PrioritizedResourceTest, ResourceManagerPartialUpdateTextures) {
- const size_t max_textures = 4;
- const size_t num_textures = 4;
- scoped_ptr<PrioritizedResourceManager> resource_manager =
- CreateManager(max_textures);
- scoped_ptr<PrioritizedResource> textures[num_textures];
- scoped_ptr<PrioritizedResource> more_textures[num_textures];
-
- for (size_t i = 0; i < num_textures; ++i) {
- textures[i] =
- resource_manager->CreateTexture(texture_size_, texture_format_);
- more_textures[i] =
- resource_manager->CreateTexture(texture_size_, texture_format_);
- }
-
- for (size_t i = 0; i < num_textures; ++i)
- textures[i]->set_request_priority(200 + i);
- PrioritizeTexturesAndBackings(resource_manager.get());
-
- // Allocate textures which are currently high priority.
- EXPECT_TRUE(ValidateTexture(textures[0], false));
- EXPECT_TRUE(ValidateTexture(textures[1], false));
- EXPECT_TRUE(ValidateTexture(textures[2], false));
- EXPECT_TRUE(ValidateTexture(textures[3], false));
-
- EXPECT_TRUE(textures[0]->have_backing_texture());
- EXPECT_TRUE(textures[1]->have_backing_texture());
- EXPECT_TRUE(textures[2]->have_backing_texture());
- EXPECT_TRUE(textures[3]->have_backing_texture());
-
- for (size_t i = 0; i < num_textures; ++i)
- more_textures[i]->set_request_priority(100 + i);
- PrioritizeTexturesAndBackings(resource_manager.get());
-
- // Textures are now below cutoff.
- EXPECT_FALSE(ValidateTexture(textures[0], false));
- EXPECT_FALSE(ValidateTexture(textures[1], false));
- EXPECT_FALSE(ValidateTexture(textures[2], false));
- EXPECT_FALSE(ValidateTexture(textures[3], false));
-
- // But they are still valid to use.
- EXPECT_TRUE(textures[0]->have_backing_texture());
- EXPECT_TRUE(textures[1]->have_backing_texture());
- EXPECT_TRUE(textures[2]->have_backing_texture());
- EXPECT_TRUE(textures[3]->have_backing_texture());
-
- // Higher priority textures are finally needed.
- EXPECT_TRUE(ValidateTexture(more_textures[0], false));
- EXPECT_TRUE(ValidateTexture(more_textures[1], false));
- EXPECT_TRUE(ValidateTexture(more_textures[2], false));
- EXPECT_TRUE(ValidateTexture(more_textures[3], false));
-
- // Lower priority have been fully evicted.
- EXPECT_FALSE(textures[0]->have_backing_texture());
- EXPECT_FALSE(textures[1]->have_backing_texture());
- EXPECT_FALSE(textures[2]->have_backing_texture());
- EXPECT_FALSE(textures[3]->have_backing_texture());
-
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ClearAllMemory(ResourceProvider());
+ const size_t kMaxTextures = 4;
+ const size_t kNumTextures = 4;
+ scoped_ptr<PrioritizedResourceManager> resource_manager =
+ CreateManager(kMaxTextures);
+ scoped_ptr<PrioritizedResource> textures[kNumTextures];
+ scoped_ptr<PrioritizedResource> more_textures[kNumTextures];
+
+ for (size_t i = 0; i < kNumTextures; ++i) {
+ textures[i] =
+ resource_manager->CreateTexture(texture_size_, texture_format_);
+ more_textures[i] =
+ resource_manager->CreateTexture(texture_size_, texture_format_);
+ }
+
+ for (size_t i = 0; i < kNumTextures; ++i)
+ textures[i]->set_request_priority(200 + i);
+ PrioritizeTexturesAndBackings(resource_manager.get());
+
+ // Allocate textures which are currently high priority.
+ EXPECT_TRUE(ValidateTexture(textures[0].get(), false));
+ EXPECT_TRUE(ValidateTexture(textures[1].get(), false));
+ EXPECT_TRUE(ValidateTexture(textures[2].get(), false));
+ EXPECT_TRUE(ValidateTexture(textures[3].get(), false));
+
+ EXPECT_TRUE(textures[0]->have_backing_texture());
+ EXPECT_TRUE(textures[1]->have_backing_texture());
+ EXPECT_TRUE(textures[2]->have_backing_texture());
+ EXPECT_TRUE(textures[3]->have_backing_texture());
+
+ for (size_t i = 0; i < kNumTextures; ++i)
+ more_textures[i]->set_request_priority(100 + i);
+ PrioritizeTexturesAndBackings(resource_manager.get());
+
+ // Textures are now below cutoff.
+ EXPECT_FALSE(ValidateTexture(textures[0].get(), false));
+ EXPECT_FALSE(ValidateTexture(textures[1].get(), false));
+ EXPECT_FALSE(ValidateTexture(textures[2].get(), false));
+ EXPECT_FALSE(ValidateTexture(textures[3].get(), false));
+
+ // But they are still valid to use.
+ EXPECT_TRUE(textures[0]->have_backing_texture());
+ EXPECT_TRUE(textures[1]->have_backing_texture());
+ EXPECT_TRUE(textures[2]->have_backing_texture());
+ EXPECT_TRUE(textures[3]->have_backing_texture());
+
+ // Higher priority textures are finally needed.
+ EXPECT_TRUE(ValidateTexture(more_textures[0].get(), false));
+ EXPECT_TRUE(ValidateTexture(more_textures[1].get(), false));
+ EXPECT_TRUE(ValidateTexture(more_textures[2].get(), false));
+ EXPECT_TRUE(ValidateTexture(more_textures[3].get(), false));
+
+ // Lower priority have been fully evicted.
+ EXPECT_FALSE(textures[0]->have_backing_texture());
+ EXPECT_FALSE(textures[1]->have_backing_texture());
+ EXPECT_FALSE(textures[2]->have_backing_texture());
+ EXPECT_FALSE(textures[3]->have_backing_texture());
+
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ClearAllMemory(ResourceProvider());
}
TEST_F(PrioritizedResourceTest, ResourceManagerPrioritiesAreEqual) {
- const size_t max_textures = 16;
- scoped_ptr<PrioritizedResourceManager> resource_manager =
- CreateManager(max_textures);
- scoped_ptr<PrioritizedResource> textures[max_textures];
-
- for (size_t i = 0; i < max_textures; ++i)
- textures[i] =
- resource_manager->CreateTexture(texture_size_, texture_format_);
-
- // All 16 textures have the same priority except 2 higher priority.
- for (size_t i = 0; i < max_textures; ++i)
- textures[i]->set_request_priority(100);
- textures[0]->set_request_priority(99);
- textures[1]->set_request_priority(99);
-
- // Set max limit to 8 textures
- resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(8));
- PrioritizeTexturesAndBackings(resource_manager.get());
-
- // The two high priority textures should be available, others should not.
- for (size_t i = 0; i < 2; ++i)
- EXPECT_TRUE(ValidateTexture(textures[i], false));
- for (size_t i = 2; i < max_textures; ++i)
- EXPECT_FALSE(ValidateTexture(textures[i], false));
- EXPECT_EQ(TexturesMemorySize(2),
- resource_manager->MemoryAboveCutoffBytes());
- EXPECT_LE(resource_manager->MemoryUseBytes(),
- resource_manager->MemoryAboveCutoffBytes());
-
- // Manually reserving textures should only succeed on the higher priority
- // textures, and on remaining textures up to the memory limit.
- for (size_t i = 0; i < 8; i++)
- EXPECT_TRUE(ValidateTexture(textures[i], true));
- for (size_t i = 9; i < max_textures; i++)
- EXPECT_FALSE(ValidateTexture(textures[i], true));
- EXPECT_EQ(TexturesMemorySize(8),
- resource_manager->MemoryAboveCutoffBytes());
- EXPECT_LE(resource_manager->MemoryUseBytes(),
- resource_manager->MemoryAboveCutoffBytes());
+ const size_t kMaxTextures = 16;
+ scoped_ptr<PrioritizedResourceManager> resource_manager =
+ CreateManager(kMaxTextures);
+ scoped_ptr<PrioritizedResource> textures[kMaxTextures];
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ClearAllMemory(ResourceProvider());
+ for (size_t i = 0; i < kMaxTextures; ++i) {
+ textures[i] =
+ resource_manager->CreateTexture(texture_size_, texture_format_);
+ }
+
+ // All 16 textures have the same priority except 2 higher priority.
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ textures[i]->set_request_priority(100);
+ textures[0]->set_request_priority(99);
+ textures[1]->set_request_priority(99);
+
+ // Set max limit to 8 textures
+ resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(8));
+ PrioritizeTexturesAndBackings(resource_manager.get());
+
+ // The two high priority textures should be available, others should not.
+ for (size_t i = 0; i < 2; ++i)
+ EXPECT_TRUE(ValidateTexture(textures[i].get(), false));
+ for (size_t i = 2; i < kMaxTextures; ++i)
+ EXPECT_FALSE(ValidateTexture(textures[i].get(), false));
+ EXPECT_EQ(TexturesMemorySize(2), resource_manager->MemoryAboveCutoffBytes());
+ EXPECT_LE(resource_manager->MemoryUseBytes(),
+ resource_manager->MemoryAboveCutoffBytes());
+
+ // Manually reserving textures should only succeed on the higher priority
+ // textures, and on remaining textures up to the memory limit.
+ for (size_t i = 0; i < 8; i++)
+ EXPECT_TRUE(ValidateTexture(textures[i].get(), true));
+ for (size_t i = 9; i < kMaxTextures; i++)
+ EXPECT_FALSE(ValidateTexture(textures[i].get(), true));
+ EXPECT_EQ(TexturesMemorySize(8), resource_manager->MemoryAboveCutoffBytes());
+ EXPECT_LE(resource_manager->MemoryUseBytes(),
+ resource_manager->MemoryAboveCutoffBytes());
+
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ClearAllMemory(ResourceProvider());
}
TEST_F(PrioritizedResourceTest, ResourceManagerDestroyedFirst) {
- scoped_ptr<PrioritizedResourceManager> resource_manager = CreateManager(1);
- scoped_ptr<PrioritizedResource> texture =
- resource_manager->CreateTexture(texture_size_, texture_format_);
+ scoped_ptr<PrioritizedResourceManager> resource_manager = CreateManager(1);
+ scoped_ptr<PrioritizedResource> texture =
+ resource_manager->CreateTexture(texture_size_, texture_format_);
- // Texture is initially invalid, but it will become available.
- EXPECT_FALSE(texture->have_backing_texture());
+ // Texture is initially invalid, but it will become available.
+ EXPECT_FALSE(texture->have_backing_texture());
- texture->set_request_priority(100);
- PrioritizeTexturesAndBackings(resource_manager.get());
+ texture->set_request_priority(100);
+ PrioritizeTexturesAndBackings(resource_manager.get());
- EXPECT_TRUE(ValidateTexture(texture, false));
- EXPECT_TRUE(texture->can_acquire_backing_texture());
- EXPECT_TRUE(texture->have_backing_texture()); {
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ClearAllMemory(ResourceProvider());
- }
- resource_manager.reset();
+ EXPECT_TRUE(ValidateTexture(texture.get(), false));
+ EXPECT_TRUE(texture->can_acquire_backing_texture());
+ EXPECT_TRUE(texture->have_backing_texture());
+ {
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ClearAllMemory(ResourceProvider());
+ }
+ resource_manager.reset();
- EXPECT_FALSE(texture->can_acquire_backing_texture());
- EXPECT_FALSE(texture->have_backing_texture());
+ EXPECT_FALSE(texture->can_acquire_backing_texture());
+ EXPECT_FALSE(texture->have_backing_texture());
}
TEST_F(PrioritizedResourceTest, TextureMovedToNewManager) {
- scoped_ptr<PrioritizedResourceManager> resource_manager_one =
- CreateManager(1);
- scoped_ptr<PrioritizedResourceManager> resource_manager_two =
- CreateManager(1);
- scoped_ptr<PrioritizedResource> texture =
- resource_manager_one->CreateTexture(texture_size_, texture_format_);
+ scoped_ptr<PrioritizedResourceManager> resource_manager_one =
+ CreateManager(1);
+ scoped_ptr<PrioritizedResourceManager> resource_manager_two =
+ CreateManager(1);
+ scoped_ptr<PrioritizedResource> texture =
+ resource_manager_one->CreateTexture(texture_size_, texture_format_);
- // Texture is initially invalid, but it will become available.
- EXPECT_FALSE(texture->have_backing_texture());
+ // Texture is initially invalid, but it will become available.
+ EXPECT_FALSE(texture->have_backing_texture());
- texture->set_request_priority(100);
- PrioritizeTexturesAndBackings(resource_manager_one.get());
+ texture->set_request_priority(100);
+ PrioritizeTexturesAndBackings(resource_manager_one.get());
- EXPECT_TRUE(ValidateTexture(texture, false));
- EXPECT_TRUE(texture->can_acquire_backing_texture());
- EXPECT_TRUE(texture->have_backing_texture());
+ EXPECT_TRUE(ValidateTexture(texture.get(), false));
+ EXPECT_TRUE(texture->can_acquire_backing_texture());
+ EXPECT_TRUE(texture->have_backing_texture());
- texture->SetTextureManager(0); {
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager_one->ClearAllMemory(ResourceProvider());
- }
- resource_manager_one.reset();
+ texture->SetTextureManager(NULL);
+ {
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager_one->ClearAllMemory(ResourceProvider());
+ }
+ resource_manager_one.reset();
- EXPECT_FALSE(texture->can_acquire_backing_texture());
- EXPECT_FALSE(texture->have_backing_texture());
+ EXPECT_FALSE(texture->can_acquire_backing_texture());
+ EXPECT_FALSE(texture->have_backing_texture());
- texture->SetTextureManager(resource_manager_two.get());
+ texture->SetTextureManager(resource_manager_two.get());
- PrioritizeTexturesAndBackings(resource_manager_two.get());
+ PrioritizeTexturesAndBackings(resource_manager_two.get());
- EXPECT_TRUE(ValidateTexture(texture, false));
- EXPECT_TRUE(texture->can_acquire_backing_texture());
- EXPECT_TRUE(texture->have_backing_texture());
+ EXPECT_TRUE(ValidateTexture(texture.get(), false));
+ EXPECT_TRUE(texture->can_acquire_backing_texture());
+ EXPECT_TRUE(texture->have_backing_texture());
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager_two->ClearAllMemory(ResourceProvider());
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager_two->ClearAllMemory(ResourceProvider());
}
TEST_F(PrioritizedResourceTest,
RenderSurfacesReduceMemoryAvailableOutsideRootSurface) {
- const size_t max_textures = 8;
- scoped_ptr<PrioritizedResourceManager> resource_manager =
- CreateManager(max_textures);
-
- // Half of the memory is taken by surfaces (with high priority place-holder)
- scoped_ptr<PrioritizedResource> render_surface_place_holder =
+ const size_t kMaxTextures = 8;
+ scoped_ptr<PrioritizedResourceManager> resource_manager =
+ CreateManager(kMaxTextures);
+
+ // Half of the memory is taken by surfaces (with high priority place-holder)
+ scoped_ptr<PrioritizedResource> render_surface_place_holder =
+ resource_manager->CreateTexture(texture_size_, texture_format_);
+ render_surface_place_holder->SetToSelfManagedMemoryPlaceholder(
+ TexturesMemorySize(4));
+ render_surface_place_holder->set_request_priority(
+ PriorityCalculator::RenderSurfacePriority());
+
+ // Create textures to fill our memory limit.
+ scoped_ptr<PrioritizedResource> textures[kMaxTextures];
+
+ for (size_t i = 0; i < kMaxTextures; ++i) {
+ textures[i] =
resource_manager->CreateTexture(texture_size_, texture_format_);
- render_surface_place_holder->SetToSelfManagedMemoryPlaceholder(
- TexturesMemorySize(4));
- render_surface_place_holder->set_request_priority(
- PriorityCalculator::RenderSurfacePriority());
-
- // Create textures to fill our memory limit.
- scoped_ptr<PrioritizedResource> textures[max_textures];
-
- for (size_t i = 0; i < max_textures; ++i)
- textures[i] =
- resource_manager->CreateTexture(texture_size_, texture_format_);
-
- // Set decreasing non-visible priorities outside root surface.
- for (size_t i = 0; i < max_textures; ++i)
- textures[i]->set_request_priority(100 + i);
-
- // Only lower half should be available.
- PrioritizeTexturesAndBackings(resource_manager.get());
- EXPECT_TRUE(ValidateTexture(textures[0], false));
- EXPECT_TRUE(ValidateTexture(textures[3], false));
- EXPECT_FALSE(ValidateTexture(textures[4], false));
- EXPECT_FALSE(ValidateTexture(textures[7], false));
-
- // Set increasing non-visible priorities outside root surface.
- for (size_t i = 0; i < max_textures; ++i)
- textures[i]->set_request_priority(100 - i);
-
- // Only upper half should be available.
- PrioritizeTexturesAndBackings(resource_manager.get());
- EXPECT_FALSE(ValidateTexture(textures[0], false));
- EXPECT_FALSE(ValidateTexture(textures[3], false));
- EXPECT_TRUE(ValidateTexture(textures[4], false));
- EXPECT_TRUE(ValidateTexture(textures[7], false));
-
- EXPECT_EQ(TexturesMemorySize(4),
- resource_manager->MemoryAboveCutoffBytes());
- EXPECT_EQ(TexturesMemorySize(4),
- resource_manager->MemoryForSelfManagedTextures());
- EXPECT_LE(resource_manager->MemoryUseBytes(),
- resource_manager->MemoryAboveCutoffBytes());
-
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ClearAllMemory(ResourceProvider());
+ }
+
+ // Set decreasing non-visible priorities outside root surface.
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ textures[i]->set_request_priority(100 + i);
+
+ // Only lower half should be available.
+ PrioritizeTexturesAndBackings(resource_manager.get());
+ EXPECT_TRUE(ValidateTexture(textures[0].get(), false));
+ EXPECT_TRUE(ValidateTexture(textures[3].get(), false));
+ EXPECT_FALSE(ValidateTexture(textures[4].get(), false));
+ EXPECT_FALSE(ValidateTexture(textures[7].get(), false));
+
+ // Set increasing non-visible priorities outside root surface.
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ textures[i]->set_request_priority(100 - i);
+
+ // Only upper half should be available.
+ PrioritizeTexturesAndBackings(resource_manager.get());
+ EXPECT_FALSE(ValidateTexture(textures[0].get(), false));
+ EXPECT_FALSE(ValidateTexture(textures[3].get(), false));
+ EXPECT_TRUE(ValidateTexture(textures[4].get(), false));
+ EXPECT_TRUE(ValidateTexture(textures[7].get(), false));
+
+ EXPECT_EQ(TexturesMemorySize(4), resource_manager->MemoryAboveCutoffBytes());
+ EXPECT_EQ(TexturesMemorySize(4),
+ resource_manager->MemoryForSelfManagedTextures());
+ EXPECT_LE(resource_manager->MemoryUseBytes(),
+ resource_manager->MemoryAboveCutoffBytes());
+
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ClearAllMemory(ResourceProvider());
}
TEST_F(PrioritizedResourceTest,
RenderSurfacesReduceMemoryAvailableForRequestLate) {
- const size_t max_textures = 8;
- scoped_ptr<PrioritizedResourceManager> resource_manager =
- CreateManager(max_textures);
-
- // Half of the memory is taken by surfaces (with high priority place-holder)
- scoped_ptr<PrioritizedResource> render_surface_place_holder =
+ const size_t kMaxTextures = 8;
+ scoped_ptr<PrioritizedResourceManager> resource_manager =
+ CreateManager(kMaxTextures);
+
+ // Half of the memory is taken by surfaces (with high priority place-holder)
+ scoped_ptr<PrioritizedResource> render_surface_place_holder =
+ resource_manager->CreateTexture(texture_size_, texture_format_);
+ render_surface_place_holder->SetToSelfManagedMemoryPlaceholder(
+ TexturesMemorySize(4));
+ render_surface_place_holder->set_request_priority(
+ PriorityCalculator::RenderSurfacePriority());
+
+ // Create textures to fill our memory limit.
+ scoped_ptr<PrioritizedResource> textures[kMaxTextures];
+
+ for (size_t i = 0; i < kMaxTextures; ++i) {
+ textures[i] =
resource_manager->CreateTexture(texture_size_, texture_format_);
- render_surface_place_holder->SetToSelfManagedMemoryPlaceholder(
- TexturesMemorySize(4));
- render_surface_place_holder->set_request_priority(
- PriorityCalculator::RenderSurfacePriority());
-
- // Create textures to fill our memory limit.
- scoped_ptr<PrioritizedResource> textures[max_textures];
-
- for (size_t i = 0; i < max_textures; ++i)
- textures[i] =
- resource_manager->CreateTexture(texture_size_, texture_format_);
-
- // Set equal priorities.
- for (size_t i = 0; i < max_textures; ++i)
- textures[i]->set_request_priority(100);
-
- // The first four to be requested late will be available.
- PrioritizeTexturesAndBackings(resource_manager.get());
- for (unsigned i = 0; i < max_textures; ++i)
- EXPECT_FALSE(ValidateTexture(textures[i], false));
- for (unsigned i = 0; i < max_textures; i += 2)
- EXPECT_TRUE(ValidateTexture(textures[i], true));
- for (unsigned i = 1; i < max_textures; i += 2)
- EXPECT_FALSE(ValidateTexture(textures[i], true));
-
- EXPECT_EQ(TexturesMemorySize(4),
- resource_manager->MemoryAboveCutoffBytes());
- EXPECT_EQ(TexturesMemorySize(4),
- resource_manager->MemoryForSelfManagedTextures());
- EXPECT_LE(resource_manager->MemoryUseBytes(),
- resource_manager->MemoryAboveCutoffBytes());
-
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ClearAllMemory(ResourceProvider());
+ }
+
+ // Set equal priorities.
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ textures[i]->set_request_priority(100);
+
+ // The first four to be requested late will be available.
+ PrioritizeTexturesAndBackings(resource_manager.get());
+ for (unsigned i = 0; i < kMaxTextures; ++i)
+ EXPECT_FALSE(ValidateTexture(textures[i].get(), false));
+ for (unsigned i = 0; i < kMaxTextures; i += 2)
+ EXPECT_TRUE(ValidateTexture(textures[i].get(), true));
+ for (unsigned i = 1; i < kMaxTextures; i += 2)
+ EXPECT_FALSE(ValidateTexture(textures[i].get(), true));
+
+ EXPECT_EQ(TexturesMemorySize(4), resource_manager->MemoryAboveCutoffBytes());
+ EXPECT_EQ(TexturesMemorySize(4),
+ resource_manager->MemoryForSelfManagedTextures());
+ EXPECT_LE(resource_manager->MemoryUseBytes(),
+ resource_manager->MemoryAboveCutoffBytes());
+
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ClearAllMemory(ResourceProvider());
}
TEST_F(PrioritizedResourceTest,
WhenRenderSurfaceNotAvailableTexturesAlsoNotAvailable) {
- const size_t max_textures = 8;
- scoped_ptr<PrioritizedResourceManager> resource_manager =
- CreateManager(max_textures);
-
- // Half of the memory is taken by surfaces (with high priority place-holder)
- scoped_ptr<PrioritizedResource> render_surface_place_holder =
+ const size_t kMaxTextures = 8;
+ scoped_ptr<PrioritizedResourceManager> resource_manager =
+ CreateManager(kMaxTextures);
+
+ // Half of the memory is taken by surfaces (with high priority place-holder)
+ scoped_ptr<PrioritizedResource> render_surface_place_holder =
+ resource_manager->CreateTexture(texture_size_, texture_format_);
+ render_surface_place_holder->SetToSelfManagedMemoryPlaceholder(
+ TexturesMemorySize(4));
+ render_surface_place_holder->set_request_priority(
+ PriorityCalculator::RenderSurfacePriority());
+
+ // Create textures to fill our memory limit.
+ scoped_ptr<PrioritizedResource> textures[kMaxTextures];
+
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ textures[i] =
resource_manager->CreateTexture(texture_size_, texture_format_);
- render_surface_place_holder->SetToSelfManagedMemoryPlaceholder(
- TexturesMemorySize(4));
- render_surface_place_holder->set_request_priority(
- PriorityCalculator::RenderSurfacePriority());
-
- // Create textures to fill our memory limit.
- scoped_ptr<PrioritizedResource> textures[max_textures];
-
- for (size_t i = 0; i < max_textures; ++i)
- textures[i] =
- resource_manager->CreateTexture(texture_size_, texture_format_);
-
- // Set 6 visible textures in the root surface, and 2 in a child surface.
- for (size_t i = 0; i < 6; ++i)
- textures[i]->
- set_request_priority(PriorityCalculator::VisiblePriority(true));
- for (size_t i = 6; i < 8; ++i)
- textures[i]->
- set_request_priority(PriorityCalculator::VisiblePriority(false));
-
- PrioritizeTexturesAndBackings(resource_manager.get());
-
- // Unable to request_late textures in the child surface.
- EXPECT_FALSE(ValidateTexture(textures[6], true));
- EXPECT_FALSE(ValidateTexture(textures[7], true));
-
- // Root surface textures are valid.
- for (size_t i = 0; i < 6; ++i)
- EXPECT_TRUE(ValidateTexture(textures[i], false));
-
- EXPECT_EQ(TexturesMemorySize(6),
- resource_manager->MemoryAboveCutoffBytes());
- EXPECT_EQ(TexturesMemorySize(2),
- resource_manager->MemoryForSelfManagedTextures());
- EXPECT_LE(resource_manager->MemoryUseBytes(),
- resource_manager->MemoryAboveCutoffBytes());
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ClearAllMemory(ResourceProvider());
+ // Set 6 visible textures in the root surface, and 2 in a child surface.
+ for (size_t i = 0; i < 6; ++i) {
+ textures[i]->
+ set_request_priority(PriorityCalculator::VisiblePriority(true));
+ }
+ for (size_t i = 6; i < 8; ++i) {
+ textures[i]->
+ set_request_priority(PriorityCalculator::VisiblePriority(false));
+ }
+
+ PrioritizeTexturesAndBackings(resource_manager.get());
+
+ // Unable to request_late textures in the child surface.
+ EXPECT_FALSE(ValidateTexture(textures[6].get(), true));
+ EXPECT_FALSE(ValidateTexture(textures[7].get(), true));
+
+ // Root surface textures are valid.
+ for (size_t i = 0; i < 6; ++i)
+ EXPECT_TRUE(ValidateTexture(textures[i].get(), false));
+
+ EXPECT_EQ(TexturesMemorySize(6), resource_manager->MemoryAboveCutoffBytes());
+ EXPECT_EQ(TexturesMemorySize(2),
+ resource_manager->MemoryForSelfManagedTextures());
+ EXPECT_LE(resource_manager->MemoryUseBytes(),
+ resource_manager->MemoryAboveCutoffBytes());
+
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ClearAllMemory(ResourceProvider());
}
TEST_F(PrioritizedResourceTest, RequestLateBackingsSorting) {
- const size_t max_textures = 8;
- scoped_ptr<PrioritizedResourceManager> resource_manager =
- CreateManager(max_textures);
- resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(max_textures));
-
- // Create textures to fill our memory limit.
- scoped_ptr<PrioritizedResource> textures[max_textures];
- for (size_t i = 0; i < max_textures; ++i)
- textures[i] =
- resource_manager->CreateTexture(texture_size_, texture_format_);
-
- // Set equal priorities, and allocate backings for all textures.
- for (size_t i = 0; i < max_textures; ++i)
- textures[i]->set_request_priority(100);
- PrioritizeTexturesAndBackings(resource_manager.get());
- for (unsigned i = 0; i < max_textures; ++i)
- EXPECT_TRUE(ValidateTexture(textures[i], false));
-
- // Drop the memory limit and prioritize (none will be above the threshold,
- // but they still have backings because ReduceMemory hasn't been called).
- resource_manager->SetMaxMemoryLimitBytes(
- TexturesMemorySize(max_textures / 2));
- PrioritizeTexturesAndBackings(resource_manager.get());
-
- // Push half of them back over the limit.
- for (size_t i = 0; i < max_textures; i += 2)
- EXPECT_TRUE(textures[i]->RequestLate());
-
- // Push the priorities to the backings array and sort the backings array
- ResourceManagerUpdateBackingsPriorities(resource_manager.get());
-
- // Assert that the backings list be sorted with the below-limit backings
- // before the above-limit backings.
- ResourceManagerAssertInvariants(resource_manager.get());
-
- // Make sure that we have backings for all of the textures.
- for (size_t i = 0; i < max_textures; ++i)
- EXPECT_TRUE(textures[i]->have_backing_texture());
-
- // Make sure that only the request_late textures are above the priority
- // cutoff
- for (size_t i = 0; i < max_textures; i += 2)
- EXPECT_TRUE(TextureBackingIsAbovePriorityCutoff(textures[i].get()));
- for (size_t i = 1; i < max_textures; i += 2)
- EXPECT_FALSE(TextureBackingIsAbovePriorityCutoff(textures[i].get()));
+ const size_t kMaxTextures = 8;
+ scoped_ptr<PrioritizedResourceManager> resource_manager =
+ CreateManager(kMaxTextures);
+ resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(kMaxTextures));
+
+ // Create textures to fill our memory limit.
+ scoped_ptr<PrioritizedResource> textures[kMaxTextures];
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ textures[i] =
+ resource_manager->CreateTexture(texture_size_, texture_format_);
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- resource_manager->ClearAllMemory(ResourceProvider());
+ // Set equal priorities, and allocate backings for all textures.
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ textures[i]->set_request_priority(100);
+ PrioritizeTexturesAndBackings(resource_manager.get());
+ for (unsigned i = 0; i < kMaxTextures; ++i)
+ EXPECT_TRUE(ValidateTexture(textures[i].get(), false));
+
+ // Drop the memory limit and prioritize (none will be above the threshold,
+ // but they still have backings because ReduceMemory hasn't been called).
+ resource_manager->SetMaxMemoryLimitBytes(
+ TexturesMemorySize(kMaxTextures / 2));
+ PrioritizeTexturesAndBackings(resource_manager.get());
+
+ // Push half of them back over the limit.
+ for (size_t i = 0; i < kMaxTextures; i += 2)
+ EXPECT_TRUE(textures[i]->RequestLate());
+
+ // Push the priorities to the backings array and sort the backings array
+ ResourceManagerUpdateBackingsPriorities(resource_manager.get());
+
+ // Assert that the backings list be sorted with the below-limit backings
+ // before the above-limit backings.
+ ResourceManagerAssertInvariants(resource_manager.get());
+
+ // Make sure that we have backings for all of the textures.
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ EXPECT_TRUE(textures[i]->have_backing_texture());
+
+ // Make sure that only the request_late textures are above the priority
+ // cutoff
+ for (size_t i = 0; i < kMaxTextures; i += 2)
+ EXPECT_TRUE(TextureBackingIsAbovePriorityCutoff(textures[i].get()));
+ for (size_t i = 1; i < kMaxTextures; i += 2)
+ EXPECT_FALSE(TextureBackingIsAbovePriorityCutoff(textures[i].get()));
+
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ClearAllMemory(ResourceProvider());
}
TEST_F(PrioritizedResourceTest, ClearUploadsToEvictedResources) {
- const size_t max_textures = 4;
- scoped_ptr<PrioritizedResourceManager> resource_manager =
- CreateManager(max_textures);
- resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(max_textures));
-
- // Create textures to fill our memory limit.
- scoped_ptr<PrioritizedResource> textures[max_textures];
-
- for (size_t i = 0; i < max_textures; ++i)
- textures[i] =
- resource_manager->CreateTexture(texture_size_, texture_format_);
-
- // Set equal priorities, and allocate backings for all textures.
- for (size_t i = 0; i < max_textures; ++i)
- textures[i]->set_request_priority(100);
- PrioritizeTexturesAndBackings(resource_manager.get());
- for (unsigned i = 0; i < max_textures; ++i)
- EXPECT_TRUE(ValidateTexture(textures[i], false));
-
- ResourceUpdateQueue queue;
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked(&proxy_);
- for (size_t i = 0; i < max_textures; ++i) {
- const ResourceUpdate upload = ResourceUpdate::Create(
- textures[i].get(), NULL, gfx::Rect(), gfx::Rect(), gfx::Vector2d());
- queue.AppendFullUpload(upload);
- }
+ const size_t kMaxTextures = 4;
+ scoped_ptr<PrioritizedResourceManager> resource_manager =
+ CreateManager(kMaxTextures);
+ resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(kMaxTextures));
- // Make sure that we have backings for all of the textures.
- for (size_t i = 0; i < max_textures; ++i)
- EXPECT_TRUE(textures[i]->have_backing_texture());
+ // Create textures to fill our memory limit.
+ scoped_ptr<PrioritizedResource> textures[kMaxTextures];
- queue.ClearUploadsToEvictedResources();
- EXPECT_EQ(4, queue.FullUploadSize());
-
- resource_manager->ReduceMemoryOnImplThread(
- TexturesMemorySize(1),
- PriorityCalculator::AllowEverythingCutoff(),
- ResourceProvider());
- queue.ClearUploadsToEvictedResources();
- EXPECT_EQ(1, queue.FullUploadSize());
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ textures[i] =
+ resource_manager->CreateTexture(texture_size_, texture_format_);
- resource_manager->ReduceMemoryOnImplThread(
- 0, PriorityCalculator::AllowEverythingCutoff(), ResourceProvider());
- queue.ClearUploadsToEvictedResources();
- EXPECT_EQ(0, queue.FullUploadSize());
+ // Set equal priorities, and allocate backings for all textures.
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ textures[i]->set_request_priority(100);
+ PrioritizeTexturesAndBackings(resource_manager.get());
+ for (unsigned i = 0; i < kMaxTextures; ++i)
+ EXPECT_TRUE(ValidateTexture(textures[i].get(), false));
+
+ ResourceUpdateQueue queue;
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ for (size_t i = 0; i < kMaxTextures; ++i) {
+ const ResourceUpdate upload = ResourceUpdate::Create(
+ textures[i].get(), NULL, gfx::Rect(), gfx::Rect(), gfx::Vector2d());
+ queue.AppendFullUpload(upload);
+ }
+
+ // Make sure that we have backings for all of the textures.
+ for (size_t i = 0; i < kMaxTextures; ++i)
+ EXPECT_TRUE(textures[i]->have_backing_texture());
+
+ queue.ClearUploadsToEvictedResources();
+ EXPECT_EQ(4, queue.FullUploadSize());
+
+ resource_manager->ReduceMemoryOnImplThread(
+ TexturesMemorySize(1),
+ PriorityCalculator::AllowEverythingCutoff(),
+ ResourceProvider());
+ queue.ClearUploadsToEvictedResources();
+ EXPECT_EQ(1, queue.FullUploadSize());
+
+ resource_manager->ReduceMemoryOnImplThread(
+ 0, PriorityCalculator::AllowEverythingCutoff(), ResourceProvider());
+ queue.ClearUploadsToEvictedResources();
+ EXPECT_EQ(0, queue.FullUploadSize());
}
TEST_F(PrioritizedResourceTest, UsageStatistics) {
- const size_t max_textures = 5;
- scoped_ptr<PrioritizedResourceManager> resource_manager =
- CreateManager(max_textures);
- scoped_ptr<PrioritizedResource> textures[max_textures];
-
- for (size_t i = 0; i < max_textures; ++i)
- textures[i] =
- resource_manager->CreateTexture(texture_size_, texture_format_);
-
- textures[0]->set_request_priority(
- PriorityCalculator::AllowVisibleOnlyCutoff() - 1);
- textures[1]->
- set_request_priority(PriorityCalculator::AllowVisibleOnlyCutoff());
- textures[2]->set_request_priority(
- PriorityCalculator::AllowVisibleAndNearbyCutoff() - 1);
- textures[3]->set_request_priority(
- PriorityCalculator::AllowVisibleAndNearbyCutoff());
- textures[4]->set_request_priority(
- PriorityCalculator::AllowVisibleAndNearbyCutoff() + 1);
-
- // Set max limit to 2 textures.
- resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(2));
- PrioritizeTexturesAndBackings(resource_manager.get());
-
- // The first two textures should be available, others should not.
- for (size_t i = 0; i < 2; ++i)
- EXPECT_TRUE(ValidateTexture(textures[i], false));
- for (size_t i = 2; i < max_textures; ++i)
- EXPECT_FALSE(ValidateTexture(textures[i], false));
-
- // Validate the statistics.
- {
- DebugScopedSetImplThread impl_thread(&proxy_);
- EXPECT_EQ(TexturesMemorySize(2), resource_manager->MemoryUseBytes());
- EXPECT_EQ(TexturesMemorySize(1),
- resource_manager->MemoryVisibleBytes());
- EXPECT_EQ(TexturesMemorySize(3),
- resource_manager->MemoryVisibleAndNearbyBytes());
- }
-
- // Re-prioritize the textures, but do not push the values to backings.
- textures[0]->set_request_priority(
- PriorityCalculator::AllowVisibleOnlyCutoff() - 1);
- textures[1]->set_request_priority(
- PriorityCalculator::AllowVisibleOnlyCutoff() - 1);
- textures[2]->set_request_priority(
- PriorityCalculator::AllowVisibleOnlyCutoff() - 1);
- textures[3]->set_request_priority(
- PriorityCalculator::AllowVisibleAndNearbyCutoff() - 1);
- textures[4]->set_request_priority(
- PriorityCalculator::AllowVisibleAndNearbyCutoff());
- resource_manager->PrioritizeTextures();
-
- // Verify that we still see the old values.
- {
- DebugScopedSetImplThread impl_thread (& proxy_);
- EXPECT_EQ(TexturesMemorySize(2), resource_manager->MemoryUseBytes());
- EXPECT_EQ(TexturesMemorySize(1),
- resource_manager->MemoryVisibleBytes());
- EXPECT_EQ(TexturesMemorySize(3),
- resource_manager->MemoryVisibleAndNearbyBytes());
- }
-
- // Push priorities to backings, and verify we see the new values.
- {
- DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked (& proxy_);
- resource_manager->PushTexturePrioritiesToBackings();
- EXPECT_EQ(TexturesMemorySize(2), resource_manager->MemoryUseBytes());
- EXPECT_EQ(TexturesMemorySize(3),
- resource_manager->MemoryVisibleBytes());
- EXPECT_EQ(TexturesMemorySize(4),
- resource_manager->MemoryVisibleAndNearbyBytes());
- }
+ const size_t kMaxTextures = 5;
+ scoped_ptr<PrioritizedResourceManager> resource_manager =
+ CreateManager(kMaxTextures);
+ scoped_ptr<PrioritizedResource> textures[kMaxTextures];
+ for (size_t i = 0; i < kMaxTextures; ++i) {
+ textures[i] =
+ resource_manager->CreateTexture(texture_size_, texture_format_);
+ }
+
+ textures[0]->
+ set_request_priority(PriorityCalculator::AllowVisibleOnlyCutoff() - 1);
+ textures[1]->
+ set_request_priority(PriorityCalculator::AllowVisibleOnlyCutoff());
+ textures[2]->set_request_priority(
+ PriorityCalculator::AllowVisibleAndNearbyCutoff() - 1);
+ textures[3]->
+ set_request_priority(PriorityCalculator::AllowVisibleAndNearbyCutoff());
+ textures[4]->set_request_priority(
+ PriorityCalculator::AllowVisibleAndNearbyCutoff() + 1);
+
+ // Set max limit to 2 textures.
+ resource_manager->SetMaxMemoryLimitBytes(TexturesMemorySize(2));
+ PrioritizeTexturesAndBackings(resource_manager.get());
+
+ // The first two textures should be available, others should not.
+ for (size_t i = 0; i < 2; ++i)
+ EXPECT_TRUE(ValidateTexture(textures[i].get(), false));
+ for (size_t i = 2; i < kMaxTextures; ++i)
+ EXPECT_FALSE(ValidateTexture(textures[i].get(), false));
+
+ // Validate the statistics.
+ {
+ DebugScopedSetImplThread impl_thread(&proxy_);
+ EXPECT_EQ(TexturesMemorySize(2), resource_manager->MemoryUseBytes());
+ EXPECT_EQ(TexturesMemorySize(1), resource_manager->MemoryVisibleBytes());
+ EXPECT_EQ(TexturesMemorySize(3),
+ resource_manager->MemoryVisibleAndNearbyBytes());
+ }
+
+ // Re-prioritize the textures, but do not push the values to backings.
+ textures[0]->
+ set_request_priority(PriorityCalculator::AllowVisibleOnlyCutoff() - 1);
+ textures[1]->
+ set_request_priority(PriorityCalculator::AllowVisibleOnlyCutoff() - 1);
+ textures[2]->
+ set_request_priority(PriorityCalculator::AllowVisibleOnlyCutoff() - 1);
+ textures[3]->set_request_priority(
+ PriorityCalculator::AllowVisibleAndNearbyCutoff() - 1);
+ textures[4]->
+ set_request_priority(PriorityCalculator::AllowVisibleAndNearbyCutoff());
+ resource_manager->PrioritizeTextures();
+
+ // Verify that we still see the old values.
+ {
+ DebugScopedSetImplThread impl_thread(&proxy_);
+ EXPECT_EQ(TexturesMemorySize(2), resource_manager->MemoryUseBytes());
+ EXPECT_EQ(TexturesMemorySize(1), resource_manager->MemoryVisibleBytes());
+ EXPECT_EQ(TexturesMemorySize(3),
+ resource_manager->MemoryVisibleAndNearbyBytes());
+ }
+
+ // Push priorities to backings, and verify we see the new values.
+ {
DebugScopedSetImplThreadAndMainThreadBlocked
- impl_thread_and_main_thread_blocked (& proxy_);
- resource_manager->ClearAllMemory(ResourceProvider());
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->PushTexturePrioritiesToBackings();
+ EXPECT_EQ(TexturesMemorySize(2), resource_manager->MemoryUseBytes());
+ EXPECT_EQ(TexturesMemorySize(3), resource_manager->MemoryVisibleBytes());
+ EXPECT_EQ(TexturesMemorySize(4),
+ resource_manager->MemoryVisibleAndNearbyBytes());
+ }
+
+ DebugScopedSetImplThreadAndMainThreadBlocked
+ impl_thread_and_main_thread_blocked(&proxy_);
+ resource_manager->ClearAllMemory(ResourceProvider());
}
} // namespace
diff --git a/cc/resources/priority_calculator.cc b/cc/resources/priority_calculator.cc
index aaeb6bb..bb9908d 100644
--- a/cc/resources/priority_calculator.cc
+++ b/cc/resources/priority_calculator.cc
@@ -4,6 +4,8 @@
#include "cc/resources/priority_calculator.h"
+#include <algorithm>
+
#include "ui/gfx/rect.h"
namespace cc {
diff --git a/cc/resources/priority_calculator.h b/cc/resources/priority_calculator.h
index 6ab54bd..2c940d8 100644
--- a/cc/resources/priority_calculator.h
+++ b/cc/resources/priority_calculator.h
@@ -36,6 +36,6 @@ class CC_EXPORT PriorityCalculator {
static int AllowEverythingCutoff();
};
-}
+} // namespace cc
#endif // CC_RESOURCES_PRIORITY_CALCULATOR_H_
diff --git a/cc/resources/resource_pool.h b/cc/resources/resource_pool.h
index f3ef9bb..f8f52ac 100644
--- a/cc/resources/resource_pool.h
+++ b/cc/resources/resource_pool.h
@@ -36,7 +36,7 @@ class CC_EXPORT ResourcePool {
virtual ~ResourcePool();
- ResourceProvider* resource_provider() { return resource_provider_; };
+ ResourceProvider* resource_provider() { return resource_provider_; }
scoped_ptr<ResourcePool::Resource> AcquireResource(
const gfx::Size&, GLenum format);
@@ -45,7 +45,7 @@ class CC_EXPORT ResourcePool {
void SetMaxMemoryUsageBytes(size_t max_memory_usage_bytes);
protected:
- ResourcePool(ResourceProvider* resource_provider);
+ explicit ResourcePool(ResourceProvider* resource_provider);
private:
ResourceProvider* resource_provider_;
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index d987251..e2b01e4 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -470,7 +470,7 @@ void ResourceProvider::UnlockForRead(ResourceId id) {
ResourceMap::iterator it = resources_.find(id);
CHECK(it != resources_.end());
Resource* resource = &it->second;
- DCHECK(resource->lock_for_read_count > 0);
+ DCHECK_GT(resource->lock_for_read_count, 0);
DCHECK(!resource->exported);
resource->lock_for_read_count--;
}
@@ -1187,7 +1187,7 @@ void ResourceProvider::LazyAllocate(Resource* resource) {
storage_format,
size.width(),
size.height()));
- } else
+ } else {
GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D,
0,
format,
@@ -1197,6 +1197,7 @@ void ResourceProvider::LazyAllocate(Resource* resource) {
format,
GL_UNSIGNED_BYTE,
NULL));
+ }
}
void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id,
diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h
index acd404f..e5001a0 100644
--- a/cc/resources/resource_provider.h
+++ b/cc/resources/resource_provider.h
@@ -395,6 +395,6 @@ class CC_EXPORT ResourceProvider {
DISALLOW_COPY_AND_ASSIGN(ResourceProvider);
};
-}
+} // namespace cc
#endif // CC_RESOURCES_RESOURCE_PROVIDER_H_
diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc
index cb431ab..6a5ea23 100644
--- a/cc/resources/resource_provider_unittest.cc
+++ b/cc/resources/resource_provider_unittest.cc
@@ -4,6 +4,8 @@
#include "cc/resources/resource_provider.h"
+#include <algorithm>
+
#include "base/bind.h"
#include "base/logging.h"
#include "cc/base/scoped_ptr_deque.h"
@@ -19,13 +21,17 @@
#include "third_party/khronos/GLES2/gl2ext.h"
#include "ui/gfx/rect.h"
-using namespace WebKit;
-
using testing::Mock;
using testing::NiceMock;
using testing::Return;
using testing::StrictMock;
using testing::_;
+using WebKit::WGC3Dbyte;
+using WebKit::WGC3Denum;
+using WebKit::WGC3Dint;
+using WebKit::WGC3Dsizei;
+using WebKit::WGC3Duint;
+using WebKit::WebGLId;
namespace cc {
namespace {
@@ -323,8 +329,8 @@ class ResourceProviderContext : public TestWebGraphicsContext3D {
PendingProduceTextureList pending_produce_textures_;
};
-class ResourceProviderTest :
- public testing::TestWithParam<ResourceProvider::ResourceType> {
+class ResourceProviderTest
+ : public testing::TestWithParam<ResourceProvider::ResourceType> {
public:
ResourceProviderTest()
: shared_data_(ContextSharedData::Create()),
diff --git a/cc/resources/resource_update.h b/cc/resources/resource_update.h
index caf63d9..c531bf7 100644
--- a/cc/resources/resource_update.h
+++ b/cc/resources/resource_update.h
@@ -39,6 +39,6 @@ struct CC_EXPORT ResourceUpdate {
gfx::Vector2d dest_offset;
};
-}
+} // namespace cc
#endif // CC_RESOURCES_RESOURCE_UPDATE_H_
diff --git a/cc/resources/resource_update_controller_unittest.cc b/cc/resources/resource_update_controller_unittest.cc
index bb6114b..c4a8ee75 100644
--- a/cc/resources/resource_update_controller_unittest.cc
+++ b/cc/resources/resource_update_controller_unittest.cc
@@ -14,8 +14,13 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/khronos/GLES2/gl2ext.h"
-using namespace WebKit;
using testing::Test;
+using WebKit::WGC3Denum;
+using WebKit::WGC3Dint;
+using WebKit::WGC3Duint;
+using WebKit::WGC3Dsizei;
+using WebKit::WebGLId;
+using WebKit::WebString;
namespace cc {
namespace {
@@ -27,7 +32,7 @@ class ResourceUpdateControllerTest;
class WebGraphicsContext3DForUploadTest : public TestWebGraphicsContext3D {
public:
- WebGraphicsContext3DForUploadTest(ResourceUpdateControllerTest* test)
+ explicit WebGraphicsContext3DForUploadTest(ResourceUpdateControllerTest* test)
: test_(test),
support_shallow_flush_(true) {}
@@ -320,8 +325,8 @@ TEST_F(ResourceUpdateControllerTest, ManyFullManyPartialUploads) {
<< "Last upload wasn't followed by a flush.";
}
-class FakeResourceUpdateControllerClient :
- public cc::ResourceUpdateControllerClient {
+class FakeResourceUpdateControllerClient
+ : public cc::ResourceUpdateControllerClient {
public:
FakeResourceUpdateControllerClient() { Reset(); }
void Reset() { ready_to_finalize_called_ = false; }
diff --git a/cc/resources/resource_update_queue.h b/cc/resources/resource_update_queue.h
index 45a983a..9ed3266 100644
--- a/cc/resources/resource_update_queue.h
+++ b/cc/resources/resource_update_queue.h
@@ -43,6 +43,6 @@ class CC_EXPORT ResourceUpdateQueue {
DISALLOW_COPY_AND_ASSIGN(ResourceUpdateQueue);
};
-}
+} // namespace cc
#endif // CC_RESOURCES_RESOURCE_UPDATE_QUEUE_H_
diff --git a/cc/resources/scoped_resource.h b/cc/resources/scoped_resource.h
index f6151b6..576b1f8 100644
--- a/cc/resources/scoped_resource.h
+++ b/cc/resources/scoped_resource.h
@@ -31,7 +31,7 @@ class CC_EXPORT ScopedResource : public Resource {
void Leak();
protected:
- explicit ScopedResource(ResourceProvider*);
+ explicit ScopedResource(ResourceProvider* provider);
private:
ResourceProvider* resource_provider_;
@@ -43,6 +43,6 @@ class CC_EXPORT ScopedResource : public Resource {
DISALLOW_COPY_AND_ASSIGN(ScopedResource);
};
-}
+} // namespace cc
#endif // CC_RESOURCES_SCOPED_RESOURCE_H_
diff --git a/cc/resources/scoped_resource_unittest.cc b/cc/resources/scoped_resource_unittest.cc
index b1c2a62..a9a087e 100644
--- a/cc/resources/scoped_resource_unittest.cc
+++ b/cc/resources/scoped_resource_unittest.cc
@@ -10,8 +10,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/khronos/GLES2/gl2.h"
-using namespace WebKit;
-
namespace cc {
namespace {
diff --git a/cc/resources/tile.h b/cc/resources/tile.h
index 904eb0b..40acb5b 100644
--- a/cc/resources/tile.h
+++ b/cc/resources/tile.h
@@ -63,8 +63,8 @@ class CC_EXPORT Tile : public base::RefCounted<Tile> {
int layer_id() const { return layer_id_; }
void set_picture_pile(scoped_refptr<PicturePileImpl> pile) {
- DCHECK(pile->CanRaster(contents_scale_, content_rect_));
- picture_pile_ = pile;
+ DCHECK(pile->CanRaster(contents_scale_, content_rect_));
+ picture_pile_ = pile;
}
private:
diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc
index dce46b4..3b569ec 100644
--- a/cc/resources/tile_manager.cc
+++ b/cc/resources/tile_manager.cc
@@ -5,6 +5,7 @@
#include "cc/resources/tile_manager.h"
#include <algorithm>
+#include <string>
#include "base/bind.h"
#include "base/debug/trace_event.h"
@@ -646,8 +647,8 @@ void TileManager::DispatchMoreTasks() {
// need to process those tiles first before we start to handle the tiles
// in the need_to_be_rasterized queue. Note that solid/transparent tiles
// will not be put into the decoding list.
- for(TileList::iterator it = tiles_with_image_decoding_tasks_.begin();
- it != tiles_with_image_decoding_tasks_.end(); ) {
+ for (TileList::iterator it = tiles_with_image_decoding_tasks_.begin();
+ it != tiles_with_image_decoding_tasks_.end(); ) {
ManagedTileState& managed_tile_state = (*it)->managed_state();
DispatchImageDecodeTasksForTile(*it);
if (managed_tile_state.pending_pixel_refs.empty()) {
@@ -1051,7 +1052,7 @@ void TileManager::RecordSolidColorPredictorResults(
if (SkColorGetA(current_color) != 0)
is_transparent = false;
- if(!is_actually_solid && !is_transparent)
+ if (!is_actually_solid && !is_transparent)
break;
}
diff --git a/cc/resources/tile_manager.h b/cc/resources/tile_manager.h
index 83223b2..105d2d6 100644
--- a/cc/resources/tile_manager.h
+++ b/cc/resources/tile_manager.h
@@ -38,10 +38,10 @@ class CC_EXPORT TileManagerClient {
// Tile manager classifying tiles into a few basic
// bins:
enum TileManagerBin {
- NOW_BIN = 0, // Needed ASAP.
- SOON_BIN = 1, // Impl-side version of prepainting.
- EVENTUALLY_BIN = 2, // Nice to have, if we've got memory and time.
- NEVER_BIN = 3, // Dont bother.
+ NOW_BIN = 0, // Needed ASAP.
+ SOON_BIN = 1, // Impl-side version of prepainting.
+ EVENTUALLY_BIN = 2, // Nice to have, if we've got memory and time.
+ NEVER_BIN = 3, // Dont bother.
NUM_BINS = 4
// Be sure to update TileManagerBinAsValue when adding new fields.
};
@@ -120,7 +120,6 @@ class CC_EXPORT TileManager : public WorkerPoolClient {
}
private:
-
// Data that is passed to raster tasks.
struct RasterTaskMetadata {
bool prediction_benchmarking;
diff --git a/cc/resources/tile_priority.cc b/cc/resources/tile_priority.cc
index e25b61e..d1c3fbf 100644
--- a/cc/resources/tile_priority.cc
+++ b/cc/resources/tile_priority.cc
@@ -30,24 +30,24 @@ bool Range::IsEmpty() {
return start_ >= end_;
}
-inline void IntersectNegativeHalfplane(Range& out, float previous,
+inline void IntersectNegativeHalfplane(Range* out, float previous,
float current, float target, float time_delta) {
float time_per_dist = time_delta / (current - previous);
float t = (target - current) * time_per_dist;
if (time_per_dist > 0.0f)
- out.start_ = std::max(out.start_, t);
+ out->start_ = std::max(out->start_, t);
else
- out.end_ = std::min(out.end_, t);
+ out->end_ = std::min(out->end_, t);
}
-inline void IntersectPositiveHalfplane(Range& out, float previous,
+inline void IntersectPositiveHalfplane(Range* out, float previous,
float current, float target, float time_delta) {
float time_per_dist = time_delta / (current - previous);
float t = (target - current) * time_per_dist;
if (time_per_dist < 0.0f)
- out.start_ = std::max(out.start_, t);
+ out->start_ = std::max(out->start_, t);
else
- out.end_ = std::min(out.end_, t);
+ out->end_ = std::min(out->end_, t);
}
} // namespace
@@ -132,16 +132,16 @@ float TilePriority::TimeForBoundsToIntersect(const gfx::RectF& previous_bounds,
// each other during that period of time.
Range range(0.0f, kMaxTimeToVisibleInSeconds);
IntersectPositiveHalfplane(
- range, previous_bounds.x(), current_bounds.x(),
+ &range, previous_bounds.x(), current_bounds.x(),
target_bounds.right(), time_delta);
IntersectNegativeHalfplane(
- range, previous_bounds.right(), current_bounds.right(),
+ &range, previous_bounds.right(), current_bounds.right(),
target_bounds.x(), time_delta);
IntersectPositiveHalfplane(
- range, previous_bounds.y(), current_bounds.y(),
+ &range, previous_bounds.y(), current_bounds.y(),
target_bounds.bottom(), time_delta);
IntersectNegativeHalfplane(
- range, previous_bounds.bottom(), current_bounds.bottom(),
+ &range, previous_bounds.bottom(), current_bounds.bottom(),
target_bounds.y(), time_delta);
return range.IsEmpty() ? kMaxTimeToVisibleInSeconds : range.start_;
}
diff --git a/cc/resources/tile_priority.h b/cc/resources/tile_priority.h
index a9558ef..d14f311 100644
--- a/cc/resources/tile_priority.h
+++ b/cc/resources/tile_priority.h
@@ -5,6 +5,7 @@
#ifndef CC_RESOURCES_TILE_PRIORITY_H_
#define CC_RESOURCES_TILE_PRIORITY_H_
+#include <algorithm>
#include <limits>
#include "base/memory/ref_counted.h"
@@ -151,13 +152,13 @@ enum TileMemoryLimitPolicy {
ALLOW_NOTHING,
// You might be made visible, but you're not being interacted with.
- ALLOW_ABSOLUTE_MINIMUM, // Tall.
+ ALLOW_ABSOLUTE_MINIMUM, // Tall.
// You're being interacted with, but we're low on memory.
- ALLOW_PREPAINT_ONLY, // Grande.
+ ALLOW_PREPAINT_ONLY, // Grande.
// You're the only thing in town. Go crazy.
- ALLOW_ANYTHING, // Venti.
+ ALLOW_ANYTHING, // Venti.
// Be sure to update TreePriorityAsValue when adding new fields.
};