summaryrefslogtreecommitdiff
path: root/chromium/cc/base
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2014-03-18 13:16:26 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-03-20 15:55:39 +0100
commit3f0f86b0caed75241fa71c95a5d73bc0164348c5 (patch)
tree92b9fb00f2e9e90b0be2262093876d4f43b6cd13 /chromium/cc/base
parente90d7c4b152c56919d963987e2503f9909a666d2 (diff)
downloadqtwebengine-chromium-3f0f86b0caed75241fa71c95a5d73bc0164348c5.tar.gz
Update to new stable branch 1750
This also includes an updated ninja and chromium dependencies needed on Windows. Change-Id: Icd597d80ed3fa4425933c9f1334c3c2e31291c42 Reviewed-by: Zoltan Arvai <zarvai@inf.u-szeged.hu> Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'chromium/cc/base')
-rw-r--r--chromium/cc/base/float_quad_unittest.cc38
-rw-r--r--chromium/cc/base/invalidation_region.cc11
-rw-r--r--chromium/cc/base/invalidation_region.h1
-rw-r--r--chromium/cc/base/latency_info_swap_promise.cc50
-rw-r--r--chromium/cc/base/latency_info_swap_promise.h28
-rw-r--r--chromium/cc/base/latency_info_swap_promise_monitor.cc43
-rw-r--r--chromium/cc/base/latency_info_swap_promise_monitor.h36
-rw-r--r--chromium/cc/base/math_util.cc28
-rw-r--r--chromium/cc/base/math_util.h10
-rw-r--r--chromium/cc/base/math_util_unittest.cc8
-rw-r--r--chromium/cc/base/ref_counted_managed.h65
-rw-r--r--chromium/cc/base/scoped_ptr_vector.h7
-rw-r--r--chromium/cc/base/scoped_ptr_vector_unittest.cc33
-rw-r--r--chromium/cc/base/swap_promise.h50
-rw-r--r--chromium/cc/base/swap_promise_monitor.cc31
-rw-r--r--chromium/cc/base/swap_promise_monitor.h44
-rw-r--r--chromium/cc/base/switches.cc55
-rw-r--r--chromium/cc/base/switches.h8
-rw-r--r--chromium/cc/base/util.h33
19 files changed, 521 insertions, 58 deletions
diff --git a/chromium/cc/base/float_quad_unittest.cc b/chromium/cc/base/float_quad_unittest.cc
index 186624eec34..c2186fd81b4 100644
--- a/chromium/cc/base/float_quad_unittest.cc
+++ b/chromium/cc/base/float_quad_unittest.cc
@@ -15,15 +15,15 @@ namespace {
TEST(FloatQuadTest, IsRectilinearTest) {
const int kNumRectilinear = 8;
gfx::Transform rectilinear_trans[kNumRectilinear];
- rectilinear_trans[1].Rotate(90.0);
- rectilinear_trans[2].Rotate(180.0);
- rectilinear_trans[3].Rotate(270.0);
- rectilinear_trans[4].SkewX(0.00000000001);
- rectilinear_trans[5].SkewY(0.00000000001);
- rectilinear_trans[6].Scale(0.00001, 0.00001);
- rectilinear_trans[6].Rotate(180.0);
- rectilinear_trans[7].Scale(100000, 100000);
- rectilinear_trans[7].Rotate(180.0);
+ rectilinear_trans[1].Rotate(90.f);
+ rectilinear_trans[2].Rotate(180.f);
+ rectilinear_trans[3].Rotate(270.f);
+ rectilinear_trans[4].SkewX(0.00000000001f);
+ rectilinear_trans[5].SkewY(0.00000000001f);
+ rectilinear_trans[6].Scale(0.00001f, 0.00001f);
+ rectilinear_trans[6].Rotate(180.f);
+ rectilinear_trans[7].Scale(100000.f, 100000.f);
+ rectilinear_trans[7].Rotate(180.f);
gfx::QuadF original(
gfx::RectF(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f));
@@ -38,16 +38,16 @@ TEST(FloatQuadTest, IsRectilinearTest) {
const int kNumNonRectilinear = 10;
gfx::Transform non_rectilinear_trans[kNumNonRectilinear];
- non_rectilinear_trans[0].Rotate(359.999);
- non_rectilinear_trans[1].Rotate(0.0000001);
- non_rectilinear_trans[2].Rotate(89.999999);
- non_rectilinear_trans[3].Rotate(90.0000001);
- non_rectilinear_trans[4].Rotate(179.999999);
- non_rectilinear_trans[5].Rotate(180.0000001);
- non_rectilinear_trans[6].Rotate(269.999999);
- non_rectilinear_trans[7].Rotate(270.0000001);
- non_rectilinear_trans[8].SkewX(0.00001);
- non_rectilinear_trans[9].SkewY(0.00001);
+ non_rectilinear_trans[0].Rotate(359.9999f);
+ non_rectilinear_trans[1].Rotate(0.0000001f);
+ non_rectilinear_trans[2].Rotate(89.9999f);
+ non_rectilinear_trans[3].Rotate(90.00001f);
+ non_rectilinear_trans[4].Rotate(179.9999f);
+ non_rectilinear_trans[5].Rotate(180.00001f);
+ non_rectilinear_trans[6].Rotate(269.9999f);
+ non_rectilinear_trans[7].Rotate(270.0001f);
+ non_rectilinear_trans[8].SkewX(0.00001f);
+ non_rectilinear_trans[9].SkewY(0.00001f);
for (int i = 0; i < kNumNonRectilinear; ++i) {
bool clipped = false;
diff --git a/chromium/cc/base/invalidation_region.cc b/chromium/cc/base/invalidation_region.cc
index 2c39d25ba06..6a8f97f78fe 100644
--- a/chromium/cc/base/invalidation_region.cc
+++ b/chromium/cc/base/invalidation_region.cc
@@ -19,14 +19,6 @@ InvalidationRegion::InvalidationRegion() {}
InvalidationRegion::~InvalidationRegion() {}
void InvalidationRegion::Swap(Region* region) {
- UMA_HISTOGRAM_CUSTOM_COUNTS(
- "Renderer4.InvalidationRegionApproximateRectCount",
- region_.GetRegionComplexity(),
- 1,
- 5000,
- 50);
-
- SimplifyIfNeeded();
region_.Swap(region);
}
@@ -35,9 +27,8 @@ void InvalidationRegion::Clear() {
}
void InvalidationRegion::Union(gfx::Rect rect) {
- // TODO(vmpstr): We should simplify the region after Union() after we get a
- // good idea of what kind of regions are typical (from the UMA histogram).
region_.Union(rect);
+ SimplifyIfNeeded();
}
void InvalidationRegion::SimplifyIfNeeded() {
diff --git a/chromium/cc/base/invalidation_region.h b/chromium/cc/base/invalidation_region.h
index fd061e8cba3..33be80332ff 100644
--- a/chromium/cc/base/invalidation_region.h
+++ b/chromium/cc/base/invalidation_region.h
@@ -22,6 +22,7 @@ class CC_EXPORT InvalidationRegion {
void Swap(Region* region);
void Clear();
void Union(gfx::Rect rect);
+ bool IsEmpty() const { return region_.IsEmpty(); }
private:
void SimplifyIfNeeded();
diff --git a/chromium/cc/base/latency_info_swap_promise.cc b/chromium/cc/base/latency_info_swap_promise.cc
new file mode 100644
index 00000000000..41c0e997d11
--- /dev/null
+++ b/chromium/cc/base/latency_info_swap_promise.cc
@@ -0,0 +1,50 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/base/latency_info_swap_promise.h"
+
+#include "base/logging.h"
+
+namespace {
+ ui::LatencyComponentType DidNotSwapReasonToLatencyComponentType(
+ cc::SwapPromise::DidNotSwapReason reason) {
+ switch (reason) {
+ case cc::SwapPromise::DID_NOT_SWAP_UNKNOWN:
+ case cc::SwapPromise::SWAP_FAILS:
+ return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT;
+ case cc::SwapPromise::COMMIT_FAILS:
+ return ui::INPUT_EVENT_LATENCY_TERMINATED_COMMIT_FAILED_COMPONENT;
+ case cc::SwapPromise::SWAP_PROMISE_LIST_OVERFLOW:
+ return ui::LATENCY_INFO_LIST_TERMINATED_OVERFLOW_COMPONENT;
+ }
+ NOTREACHED() << "Unhandled DidNotSwapReason.";
+ return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT;
+ }
+} // namespace
+
+namespace cc {
+
+LatencyInfoSwapPromise::LatencyInfoSwapPromise(const ui::LatencyInfo& latency)
+ : latency_(latency) {
+}
+
+LatencyInfoSwapPromise::~LatencyInfoSwapPromise() {
+}
+
+void LatencyInfoSwapPromise::DidSwap(CompositorFrameMetadata* metadata) {
+ DCHECK(!latency_.terminated);
+ // TODO(miletus): Append the |latency_| into metadata's LatencyInfo list
+ // once we remove LatencyInfo merge in GPU side.
+ metadata->latency_info.MergeWith(latency_);
+}
+
+void LatencyInfoSwapPromise::DidNotSwap(DidNotSwapReason reason) {
+ latency_.AddLatencyNumber(DidNotSwapReasonToLatencyComponentType(reason),
+ 0, 0);
+ // TODO(miletus): Turn this back on once per-event LatencyInfo tracking
+ // is enabled in GPU side.
+ // DCHECK(latency_.terminated);
+}
+
+} // namespace cc
diff --git a/chromium/cc/base/latency_info_swap_promise.h b/chromium/cc/base/latency_info_swap_promise.h
new file mode 100644
index 00000000000..1a2b1d6b206
--- /dev/null
+++ b/chromium/cc/base/latency_info_swap_promise.h
@@ -0,0 +1,28 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_BASE_LATENCY_INFO_SWAP_PROMISE_H_
+#define CC_BASE_LATENCY_INFO_SWAP_PROMISE_H_
+
+#include "base/compiler_specific.h"
+#include "cc/base/swap_promise.h"
+#include "ui/events/latency_info.h"
+
+namespace cc {
+
+class CC_EXPORT LatencyInfoSwapPromise : public SwapPromise {
+ public:
+ explicit LatencyInfoSwapPromise(const ui::LatencyInfo& latency_info);
+ virtual ~LatencyInfoSwapPromise();
+
+ virtual void DidSwap(CompositorFrameMetadata* metadata) OVERRIDE;
+ virtual void DidNotSwap(DidNotSwapReason reason) OVERRIDE;
+
+ private:
+ ui::LatencyInfo latency_;
+};
+
+} // namespace cc
+
+#endif // CC_BASE_LATENCY_INFO_SWAP_PROMISE_H_
diff --git a/chromium/cc/base/latency_info_swap_promise_monitor.cc b/chromium/cc/base/latency_info_swap_promise_monitor.cc
new file mode 100644
index 00000000000..0f2ff7481bb
--- /dev/null
+++ b/chromium/cc/base/latency_info_swap_promise_monitor.cc
@@ -0,0 +1,43 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/base/latency_info_swap_promise_monitor.h"
+
+#include "cc/base/latency_info_swap_promise.h"
+#include "cc/trees/layer_tree_host.h"
+#include "cc/trees/layer_tree_host_impl.h"
+#include "cc/trees/layer_tree_impl.h"
+
+namespace cc {
+
+LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor(
+ ui::LatencyInfo* latency,
+ LayerTreeHost* layer_tree_host,
+ LayerTreeHostImpl* layer_tree_host_impl)
+ : SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl),
+ latency_(latency) {}
+
+LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {}
+
+void LatencyInfoSwapPromiseMonitor::OnSetNeedsCommitOnMain() {
+ if (!latency_->FindLatency(
+ ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0)) {
+ latency_->AddLatencyNumber(
+ ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0);
+ scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_));
+ layer_tree_host_->QueueSwapPromise(swap_promise.Pass());
+ }
+}
+
+void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() {
+ if (!latency_->FindLatency(
+ ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0)) {
+ latency_->AddLatencyNumber(
+ ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, 0);
+ scoped_ptr<SwapPromise> swap_promise(new LatencyInfoSwapPromise(*latency_));
+ layer_tree_host_impl_->active_tree()->QueueSwapPromise(swap_promise.Pass());
+ }
+}
+
+} // namespace cc
diff --git a/chromium/cc/base/latency_info_swap_promise_monitor.h b/chromium/cc/base/latency_info_swap_promise_monitor.h
new file mode 100644
index 00000000000..a463fdbeeff
--- /dev/null
+++ b/chromium/cc/base/latency_info_swap_promise_monitor.h
@@ -0,0 +1,36 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/compiler_specific.h"
+#include "cc/base/swap_promise_monitor.h"
+
+#ifndef CC_BASE_LATENCY_INFO_SWAP_PROMISE_MONITOR_H_
+#define CC_BASE_LATENCY_INFO_SWAP_PROMISE_MONITOR_H_
+
+namespace ui {
+struct LatencyInfo;
+} // namespace ui
+
+namespace cc {
+
+// A LatencyInfoSwapPromiseMonitor queues a LatencyInfoSwapPromise into
+// LayerTreeHost or LayerTreeHostImpl if there is compositor state change
+// while it is being mointored.
+class CC_EXPORT LatencyInfoSwapPromiseMonitor : public SwapPromiseMonitor {
+ public:
+ LatencyInfoSwapPromiseMonitor(ui::LatencyInfo* latency,
+ LayerTreeHost* layer_tree_host,
+ LayerTreeHostImpl* layer_tree_host_impl);
+ virtual ~LatencyInfoSwapPromiseMonitor();
+
+ virtual void OnSetNeedsCommitOnMain() OVERRIDE;
+ virtual void OnSetNeedsRedrawOnImpl() OVERRIDE;
+
+ private:
+ ui::LatencyInfo* latency_;
+};
+
+} // namespace cc
+
+#endif // CC_BASE_LATENCY_INFO_SWAP_PROMISE_MONITOR_H_
diff --git a/chromium/cc/base/math_util.cc b/chromium/cc/base/math_util.cc
index 40b8d11c68c..7a1bc1a8674 100644
--- a/chromium/cc/base/math_util.cc
+++ b/chromium/cc/base/math_util.cc
@@ -72,13 +72,13 @@ static HomogeneousCoordinate ComputeClippedPointForEdge(
// w plane when this is called.
DCHECK(h1.ShouldBeClipped() ^ h2.ShouldBeClipped());
- SkMScalar w = 0.00001; // or any positive non-zero small epsilon
-
+ // ...or any positive non-zero small epsilon
+ SkMScalar w = 0.00001f;
SkMScalar t = (w - h1.w()) / (h2.w() - h1.w());
- SkMScalar x = (1 - t) * h1.x() + t * h2.x();
- SkMScalar y = (1 - t) * h1.y() + t * h2.y();
- SkMScalar z = (1 - t) * h1.z() + t * h2.z();
+ SkMScalar x = (SK_MScalar1 - t) * h1.x() + t * h2.x();
+ SkMScalar y = (SK_MScalar1 - t) * h1.y() + t * h2.y();
+ SkMScalar z = (SK_MScalar1 - t) * h1.z() + t * h2.z();
return HomogeneousCoordinate(x, y, z, w);
}
@@ -466,6 +466,13 @@ gfx::RectF MathUtil::ScaleRectProportional(const gfx::RectF& input_outer_rect,
}
static inline float ScaleOnAxis(double a, double b, double c) {
+ if (!b && !c)
+ return a;
+ if (!a && !c)
+ return b;
+ if (!a && !b)
+ return c;
+
// Do the sqrt as a double to not lose precision.
return static_cast<float>(std::sqrt(a * a + b * b + c * c));
}
@@ -583,6 +590,17 @@ scoped_ptr<base::Value> MathUtil::AsValue(const gfx::Transform& transform) {
return res.PassAs<base::Value>();
}
+scoped_ptr<base::Value> MathUtil::AsValue(const gfx::BoxF& box) {
+ scoped_ptr<base::ListValue> res(new base::ListValue());
+ res->AppendInteger(box.x());
+ res->AppendInteger(box.y());
+ res->AppendInteger(box.z());
+ res->AppendInteger(box.width());
+ res->AppendInteger(box.height());
+ res->AppendInteger(box.depth());
+ return res.PassAs<base::Value>();
+}
+
scoped_ptr<base::Value> MathUtil::AsValueSafely(double value) {
return scoped_ptr<base::Value>(base::Value::CreateDoubleValue(
std::min(value, std::numeric_limits<double>::max())));
diff --git a/chromium/cc/base/math_util.h b/chromium/cc/base/math_util.h
index 7912f8a8a25..baceb7058fe 100644
--- a/chromium/cc/base/math_util.h
+++ b/chromium/cc/base/math_util.h
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "cc/base/cc_export.h"
+#include "ui/gfx/box_f.h"
#include "ui/gfx/point3_f.h"
#include "ui/gfx/point_f.h"
#include "ui/gfx/size.h"
@@ -39,24 +40,24 @@ struct HomogeneousCoordinate {
bool ShouldBeClipped() const { return w() <= 0.0; }
gfx::PointF CartesianPoint2d() const {
- if (w() == 1.0)
+ if (w() == SK_MScalar1)
return gfx::PointF(x(), y());
// For now, because this code is used privately only by MathUtil, it should
// never be called when w == 0, and we do not yet need to handle that case.
DCHECK(w());
- SkMScalar inv_w = 1.0 / w();
+ SkMScalar inv_w = SK_MScalar1 / w();
return gfx::PointF(x() * inv_w, y() * inv_w);
}
gfx::Point3F CartesianPoint3d() const {
- if (w() == 1)
+ if (w() == SK_MScalar1)
return gfx::Point3F(x(), y(), z());
// For now, because this code is used privately only by MathUtil, it should
// never be called when w == 0, and we do not yet need to handle that case.
DCHECK(w());
- SkMScalar inv_w = 1.0 / w();
+ SkMScalar inv_w = SK_MScalar1 / w();
return gfx::Point3F(x() * inv_w, y() * inv_w, z() * inv_w);
}
@@ -172,6 +173,7 @@ class CC_EXPORT MathUtil {
static scoped_ptr<base::Value> AsValue(const gfx::QuadF& q);
static scoped_ptr<base::Value> AsValue(const gfx::RectF& rect);
static scoped_ptr<base::Value> AsValue(const gfx::Transform& transform);
+ static scoped_ptr<base::Value> AsValue(const gfx::BoxF& box);
// Returns a base::Value representation of the floating point value.
// If the value is inf, returns max double/float representation.
diff --git a/chromium/cc/base/math_util_unittest.cc b/chromium/cc/base/math_util_unittest.cc
index d62280ddb5f..6e276c25d64 100644
--- a/chromium/cc/base/math_util_unittest.cc
+++ b/chromium/cc/base/math_util_unittest.cc
@@ -22,7 +22,7 @@ TEST(MathUtilTest, ProjectionOfPerpendicularPlane) {
gfx::Transform transform;
transform.MakeIdentity();
- transform.matrix().setDouble(2, 2, 0);
+ transform.matrix().set(2, 2, 0);
gfx::RectF rect = gfx::RectF(0, 0, 1, 1);
gfx::RectF projected_rect = MathUtil::ProjectClippedRect(transform, rect);
@@ -44,8 +44,10 @@ TEST(MathUtilTest, EnclosingClippedRectUsesCorrectInitialBounds) {
// then the enclosing clipped rect will be computed incorrectly.
gfx::RectF result = MathUtil::ComputeEnclosingClippedRect(h1, h2, h3, h4);
- EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(-100, -100), gfx::SizeF(90, 90)),
- result);
+ // Due to floating point math in ComputeClippedPointForEdge this result
+ // is fairly imprecise. 0.15f was empirically determined.
+ EXPECT_RECT_NEAR(
+ gfx::RectF(gfx::PointF(-100, -100), gfx::SizeF(90, 90)), result, 0.15f);
}
TEST(MathUtilTest, EnclosingRectOfVerticesUsesCorrectInitialBounds) {
diff --git a/chromium/cc/base/ref_counted_managed.h b/chromium/cc/base/ref_counted_managed.h
new file mode 100644
index 00000000000..8bb836f0159
--- /dev/null
+++ b/chromium/cc/base/ref_counted_managed.h
@@ -0,0 +1,65 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_BASE_REF_COUNTED_MANAGED_H_
+#define CC_BASE_REF_COUNTED_MANAGED_H_
+
+#include "base/logging.h"
+#include "base/memory/ref_counted.h"
+#include "cc/base/cc_export.h"
+
+namespace cc {
+
+template <typename T> class RefCountedManaged;
+
+template <typename T>
+class CC_EXPORT RefCountedManager {
+ protected:
+ RefCountedManager() : live_object_count_(0) {}
+ ~RefCountedManager() {
+ CHECK_EQ(0, live_object_count_);
+ }
+
+ virtual void Release(T* object) = 0;
+
+ private:
+ friend class RefCountedManaged<T>;
+ int live_object_count_;
+};
+
+template <typename T>
+class CC_EXPORT RefCountedManaged : public base::subtle::RefCountedBase {
+ public:
+ explicit RefCountedManaged(RefCountedManager<T>* manager)
+ : manager_(manager) {
+ manager_->live_object_count_++;
+ }
+
+ void AddRef() const {
+ base::subtle::RefCountedBase::AddRef();
+ }
+
+ void Release() {
+ if (base::subtle::RefCountedBase::Release()) {
+ DCHECK_GT(manager_->live_object_count_, 0);
+ manager_->live_object_count_--;
+
+ // This must be the last statement in case manager deletes
+ // the object immediately.
+ manager_->Release(static_cast<T*>(this));
+ }
+ }
+
+ protected:
+ ~RefCountedManaged() {}
+
+ private:
+ RefCountedManager<T>* manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(RefCountedManaged<T>);
+};
+
+} // namespace cc
+
+#endif // CC_BASE_REF_COUNTED_MANAGED_H_
diff --git a/chromium/cc/base/scoped_ptr_vector.h b/chromium/cc/base/scoped_ptr_vector.h
index 856e2f51cd1..288cb6fa47b 100644
--- a/chromium/cc/base/scoped_ptr_vector.h
+++ b/chromium/cc/base/scoped_ptr_vector.h
@@ -140,6 +140,13 @@ class ScopedPtrVector {
data_.insert(position, tmp_data.begin(), tmp_data.end());
}
+ template <typename Predicate>
+ iterator partition(Predicate predicate) {
+ typename std::vector<T*>::iterator first = begin();
+ typename std::vector<T*>::iterator last = end();
+ return static_cast<iterator>(std::partition(first, last, predicate));
+ }
+
void swap(ScopedPtrVector<T>& other) {
data_.swap(other.data_);
}
diff --git a/chromium/cc/base/scoped_ptr_vector_unittest.cc b/chromium/cc/base/scoped_ptr_vector_unittest.cc
index 4e450b9c823..8190b37b83b 100644
--- a/chromium/cc/base/scoped_ptr_vector_unittest.cc
+++ b/chromium/cc/base/scoped_ptr_vector_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <set>
+
#include "cc/base/scoped_ptr_vector.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -17,6 +19,11 @@ class Data {
int data_;
};
+class IsOddPredicate {
+ public:
+ bool operator()(const Data* data) { return (data->data() % 2) == 1; }
+};
+
TEST(ScopedPtrVectorTest, PushBack) {
ScopedPtrVector<Data> v;
@@ -68,5 +75,31 @@ TEST(ScopedPtrVectorTest, InsertAndTake) {
EXPECT_EQ(NULL, v2[2]);
}
+TEST(ScopedPtrVectorTest, Partition) {
+ ScopedPtrVector<Data> v;
+ v.push_back(Data::Create(1));
+ v.push_back(Data::Create(2));
+ v.push_back(Data::Create(3));
+ v.push_back(Data::Create(4));
+ v.push_back(Data::Create(5));
+
+ ScopedPtrVector<Data>::iterator it = v.partition(IsOddPredicate());
+ std::set<int> odd_numbers;
+ for (ScopedPtrVector<Data>::iterator second_it = v.begin();
+ second_it != it;
+ ++second_it) {
+ EXPECT_EQ(1, (*second_it)->data() % 2);
+ odd_numbers.insert((*second_it)->data());
+ }
+ EXPECT_EQ(3u, odd_numbers.size());
+
+ std::set<int> even_numbers;
+ for (; it != v.end(); ++it) {
+ EXPECT_EQ(0, (*it)->data() % 2);
+ even_numbers.insert((*it)->data());
+ }
+ EXPECT_EQ(2u, even_numbers.size());
+}
+
} // namespace
} // namespace cc
diff --git a/chromium/cc/base/swap_promise.h b/chromium/cc/base/swap_promise.h
new file mode 100644
index 00000000000..36a5b130a50
--- /dev/null
+++ b/chromium/cc/base/swap_promise.h
@@ -0,0 +1,50 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_BASE_SWAP_PROMISE_H_
+#define CC_BASE_SWAP_PROMISE_H_
+
+#include "cc/output/compositor_frame_metadata.h"
+
+namespace cc {
+
+const unsigned int kMaxQueuedSwapPromiseNumber = 100;
+
+// When a change to the compositor's state/invalidation/whatever happens, a
+// Swap Promise can be inserted into LayerTreeHost/LayerTreeImpl, to track
+// whether the compositor's reply to the new state/invaliadtion/whatever is
+// completed in the compositor, i.e. the compositor knows it has been sent
+// to its output or not.
+//
+// If the new compositor state is sent to the output, SwapPromise::DidSwap()
+// will be called, and if the compositor fails to send its new state to the
+// output, SwapPromise::DidNotSwap() will be called.
+//
+// Client wishes to use SwapPromise should have a subclass that defines
+// the behavior of DidSwap() and DidNotSwap(). Notice that the promise can
+// be broken at either main or impl thread, e.g. commit fails on main thread,
+// new frame data has no actual damage so LayerTreeHostImpl::SwapBuffers()
+// bails out early on impl thread, so don't assume that DidSwap() and
+// DidNotSwap() are called at a particular thread. It is better to let the
+// subclass carry thread-safe member data and operate on that member data in
+// DidSwap() and DidNotSwap().
+class CC_EXPORT SwapPromise {
+ public:
+ enum DidNotSwapReason {
+ DID_NOT_SWAP_UNKNOWN,
+ SWAP_FAILS,
+ COMMIT_FAILS,
+ SWAP_PROMISE_LIST_OVERFLOW,
+ };
+
+ SwapPromise() {}
+ virtual ~SwapPromise() {}
+
+ virtual void DidSwap(CompositorFrameMetadata* metadata) = 0;
+ virtual void DidNotSwap(DidNotSwapReason reason) = 0;
+};
+
+} // namespace cc
+
+#endif // CC_BASE_SWAP_PROMISE_H_
diff --git a/chromium/cc/base/swap_promise_monitor.cc b/chromium/cc/base/swap_promise_monitor.cc
new file mode 100644
index 00000000000..0c04f35ebc4
--- /dev/null
+++ b/chromium/cc/base/swap_promise_monitor.cc
@@ -0,0 +1,31 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/logging.h"
+#include "cc/base/swap_promise_monitor.h"
+#include "cc/trees/layer_tree_host.h"
+#include "cc/trees/layer_tree_host_impl.h"
+
+namespace cc {
+
+SwapPromiseMonitor::SwapPromiseMonitor(LayerTreeHost* layer_tree_host,
+ LayerTreeHostImpl* layer_tree_host_impl)
+ : layer_tree_host_(layer_tree_host),
+ layer_tree_host_impl_(layer_tree_host_impl) {
+ DCHECK((layer_tree_host && !layer_tree_host_impl) ||
+ (!layer_tree_host && layer_tree_host_impl));
+ if (layer_tree_host_)
+ layer_tree_host_->InsertSwapPromiseMonitor(this);
+ if (layer_tree_host_impl_)
+ layer_tree_host_impl_->InsertSwapPromiseMonitor(this);
+}
+
+SwapPromiseMonitor::~SwapPromiseMonitor() {
+ if (layer_tree_host_)
+ layer_tree_host_->RemoveSwapPromiseMonitor(this);
+ if (layer_tree_host_impl_)
+ layer_tree_host_impl_->RemoveSwapPromiseMonitor(this);
+}
+
+} // namespace cc
diff --git a/chromium/cc/base/swap_promise_monitor.h b/chromium/cc/base/swap_promise_monitor.h
new file mode 100644
index 00000000000..21a159ad32a
--- /dev/null
+++ b/chromium/cc/base/swap_promise_monitor.h
@@ -0,0 +1,44 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_BASE_SWAP_PROMISE_MONITOR_H_
+#define CC_BASE_SWAP_PROMISE_MONITOR_H_
+
+#include "cc/base/cc_export.h"
+
+namespace cc {
+
+class LayerTreeHost;
+class LayerTreeHostImpl;
+
+// A SwapPromiseMonitor is used to monitor compositor state change that
+// should be associated with a SwapPromise, e.g. SetNeedsCommit() is
+// called on main thread or SetNeedsRedraw() is called on impl thread.
+// Creating a SwapPromiseMonitor will insert itself into a LayerTreeHost
+// or LayerTreeHostImpl. You must provide a pointer to the appropriate
+// structure to the monitor (and only one of the two). Notification of
+// compositor state change will be sent through OnSetNeedsCommitOnMain()
+// or OnSetNeedsRedrawOnImpl(). When SwapPromiseMonitor is destroyed, it
+// will unregister itself from LayerTreeHost or LayerTreeHostImpl.
+class CC_EXPORT SwapPromiseMonitor {
+ public:
+ // If the monitor lives on the main thread, pass in layer_tree_host
+ // and set layer_tree_host_impl to NULL.
+ // If the monitor lives on the impl thread, pass in layer_tree_host_impl
+ // and set layer_tree_host to NULL.
+ SwapPromiseMonitor(LayerTreeHost* layer_tree_host,
+ LayerTreeHostImpl* layer_tree_host_impl);
+ virtual ~SwapPromiseMonitor();
+
+ virtual void OnSetNeedsCommitOnMain() = 0;
+ virtual void OnSetNeedsRedrawOnImpl() = 0;
+
+ protected:
+ LayerTreeHost* layer_tree_host_;
+ LayerTreeHostImpl* layer_tree_host_impl_;
+};
+
+} // namespace cc
+
+#endif // CC_BASE_SWAP_PROMISE_MONITOR_H_
diff --git a/chromium/cc/base/switches.cc b/chromium/cc/base/switches.cc
index 87e10ce0089..ddba9cbd444 100644
--- a/chromium/cc/base/switches.cc
+++ b/chromium/cc/base/switches.cc
@@ -36,10 +36,10 @@ const char kEnableImplSidePainting[] = "enable-impl-side-painting";
const char kEnableTopControlsPositionCalculation[] =
"enable-top-controls-position-calculation";
-// For any layers that can get drawn directly to screen, draw them with the Skia
-// GPU backend. Only valid with gl rendering + threaded compositing + impl-side
-// painting.
-const char kForceDirectLayerDrawing[] = "force-direct-layer-drawing";
+// Allow heuristics to determine when a layer tile should be drawn with
+// the Skia GPU backend. Only valid with GPU accelerated compositing +
+// impl-side painting.
+const char kEnableGPURasterization[] = "enable-gpu-rasterization";
// The height of the movable top controls.
const char kTopControlsHeight[] = "top-controls-height";
@@ -62,10 +62,6 @@ const char kTraceOverdraw[] = "trace-overdraw";
// complete, such as --slow-down-raster-scale-factor=25.
const char kSlowDownRasterScaleFactor[] = "slow-down-raster-scale-factor";
-// The scale factor for low resolution tile contents.
-const char kLowResolutionContentsScaleFactor[] =
- "low-resolution-contents-scale-factor";
-
// Max tiles allowed for each tilings interest area.
const char kMaxTilesForInterestArea[] = "max-tiles-for-interest-area";
@@ -101,6 +97,10 @@ const char kUIShowCompositedLayerBorders[] = "ui-show-layer-borders";
const char kShowFPSCounter[] = "show-fps-counter";
const char kUIShowFPSCounter[] = "ui-show-fps-counter";
+// Renders a border that represents the bounding box for the layer's animation.
+const char kShowLayerAnimationBounds[] = "show-layer-animation-bounds";
+const char kUIShowLayerAnimationBounds[] = "ui-show-layer-animation-bounds";
+
// Show rects in the HUD around layers whose properties have changed.
const char kShowPropertyChangedRects[] = "show-property-changed-rects";
const char kUIShowPropertyChangedRects[] = "ui-show-property-changed-rects";
@@ -141,14 +141,21 @@ const char kDisableMapImage[] = "disable-map-image";
// Prevents the layer tree unit tests from timing out.
const char kCCLayerTreeTestNoTimeout[] = "cc-layer-tree-test-no-timeout";
+// Makes pixel tests write their output instead of read it.
+const char kCCRebaselinePixeltests[] = "cc-rebaseline-pixeltests";
+
// Disable textures using RGBA_4444 layout.
const char kDisable4444Textures[] = "disable-4444-textures";
+// Disable touch hit testing in the compositor.
+const char kDisableCompositorTouchHitTesting[] =
+ "disable-compositor-touch-hit-testing";
+
bool IsLCDTextEnabled() {
const CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(cc::switches::kDisableLCDText))
+ if (command_line->HasSwitch(switches::kDisableLCDText))
return false;
- else if (command_line->HasSwitch(cc::switches::kEnableLCDText))
+ else if (command_line->HasSwitch(switches::kEnableLCDText))
return true;
#if defined(OS_ANDROID)
@@ -158,12 +165,13 @@ bool IsLCDTextEnabled() {
#endif
}
-bool IsImplSidePaintingEnabled() {
+namespace {
+bool CheckImplSidePaintingStatus() {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting))
+ if (command_line.HasSwitch(switches::kDisableImplSidePainting))
return false;
- else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting))
+ else if (command_line.HasSwitch(switches::kEnableImplSidePainting))
return true;
#if defined(OS_ANDROID)
@@ -173,12 +181,29 @@ bool IsImplSidePaintingEnabled() {
#endif
}
+bool CheckGPURasterizationStatus() {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ return command_line.HasSwitch(switches::kEnableGPURasterization);
+}
+
+} // namespace
+
+bool IsImplSidePaintingEnabled() {
+ static bool enabled = CheckImplSidePaintingStatus();
+ return enabled;
+}
+
+bool IsGPURasterizationEnabled() {
+ static bool enabled = CheckGPURasterizationStatus();
+ return enabled;
+}
+
bool IsMapImageEnabled() {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(cc::switches::kDisableMapImage))
+ if (command_line.HasSwitch(switches::kDisableMapImage))
return false;
- else if (command_line.HasSwitch(cc::switches::kEnableMapImage))
+ else if (command_line.HasSwitch(switches::kEnableMapImage))
return true;
return false;
diff --git a/chromium/cc/base/switches.h b/chromium/cc/base/switches.h
index 97fe833390c..19cba57bb98 100644
--- a/chromium/cc/base/switches.h
+++ b/chromium/cc/base/switches.h
@@ -24,7 +24,7 @@ CC_EXPORT extern const char kDisableCompositedAntialiasing[];
CC_EXPORT extern const char kEnableLCDText[];
CC_EXPORT extern const char kEnableImplSidePainting[];
CC_EXPORT extern const char kEnableTopControlsPositionCalculation[];
-CC_EXPORT extern const char kForceDirectLayerDrawing[];
+CC_EXPORT extern const char kEnableGPURasterization[];
CC_EXPORT extern const char kJankInsteadOfCheckerboard[];
CC_EXPORT extern const char kNumRasterThreads[];
CC_EXPORT extern const char kTopControlsHeight[];
@@ -32,7 +32,6 @@ CC_EXPORT extern const char kTopControlsHideThreshold[];
CC_EXPORT extern const char kTraceOverdraw[];
CC_EXPORT extern const char kTopControlsShowThreshold[];
CC_EXPORT extern const char kSlowDownRasterScaleFactor[];
-CC_EXPORT extern const char kLowResolutionContentsScaleFactor[];
CC_EXPORT extern const char kCompositeToMailbox[];
CC_EXPORT extern const char kMaxTilesForInterestArea[];
CC_EXPORT extern const char kMaxUnusedResourceMemoryUsagePercentage[];
@@ -42,6 +41,7 @@ CC_EXPORT extern const char kStrictLayerPropertyChangeChecking[];
CC_EXPORT extern const char kEnableMapImage[];
CC_EXPORT extern const char kDisableMapImage[];
CC_EXPORT extern const char kDisable4444Textures[];
+CC_EXPORT extern const char kDisableCompositorTouchHitTesting[];
// Switches for both the renderer and ui compositors.
CC_EXPORT extern const char kUIDisablePartialSwap[];
@@ -53,6 +53,8 @@ CC_EXPORT extern const char kShowCompositedLayerBorders[];
CC_EXPORT extern const char kUIShowCompositedLayerBorders[];
CC_EXPORT extern const char kShowFPSCounter[];
CC_EXPORT extern const char kUIShowFPSCounter[];
+CC_EXPORT extern const char kShowLayerAnimationBounds[];
+CC_EXPORT extern const char kUIShowLayerAnimationBounds[];
CC_EXPORT extern const char kShowPropertyChangedRects[];
CC_EXPORT extern const char kUIShowPropertyChangedRects[];
CC_EXPORT extern const char kShowSurfaceDamageRects[];
@@ -68,9 +70,11 @@ CC_EXPORT extern const char kUIShowNonOccludingRects[];
// Unit test related.
CC_EXPORT extern const char kCCLayerTreeTestNoTimeout[];
+CC_EXPORT extern const char kCCRebaselinePixeltests[];
CC_EXPORT bool IsLCDTextEnabled();
CC_EXPORT bool IsImplSidePaintingEnabled();
+CC_EXPORT bool IsGPURasterizationEnabled();
CC_EXPORT bool IsMapImageEnabled();
} // namespace switches
diff --git a/chromium/cc/base/util.h b/chromium/cc/base/util.h
index 1d716ae2a42..bd511786dca 100644
--- a/chromium/cc/base/util.h
+++ b/chromium/cc/base/util.h
@@ -8,6 +8,9 @@
#include <limits>
#include "base/basictypes.h"
+#include "cc/resources/resource_provider.h"
+#include "third_party/khronos/GLES2/gl2.h"
+#include "third_party/khronos/GLES2/gl2ext.h"
namespace cc {
@@ -24,6 +27,36 @@ template <typename T> T RoundDown(T n, T mul) {
: ((n - mul + 1) / mul) * mul;
}
+inline GLenum GLDataType(ResourceFormat format) {
+ DCHECK_LE(format, RESOURCE_FORMAT_MAX);
+ static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = {
+ GL_UNSIGNED_BYTE, // RGBA_8888
+ GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444
+ GL_UNSIGNED_BYTE, // BGRA_8888
+ GL_UNSIGNED_BYTE, // LUMINANCE_8
+ GL_UNSIGNED_SHORT_5_6_5, // RGB_565,
+ GL_UNSIGNED_BYTE // ETC1
+ };
+ return format_gl_data_type[format];
+}
+
+inline GLenum GLDataFormat(ResourceFormat format) {
+ DCHECK_LE(format, RESOURCE_FORMAT_MAX);
+ static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = {
+ GL_RGBA, // RGBA_8888
+ GL_RGBA, // RGBA_4444
+ GL_BGRA_EXT, // BGRA_8888
+ GL_LUMINANCE, // LUMINANCE_8
+ GL_RGB, // RGB_565
+ GL_ETC1_RGB8_OES // ETC1
+ };
+ return format_gl_data_format[format];
+}
+
+inline GLenum GLInternalFormat(ResourceFormat format) {
+ return GLDataFormat(format);
+}
+
} // namespace cc
#endif // CC_BASE_UTIL_H_