#include "cc/layers/io_surface_layer_impl.h"
#include "cc/layers/layer_impl.h"
#include "cc/layers/painted_scrollbar_layer_impl.h"
-#include "cc/layers/quad_sink.h"
#include "cc/layers/render_surface_impl.h"
#include "cc/layers/solid_color_layer_impl.h"
+#include "cc/layers/solid_color_scrollbar_layer_impl.h"
#include "cc/layers/texture_layer_impl.h"
#include "cc/layers/tiled_layer_impl.h"
#include "cc/layers/video_layer_impl.h"
public LayerTreeHostImplClient {
public:
LayerTreeHostImplTest()
- : proxy_(base::MessageLoopProxy::current()),
+ : proxy_(base::MessageLoopProxy::current(),
+ base::MessageLoopProxy::current()),
always_impl_thread_(&proxy_),
always_main_thread_blocked_(&proxy_),
shared_bitmap_manager_(new TestSharedBitmapManager()),
did_notify_ready_to_activate_(false),
did_request_commit_(false),
did_request_redraw_(false),
+ did_request_animate_(false),
did_request_manage_tiles_(false),
did_upload_visible_tile_(false),
reduce_memory_result_(true),
settings.minimum_occlusion_tracking_size = gfx::Size();
settings.impl_side_painting = true;
settings.texture_id_allocation_chunk_size = 1;
+ settings.report_overscroll_only_for_scrollable_axes = true;
return settings;
}
virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE {}
virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE {}
+ virtual void CommitVSyncParameters(base::TimeTicks timebase,
+ base::TimeDelta interval) OVERRIDE {}
+ virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) OVERRIDE {}
+ virtual void SetMaxSwapsPendingOnImplThread(int max) OVERRIDE {}
virtual void DidSwapBuffersOnImplThread() OVERRIDE {}
- virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE {}
- virtual void BeginImplFrame(const BeginFrameArgs& args) OVERRIDE {}
+ virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE {}
+ virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {}
virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE {
on_can_draw_state_changed_called_ = true;
}
virtual void NotifyReadyToActivate() OVERRIDE {
did_notify_ready_to_activate_ = true;
- host_impl_->ActivatePendingTree();
+ host_impl_->ActivateSyncTree();
}
virtual void SetNeedsRedrawOnImplThread() OVERRIDE {
did_request_redraw_ = true;
const gfx::Rect& damage_rect) OVERRIDE {
did_request_redraw_ = true;
}
+ virtual void SetNeedsAnimateOnImplThread() OVERRIDE {
+ did_request_animate_ = true;
+ }
virtual void SetNeedsManageTilesOnImplThread() OVERRIDE {
did_request_manage_tiles_ = true;
}
current_priority_cutoff_value_ = priority_cutoff;
return reduce_memory_result_;
}
- virtual void SendManagedMemoryStats() OVERRIDE {}
virtual bool IsInsideDraw() OVERRIDE { return false; }
virtual void RenewTreePriority() OVERRIDE {}
- virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay)
- OVERRIDE { requested_scrollbar_animation_delay_ = delay; }
- virtual void DidActivatePendingTree() OVERRIDE {}
+ virtual void PostDelayedScrollbarFadeOnImplThread(
+ const base::Closure& start_fade,
+ base::TimeDelta delay) OVERRIDE {
+ scrollbar_fade_start_ = start_fade;
+ requested_scrollbar_animation_delay_ = delay;
+ }
+ virtual void DidActivateSyncTree() OVERRIDE {}
virtual void DidManageTiles() OVERRIDE {}
void set_reduce_memory_result(bool reduce_memory_result) {
}
void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) {
- root->SetAnchorPoint(gfx::PointF());
root->SetPosition(gfx::PointF());
root->SetBounds(gfx::Size(10, 10));
root->SetContentBounds(gfx::Size(10, 10));
root->SetBounds(content_size);
root->SetContentBounds(content_size);
root->SetPosition(gfx::PointF());
- root->SetAnchorPoint(gfx::PointF());
scoped_ptr<LayerImpl> scroll =
LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId);
scroll->SetBounds(content_size);
scroll->SetContentBounds(content_size);
scroll->SetPosition(gfx::PointF());
- scroll->SetAnchorPoint(gfx::PointF());
scroll->SetIsContainerForFixedPositionLayers(true);
scoped_ptr<LayerImpl> contents =
contents->SetBounds(content_size);
contents->SetContentBounds(content_size);
contents->SetPosition(gfx::PointF());
- contents->SetAnchorPoint(gfx::PointF());
scroll->AddChild(contents.Pass());
page_scale->AddChild(scroll.Pass());
void DrawFrame() {
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
}
void DrawOneFrame() {
LayerTreeHostImpl::FrameData frame_data;
- host_impl_->PrepareToDraw(&frame_data, gfx::Rect());
+ host_impl_->PrepareToDraw(&frame_data);
host_impl_->DidDrawAllLayers(frame_data);
}
bool did_notify_ready_to_activate_;
bool did_request_commit_;
bool did_request_redraw_;
+ bool did_request_animate_;
bool did_request_manage_tiles_;
bool did_upload_visible_tile_;
bool reduce_memory_result_;
+ base::Closure scrollbar_fade_start_;
base::TimeDelta requested_scrollbar_animation_delay_;
size_t current_limit_bytes_;
int current_priority_cutoff_value_;
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
+ EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(),
+ InputHandler::Wheel));
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
+ EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10),
+ InputHandler::Wheel));
host_impl_->ScrollEnd();
+ EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(),
+ InputHandler::Wheel));
EXPECT_TRUE(did_request_redraw_);
EXPECT_TRUE(did_request_commit_);
}
// We should not crash when trying to scroll after the renderer initialization
// fails.
- EXPECT_EQ(InputHandler::ScrollIgnored,
+ EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
}
EXPECT_EQ(InputHandler::ScrollOnMainThread,
host_impl_->ScrollBegin(gfx::Point(25, 25),
InputHandler::Wheel));
+ EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25),
+ InputHandler::Wheel));
EXPECT_EQ(InputHandler::ScrollOnMainThread,
host_impl_->ScrollBegin(gfx::Point(25, 25),
InputHandler::Gesture));
+ EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25),
+ InputHandler::Gesture));
// All scroll types outside this region should succeed.
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(75, 75),
InputHandler::Wheel));
+ EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75),
+ InputHandler::Gesture));
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
+ EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25),
+ InputHandler::Gesture));
host_impl_->ScrollEnd();
+ EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75),
+ InputHandler::Gesture));
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(75, 75),
InputHandler::Gesture));
+ EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75),
+ InputHandler::Gesture));
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
host_impl_->ScrollEnd();
+ EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75),
+ InputHandler::Gesture));
}
TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) {
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(40, 10),
InputHandler::Wheel));
+ EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(40, 10),
+ InputHandler::Wheel));
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 1));
host_impl_->ScrollEnd();
InputHandler::Wheel));
}
+TEST_F(LayerTreeHostImplTest, ScrollHandlerNotPresent) {
+ LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200));
+ EXPECT_FALSE(scroll_layer->have_scroll_event_handlers());
+ host_impl_->SetViewportSize(gfx::Size(50, 50));
+ DrawFrame();
+
+ EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler());
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture);
+ EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler());
+ host_impl_->ScrollEnd();
+ EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler());
+}
+
+TEST_F(LayerTreeHostImplTest, ScrollHandlerPresent) {
+ LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200));
+ scroll_layer->SetHaveScrollEventHandlers(true);
+ host_impl_->SetViewportSize(gfx::Size(50, 50));
+ DrawFrame();
+
+ EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler());
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture);
+ EXPECT_TRUE(host_impl_->scroll_affects_scroll_handler());
+ host_impl_->ScrollEnd();
+ EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler());
+}
+
TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) {
SetupScrollAndContentsLayers(gfx::Size(200, 200));
host_impl_->SetViewportSize(gfx::Size(100, 100));
overflow->SetScrollClipLayer(scroll_layer->parent()->id());
overflow->SetScrollOffset(gfx::Vector2d());
overflow->SetPosition(gfx::PointF());
- overflow->SetAnchorPoint(gfx::PointF());
DrawFrame();
gfx::Point scroll_position(10, 10);
scroll_layer->FixedContainerSizeDelta());
host_impl_->PinchGestureEnd();
host_impl_->ScrollEnd();
+ EXPECT_FALSE(did_request_animate_);
EXPECT_TRUE(did_request_redraw_);
EXPECT_TRUE(did_request_commit_);
EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds());
}
}
+TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) {
+ ui::LatencyInfo latency_info;
+ latency_info.trace_id = 1234;
+ scoped_ptr<SwapPromise> swap_promise(
+ new LatencyInfoSwapPromise(latency_info));
+
+ SetupScrollAndContentsLayers(gfx::Size(100, 100));
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
+ host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(swap_promise.Pass());
+ host_impl_->ScrollEnd();
+
+ scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas();
+ EXPECT_EQ(1u, scroll_info->swap_promises.size());
+ EXPECT_EQ(latency_info.trace_id, scroll_info->swap_promises[0]->TraceId());
+}
+
+TEST_F(LayerTreeHostImplTest, MasksToBoundsDoesntClobberInnerContainerSize) {
+ SetupScrollAndContentsLayers(gfx::Size(100, 100));
+ host_impl_->SetViewportSize(gfx::Size(50, 50));
+ DrawFrame();
+
+ LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
+ LayerImpl* container_layer = scroll_layer->scroll_clip_layer();
+ DCHECK(scroll_layer);
+
+ float min_page_scale = 1.f;
+ float max_page_scale = 4.f;
+ host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
+ min_page_scale,
+ max_page_scale);
+
+ // If the container's masks_to_bounds is false, the viewport size should
+ // overwrite the inner viewport container layer's size.
+ {
+ EXPECT_EQ(gfx::Size(50, 50),
+ container_layer->bounds());
+ container_layer->SetMasksToBounds(false);
+
+ container_layer->SetBounds(gfx::Size(30, 25));
+ EXPECT_EQ(gfx::Size(30, 25),
+ container_layer->bounds());
+
+ // This should cause a reset of the inner viewport container layer's bounds.
+ host_impl_->DidChangeTopControlsPosition();
+
+ EXPECT_EQ(gfx::Size(50, 50),
+ container_layer->bounds());
+ }
+
+ host_impl_->SetViewportSize(gfx::Size(50, 50));
+ container_layer->SetBounds(gfx::Size(50, 50));
+
+ // If the container's masks_to_bounds is true, the viewport size should
+ // *NOT* overwrite the inner viewport container layer's size.
+ {
+ EXPECT_EQ(gfx::Size(50, 50),
+ container_layer->bounds());
+ container_layer->SetMasksToBounds(true);
+
+ container_layer->SetBounds(gfx::Size(30, 25));
+ EXPECT_EQ(gfx::Size(30, 25),
+ container_layer->bounds());
+
+ // This should cause a reset of the inner viewport container layer's bounds.
+ host_impl_->DidChangeTopControlsPosition();
+
+ EXPECT_EQ(gfx::Size(30, 25),
+ container_layer->bounds());
+ }
+}
+
TEST_F(LayerTreeHostImplTest, PinchGesture) {
SetupScrollAndContentsLayers(gfx::Size(100, 100));
host_impl_->SetViewportSize(gfx::Size(50, 50));
host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50));
host_impl_->PinchGestureEnd();
host_impl_->ScrollEnd();
+ EXPECT_FALSE(did_request_animate_);
EXPECT_TRUE(did_request_redraw_);
EXPECT_TRUE(did_request_commit_);
max_page_scale);
scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50));
+ did_request_redraw_ = false;
+ did_request_animate_ = false;
host_impl_->StartPageScaleAnimation(gfx::Vector2d(), false, 2.f, duration);
+ EXPECT_FALSE(did_request_redraw_);
+ EXPECT_TRUE(did_request_animate_);
+
did_request_redraw_ = false;
+ did_request_animate_ = false;
host_impl_->Animate(start_time);
EXPECT_TRUE(did_request_redraw_);
+ EXPECT_TRUE(did_request_animate_);
did_request_redraw_ = false;
+ did_request_animate_ = false;
host_impl_->Animate(halfway_through_animation);
EXPECT_TRUE(did_request_redraw_);
+ EXPECT_TRUE(did_request_animate_);
did_request_redraw_ = false;
+ did_request_animate_ = false;
did_request_commit_ = false;
host_impl_->Animate(end_time);
EXPECT_TRUE(did_request_commit_);
+ EXPECT_FALSE(did_request_animate_);
scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();
max_page_scale);
scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50));
+ did_request_redraw_ = false;
+ did_request_animate_ = false;
host_impl_->StartPageScaleAnimation(
gfx::Vector2d(25, 25), true, min_page_scale, duration);
+ EXPECT_FALSE(did_request_redraw_);
+ EXPECT_TRUE(did_request_animate_);
+
did_request_redraw_ = false;
+ did_request_animate_ = false;
host_impl_->Animate(start_time);
EXPECT_TRUE(did_request_redraw_);
+ EXPECT_TRUE(did_request_animate_);
did_request_redraw_ = false;
did_request_commit_ = false;
+ did_request_animate_ = false;
host_impl_->Animate(end_time);
EXPECT_TRUE(did_request_redraw_);
+ EXPECT_FALSE(did_request_animate_);
EXPECT_TRUE(did_request_commit_);
scoped_ptr<ScrollAndScaleSet> scroll_info =
base::TimeTicks fake_current_physical_time_;
};
+#define SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST() \
+ gfx::Size viewport_size(10, 10); \
+ gfx::Size content_size(100, 100); \
+ \
+ LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = \
+ new LayerTreeHostImplOverridePhysicalTime(settings, \
+ this, \
+ &proxy_, \
+ shared_bitmap_manager_.get(), \
+ &stats_instrumentation_); \
+ host_impl_ = make_scoped_ptr(host_impl_override_time); \
+ host_impl_->InitializeRenderer(CreateOutputSurface()); \
+ host_impl_->SetViewportSize(viewport_size); \
+ \
+ scoped_ptr<LayerImpl> root = \
+ LayerImpl::Create(host_impl_->active_tree(), 1); \
+ root->SetBounds(viewport_size); \
+ \
+ scoped_ptr<LayerImpl> scroll = \
+ LayerImpl::Create(host_impl_->active_tree(), 2); \
+ scroll->SetScrollClipLayer(root->id()); \
+ scroll->SetScrollOffset(gfx::Vector2d()); \
+ root->SetBounds(viewport_size); \
+ scroll->SetBounds(content_size); \
+ scroll->SetContentBounds(content_size); \
+ scroll->SetIsContainerForFixedPositionLayers(true); \
+ \
+ scoped_ptr<LayerImpl> contents = \
+ LayerImpl::Create(host_impl_->active_tree(), 3); \
+ contents->SetDrawsContent(true); \
+ contents->SetBounds(content_size); \
+ contents->SetContentBounds(content_size); \
+ \
+ scoped_ptr<SolidColorScrollbarLayerImpl> scrollbar = \
+ SolidColorScrollbarLayerImpl::Create( \
+ host_impl_->active_tree(), 4, VERTICAL, 10, 0, false, true); \
+ EXPECT_FLOAT_EQ(0.f, scrollbar->opacity()); \
+ \
+ scroll->AddChild(contents.Pass()); \
+ root->AddChild(scroll.Pass()); \
+ scrollbar->SetScrollLayerAndClipLayerByIds(2, 1); \
+ root->AddChild(scrollbar.PassAs<LayerImpl>()); \
+ \
+ host_impl_->active_tree()->SetRootLayer(root.Pass()); \
+ host_impl_->active_tree()->SetViewportLayersFromIds( \
+ 1, 2, Layer::INVALID_ID); \
+ host_impl_->active_tree()->DidBecomeActive(); \
+ DrawFrame();
+
TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) {
LayerTreeSettings settings;
settings.scrollbar_animator = LayerTreeSettings::LinearFade;
- settings.scrollbar_linear_fade_delay_ms = 20;
- settings.scrollbar_linear_fade_length_ms = 20;
-
- gfx::Size viewport_size(10, 10);
- gfx::Size content_size(100, 100);
-
- LayerTreeHostImplOverridePhysicalTime* host_impl_override_time =
- new LayerTreeHostImplOverridePhysicalTime(settings,
- this,
- &proxy_,
- shared_bitmap_manager_.get(),
- &stats_instrumentation_);
- host_impl_ = make_scoped_ptr(host_impl_override_time);
- host_impl_->InitializeRenderer(CreateOutputSurface());
- host_impl_->SetViewportSize(viewport_size);
-
- scoped_ptr<LayerImpl> root =
- LayerImpl::Create(host_impl_->active_tree(), 1);
- root->SetBounds(viewport_size);
-
- scoped_ptr<LayerImpl> scroll =
- LayerImpl::Create(host_impl_->active_tree(), 2);
- scroll->SetScrollClipLayer(root->id());
- scroll->SetScrollOffset(gfx::Vector2d());
- root->SetBounds(viewport_size);
- scroll->SetBounds(content_size);
- scroll->SetContentBounds(content_size);
- scroll->SetIsContainerForFixedPositionLayers(true);
-
- scoped_ptr<LayerImpl> contents =
- LayerImpl::Create(host_impl_->active_tree(), 3);
- contents->SetDrawsContent(true);
- contents->SetBounds(content_size);
- contents->SetContentBounds(content_size);
-
- scoped_ptr<PaintedScrollbarLayerImpl> scrollbar =
- PaintedScrollbarLayerImpl::Create(host_impl_->active_tree(), 4, VERTICAL);
- scrollbar->SetScrollLayerById(2);
- scrollbar->SetClipLayerById(1);
-
- scroll->AddChild(contents.Pass());
- root->AddChild(scroll.Pass());
- root->AddChild(scrollbar.PassAs<LayerImpl>());
+ settings.scrollbar_fade_delay_ms = 20;
+ settings.scrollbar_fade_duration_ms = 20;
- host_impl_->active_tree()->SetRootLayer(root.Pass());
- host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID);
- host_impl_->active_tree()->DidBecomeActive();
- DrawFrame();
+ SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST();
base::TimeTicks fake_now = gfx::FrameTime::Now();
- host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now);
- // If no scroll happened recently, StartScrollbarAnimation should have no
- // effect.
- host_impl_->StartScrollbarAnimation();
EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
EXPECT_FALSE(did_request_redraw_);
- // If no scroll happened during a scroll gesture, StartScrollbarAnimation
- // should have no effect.
+ // If no scroll happened during a scroll gesture, it should have no effect.
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel);
host_impl_->ScrollEnd();
- host_impl_->StartScrollbarAnimation();
EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
EXPECT_FALSE(did_request_redraw_);
+ EXPECT_TRUE(scrollbar_fade_start_.Equals(base::Closure()));
// After a scroll, a fade animation should be scheduled about 20ms from now.
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel);
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0));
host_impl_->ScrollEnd();
did_request_redraw_ = false;
- host_impl_->StartScrollbarAnimation();
+ did_request_animate_ = false;
EXPECT_LT(base::TimeDelta::FromMilliseconds(19),
requested_scrollbar_animation_delay_);
EXPECT_FALSE(did_request_redraw_);
+ EXPECT_FALSE(did_request_animate_);
requested_scrollbar_animation_delay_ = base::TimeDelta();
+ scrollbar_fade_start_.Run();
+ host_impl_->Animate(fake_now);
// After the fade begins, we should start getting redraws instead of a
// scheduled animation.
fake_now += base::TimeDelta::FromMilliseconds(25);
- host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now);
- host_impl_->StartScrollbarAnimation();
- EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
- EXPECT_TRUE(did_request_redraw_);
- did_request_redraw_ = false;
-
- // If no scroll happened recently, StartScrollbarAnimation should have no
- // effect.
- fake_now += base::TimeDelta::FromMilliseconds(25);
- host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now);
- host_impl_->StartScrollbarAnimation();
EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
- EXPECT_FALSE(did_request_redraw_);
+ EXPECT_TRUE(did_request_animate_);
+ did_request_animate_ = false;
// Setting the scroll offset outside a scroll should also cause the scrollbar
// to appear and to schedule a fade.
host_impl_->InnerViewportScrollLayer()->SetScrollOffset(gfx::Vector2d(5, 5));
- host_impl_->StartScrollbarAnimation();
EXPECT_LT(base::TimeDelta::FromMilliseconds(19),
requested_scrollbar_animation_delay_);
EXPECT_FALSE(did_request_redraw_);
+ EXPECT_FALSE(did_request_animate_);
+ requested_scrollbar_animation_delay_ = base::TimeDelta();
+}
+
+TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) {
+ LayerTreeSettings settings;
+ settings.scrollbar_animator = LayerTreeSettings::LinearFade;
+ settings.scrollbar_fade_delay_ms = 20;
+ settings.scrollbar_fade_duration_ms = 20;
+ settings.use_pinch_zoom_scrollbars = true;
+
+ SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST();
+
+ base::TimeTicks fake_now = gfx::FrameTime::Now();
+
+ host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f);
+
+ EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
+ EXPECT_FALSE(did_request_animate_);
+
+ // If no scroll happened during a scroll gesture, it should have no effect.
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel);
+ host_impl_->ScrollEnd();
+ EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
+ EXPECT_FALSE(did_request_animate_);
+ EXPECT_TRUE(scrollbar_fade_start_.Equals(base::Closure()));
+
+ // After a scroll, no fade animation should be scheduled.
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel);
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0));
+ host_impl_->ScrollEnd();
+ did_request_redraw_ = false;
+ EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
+ EXPECT_FALSE(did_request_animate_);
+ requested_scrollbar_animation_delay_ = base::TimeDelta();
+
+ // We should not see any draw requests.
+ fake_now += base::TimeDelta::FromMilliseconds(25);
+ EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
+ EXPECT_FALSE(did_request_animate_);
+
+ // Make page scale > min so that subsequent scrolls will trigger fades.
+ host_impl_->active_tree()->SetPageScaleDelta(1.1f);
+
+ // After a scroll, a fade animation should be scheduled about 20ms from now.
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel);
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0));
+ host_impl_->ScrollEnd();
+ did_request_redraw_ = false;
+ EXPECT_LT(base::TimeDelta::FromMilliseconds(19),
+ requested_scrollbar_animation_delay_);
+ EXPECT_FALSE(did_request_animate_);
requested_scrollbar_animation_delay_ = base::TimeDelta();
+ scrollbar_fade_start_.Run();
- // None of the above should have called CurrentFrameTimeTicks, so if we call
- // it now we should get the current time.
- fake_now += base::TimeDelta::FromMilliseconds(10);
- host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now);
- EXPECT_EQ(fake_now, host_impl_->CurrentFrameTimeTicks());
+ // After the fade begins, we should start getting redraws instead of a
+ // scheduled animation.
+ fake_now += base::TimeDelta::FromMilliseconds(25);
+ host_impl_->Animate(fake_now);
+ EXPECT_TRUE(did_request_animate_);
}
void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale(
float device_scale_factor) {
LayerTreeSettings settings;
+ settings.scrollbar_fade_delay_ms = 500;
+ settings.scrollbar_fade_duration_ms = 300;
settings.scrollbar_animator = LayerTreeSettings::Thinning;
gfx::Size viewport_size(300, 200);
scrollbar->SetBounds(gfx::Size(15, viewport_size.height()));
scrollbar->SetContentBounds(gfx::Size(15, viewport_size.height()));
scrollbar->SetPosition(gfx::Point(285, 0));
- scrollbar->SetScrollLayerById(2);
scroll->AddChild(contents.Pass());
root->AddChild(scroll.Pass());
+ scrollbar->SetScrollLayerAndClipLayerByIds(2, 1);
root->AddChild(scrollbar.PassAs<LayerImpl>());
host_impl_->active_tree()->SetRootLayer(root.Pass());
host_impl_->MakeCompositorFrameMetadata();
EXPECT_EQ(gfx::Vector2dF(), metadata.root_scroll_offset);
EXPECT_EQ(1.f, metadata.page_scale_factor);
- EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.viewport_size);
+ EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.scrollable_viewport_size);
EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size);
EXPECT_EQ(0.5f, metadata.min_page_scale_factor);
EXPECT_EQ(4.f, metadata.max_page_scale_factor);
host_impl_->MakeCompositorFrameMetadata();
EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset);
EXPECT_EQ(2.f, metadata.page_scale_factor);
- EXPECT_EQ(gfx::SizeF(25.f, 25.f), metadata.viewport_size);
+ EXPECT_EQ(gfx::SizeF(25.f, 25.f), metadata.scrollable_viewport_size);
EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size);
EXPECT_EQ(0.5f, metadata.min_page_scale_factor);
EXPECT_EQ(4.f, metadata.max_page_scale_factor);
host_impl_->MakeCompositorFrameMetadata();
EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset);
EXPECT_EQ(4.f, metadata.page_scale_factor);
- EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.viewport_size);
+ EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.scrollable_viewport_size);
EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size);
EXPECT_EQ(0.5f, metadata.min_page_scale_factor);
EXPECT_EQ(4.f, metadata.max_page_scale_factor);
}
}
-// TODO(enne): Convert this to PictureLayerImpl
-class DidDrawCheckLayer : public TiledLayerImpl {
+class DidDrawCheckLayer : public LayerImpl {
public:
static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
return scoped_ptr<LayerImpl>(new DidDrawCheckLayer(tree_impl, id));
will_draw_called_ = true;
if (will_draw_returns_false_)
return false;
- return TiledLayerImpl::WillDraw(draw_mode, provider);
+ return LayerImpl::WillDraw(draw_mode, provider);
}
- virtual void AppendQuads(QuadSink* quad_sink,
+ virtual void AppendQuads(RenderPass* render_pass,
+ const OcclusionTracker<LayerImpl>& occlusion_tracker,
AppendQuadsData* append_quads_data) OVERRIDE {
append_quads_called_ = true;
- TiledLayerImpl::AppendQuads(quad_sink, append_quads_data);
+ LayerImpl::AppendQuads(render_pass, occlusion_tracker, append_quads_data);
}
virtual void DidDraw(ResourceProvider* provider) OVERRIDE {
did_draw_called_ = true;
- TiledLayerImpl::DidDraw(provider);
+ LayerImpl::DidDraw(provider);
}
bool will_draw_called() const { return will_draw_called_; }
protected:
DidDrawCheckLayer(LayerTreeImpl* tree_impl, int id)
- : TiledLayerImpl(tree_impl, id),
+ : LayerImpl(tree_impl, id),
will_draw_returns_false_(false),
will_draw_called_(false),
append_quads_called_(false),
did_draw_called_(false) {
- SetAnchorPoint(gfx::PointF());
SetBounds(gfx::Size(10, 10));
SetContentBounds(gfx::Size(10, 10));
SetDrawsContent(true);
- set_skips_draw(false);
draw_properties().visible_content_rect = gfx::Rect(0, 0, 10, 10);
-
- scoped_ptr<LayerTilingData> tiler =
- LayerTilingData::Create(gfx::Size(100, 100),
- LayerTilingData::HAS_BORDER_TEXELS);
- tiler->SetBounds(content_bounds());
- SetTilingData(*tiler.get());
}
private:
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
EXPECT_TRUE(layer->did_draw_called());
}
+ host_impl_->SetViewportDamage(gfx::Rect(10, 10));
+
{
LayerTreeHostImpl::FrameData frame;
layer->set_will_draw_returns_false();
layer->ClearDidDrawCheck();
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect(10, 10)));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
EXPECT_FALSE(layer->will_draw_called());
EXPECT_FALSE(layer->did_draw_called());
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
EXPECT_FALSE(layer->will_draw_called());
EXPECT_FALSE(layer->did_draw_called());
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
EXPECT_FALSE(top_layer->will_draw_called());
EXPECT_FALSE(top_layer->did_draw_called());
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
EXPECT_FALSE(layer2->did_draw_called());
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
+ host_impl_->active_tree()->root_layer());
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl,
int id,
bool tile_missing,
- bool skips_draw,
+ bool had_incomplete_tile,
bool animating,
ResourceProvider* resource_provider) {
- return scoped_ptr<LayerImpl>(new MissingTextureAnimatingLayer(
- tree_impl,
- id,
- tile_missing,
- skips_draw,
- animating,
- resource_provider));
+ return scoped_ptr<LayerImpl>(
+ new MissingTextureAnimatingLayer(tree_impl,
+ id,
+ tile_missing,
+ had_incomplete_tile,
+ animating,
+ resource_provider));
}
- virtual void AppendQuads(QuadSink* quad_sink,
+ virtual void AppendQuads(RenderPass* render_pass,
+ const OcclusionTracker<LayerImpl>& occlusion_tracker,
AppendQuadsData* append_quads_data) OVERRIDE {
- TiledLayerImpl::AppendQuads(quad_sink, append_quads_data);
+ LayerImpl::AppendQuads(render_pass, occlusion_tracker, append_quads_data);
+ if (had_incomplete_tile_)
+ append_quads_data->num_incomplete_tiles++;
if (tile_missing_)
- append_quads_data->had_incomplete_tile = true;
+ append_quads_data->num_missing_tiles++;
}
private:
MissingTextureAnimatingLayer(LayerTreeImpl* tree_impl,
int id,
bool tile_missing,
- bool skips_draw,
+ bool had_incomplete_tile,
bool animating,
ResourceProvider* resource_provider)
- : DidDrawCheckLayer(tree_impl, id), tile_missing_(tile_missing) {
- scoped_ptr<LayerTilingData> tiling_data =
- LayerTilingData::Create(gfx::Size(10, 10),
- LayerTilingData::NO_BORDER_TEXELS);
- tiling_data->SetBounds(bounds());
- SetTilingData(*tiling_data.get());
- set_skips_draw(skips_draw);
- if (!tile_missing) {
- ResourceProvider::ResourceId resource =
- resource_provider->CreateResource(gfx::Size(1, 1),
- GL_CLAMP_TO_EDGE,
- ResourceProvider::TextureUsageAny,
- RGBA_8888);
- resource_provider->AllocateForTesting(resource);
- PushTileProperties(0, 0, resource, gfx::Rect(), false);
- }
+ : DidDrawCheckLayer(tree_impl, id),
+ tile_missing_(tile_missing),
+ had_incomplete_tile_(had_incomplete_tile) {
if (animating)
AddAnimatedTransformToLayer(this, 10.0, 3, 0);
}
bool tile_missing_;
+ bool had_incomplete_tile_;
};
-TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenNoTexturesMissing) {
+TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsOnDefault) {
host_impl_->active_tree()->SetRootLayer(
DidDrawCheckLayer::Create(host_impl_->active_tree(), 1));
DidDrawCheckLayer* root =
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
bool tile_missing = false;
- bool skips_draw = false;
+ bool had_incomplete_tile = false;
bool is_animating = false;
root->AddChild(
MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2,
tile_missing,
- skips_draw,
+ had_incomplete_tile,
is_animating,
host_impl_->resource_provider()));
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
}
DidDrawCheckLayer* root =
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
bool tile_missing = false;
- bool skips_draw = false;
+ bool had_incomplete_tile = false;
bool is_animating = true;
root->AddChild(
MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
2,
tile_missing,
- skips_draw,
+ had_incomplete_tile,
is_animating,
host_impl_->resource_provider()));
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
}
-TEST_F(LayerTreeHostImplTest,
- PrepareToDrawSucceedsWithNonAnimatedMissingTexture) {
- // When a texture is missing and we're not animating, we draw as usual with
- // checkerboarding.
+TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithMissingTiles) {
host_impl_->active_tree()->SetRootLayer(
DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
DidDrawCheckLayer* root =
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
bool tile_missing = true;
- bool skips_draw = false;
+ bool had_incomplete_tile = false;
+ bool is_animating = false;
+ root->AddChild(
+ MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
+ 4,
+ tile_missing,
+ had_incomplete_tile,
+ is_animating,
+ host_impl_->resource_provider()));
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame);
+}
+
+TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWithIncompleteTile) {
+ host_impl_->active_tree()->SetRootLayer(
+ DidDrawCheckLayer::Create(host_impl_->active_tree(), 3));
+ DidDrawCheckLayer* root =
+ static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
+
+ bool tile_missing = false;
+ bool had_incomplete_tile = true;
bool is_animating = false;
root->AddChild(
MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
4,
tile_missing,
- skips_draw,
+ had_incomplete_tile,
is_animating,
host_impl_->resource_provider()));
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
}
-TEST_F(LayerTreeHostImplTest, PrepareToDrawFailsWhenAnimationUsesCheckerboard) {
- // When a texture is missing and we're animating, we don't want to draw
- // anything.
+TEST_F(LayerTreeHostImplTest,
+ PrepareToDrawFailsWithAnimationAndMissingTilesUsesCheckerboard) {
host_impl_->active_tree()->SetRootLayer(
DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
DidDrawCheckLayer* root =
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
bool tile_missing = true;
- bool skips_draw = false;
+ bool had_incomplete_tile = false;
bool is_animating = true;
root->AddChild(
MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
6,
tile_missing,
- skips_draw,
+ had_incomplete_tile,
is_animating,
host_impl_->resource_provider()));
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_ABORTED_CHECKERBOARD_ANIMATIONS,
+ host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
}
TEST_F(LayerTreeHostImplTest,
- PrepareToDrawSucceedsWithMissingSkippedAnimatedLayer) {
- // When the layer skips draw and we're animating, we still draw the frame.
+ PrepareToDrawSucceedsWithAnimationAndIncompleteTiles) {
host_impl_->active_tree()->SetRootLayer(
- DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
+ DidDrawCheckLayer::Create(host_impl_->active_tree(), 5));
DidDrawCheckLayer* root =
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
bool tile_missing = false;
- bool skips_draw = true;
+ bool had_incomplete_tile = true;
bool is_animating = true;
root->AddChild(
MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
+ 6,
+ tile_missing,
+ had_incomplete_tile,
+ is_animating,
+ host_impl_->resource_provider()));
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame);
+}
+
+TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsWhenHighResRequired) {
+ host_impl_->active_tree()->SetRootLayer(
+ DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
+ DidDrawCheckLayer* root =
+ static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
+ bool tile_missing = false;
+ bool had_incomplete_tile = false;
+ bool is_animating = false;
+ root->AddChild(
+ MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
8,
tile_missing,
- skips_draw,
+ had_incomplete_tile,
is_animating,
host_impl_->resource_provider()));
+ host_impl_->active_tree()->SetRequiresHighResToDraw();
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()),
- DrawSwapReadbackResult::DRAW_SUCCESS);
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
}
TEST_F(LayerTreeHostImplTest,
- PrepareToDrawSucceedsWhenHighResRequiredButNoMissingTextures) {
- // When the layer skips draw and we're animating, we still draw the frame.
+ PrepareToDrawFailsWhenHighResRequiredAndIncompleteTiles) {
host_impl_->active_tree()->SetRootLayer(
DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
DidDrawCheckLayer* root =
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
bool tile_missing = false;
- bool skips_draw = false;
+ bool had_incomplete_tile = true;
bool is_animating = false;
root->AddChild(
MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
8,
tile_missing,
- skips_draw,
+ had_incomplete_tile,
is_animating,
host_impl_->resource_provider()));
host_impl_->active_tree()->SetRequiresHighResToDraw();
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()),
- DrawSwapReadbackResult::DRAW_SUCCESS);
+ EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
+ host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
}
TEST_F(LayerTreeHostImplTest,
- PrepareToDrawFailsWhenHighResRequiredAndMissingTextures) {
- // When the layer skips draw and we're animating, we still draw the frame.
+ PrepareToDrawFailsWhenHighResRequiredAndMissingTile) {
host_impl_->active_tree()->SetRootLayer(
DidDrawCheckLayer::Create(host_impl_->active_tree(), 7));
DidDrawCheckLayer* root =
static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer());
bool tile_missing = true;
- bool skips_draw = false;
+ bool had_incomplete_tile = false;
bool is_animating = false;
root->AddChild(
MissingTextureAnimatingLayer::Create(host_impl_->active_tree(),
8,
tile_missing,
- skips_draw,
+ had_incomplete_tile,
is_animating,
host_impl_->resource_provider()));
host_impl_->active_tree()->SetRequiresHighResToDraw();
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(host_impl_->PrepareToDraw(&frame, gfx::Rect()),
- DrawSwapReadbackResult::DRAW_ABORTED_MISSING_HIGH_RES_CONTENT);
+ EXPECT_EQ(DRAW_ABORTED_MISSING_HIGH_RES_CONTENT,
+ host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
}
root->SetBounds(layer_size_);
root->SetContentBounds(layer_size_);
root->SetPosition(gfx::PointF());
- root->SetAnchorPoint(gfx::PointF());
root->SetDrawsContent(false);
root->SetIsContainerForFixedPositionLayers(true);
int inner_viewport_scroll_layer_id = root->id();
LayerImpl::Create(host_impl_->active_tree(), 1);
content_layer->SetDrawsContent(true);
content_layer->SetPosition(gfx::PointF());
- content_layer->SetAnchorPoint(gfx::PointF());
content_layer->SetBounds(contents_size);
content_layer->SetContentBounds(contents_size);
content_layer->SetContentsScale(2.f, 2.f);
scroll_layer->SetBounds(contents_size);
scroll_layer->SetContentBounds(contents_size);
scroll_layer->SetPosition(gfx::PointF());
- scroll_layer->SetAnchorPoint(gfx::PointF());
scroll_layer->AddChild(content_layer.Pass());
scroll_clip_layer->AddChild(scroll_layer.Pass());
// Make sure all the layers are drawn with the page scale delta applied, i.e.,
// the page scale delta on the root layer is applied hierarchically.
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
// Only allow vertical scrolling.
clip_layer->SetBounds(
gfx::Size(child->bounds().width(), child->bounds().height() / 2));
- // The rotation depends on the layer's anchor point, and the child layer is a
- // different size than the clip, so make sure the clip layer's anchor lines
- // up over the child.
- clip_layer->SetAnchorPoint(gfx::PointF(0.5, 1.0));
+ // The rotation depends on the layer's transform origin, and the child layer
+ // is a different size than the clip, so make sure the clip layer's origin
+ // lines up over the child.
+ clip_layer->SetTransformOrigin(gfx::Point3F(
+ clip_layer->bounds().width() * 0.5f, clip_layer->bounds().height(), 0.f));
LayerImpl* child_ptr = child.get();
clip_layer->AddChild(child.Pass());
scroll_layer->AddChild(clip_layer.Pass());
virtual ~TestScrollOffsetDelegate() {}
- virtual void SetMaxScrollOffset(
- const gfx::Vector2dF& max_scroll_offset) OVERRIDE {
- max_scroll_offset_ = max_scroll_offset;
- }
-
- virtual void SetTotalScrollOffset(const gfx::Vector2dF& new_value) OVERRIDE {
- last_set_scroll_offset_ = new_value;
- }
-
virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE {
return getter_return_value_;
}
virtual bool IsExternalFlingActive() const OVERRIDE { return false; }
- virtual void SetTotalPageScaleFactorAndLimits(
- float page_scale_factor,
- float min_page_scale_factor,
- float max_page_scale_factor) OVERRIDE {
+ virtual void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset,
+ const gfx::Vector2dF& max_scroll_offset,
+ const gfx::SizeF& scrollable_size,
+ float page_scale_factor,
+ float min_page_scale_factor,
+ float max_page_scale_factor) OVERRIDE {
+ DCHECK(total_scroll_offset.x() <= max_scroll_offset.x());
+ DCHECK(total_scroll_offset.y() <= max_scroll_offset.y());
+ last_set_scroll_offset_ = total_scroll_offset;
+ max_scroll_offset_ = max_scroll_offset;
+ scrollable_size_ = scrollable_size;
page_scale_factor_ = page_scale_factor;
min_page_scale_factor_ = min_page_scale_factor;
max_page_scale_factor_ = max_page_scale_factor;
}
- virtual void SetScrollableSize(const gfx::SizeF& scrollable_size) OVERRIDE {
- scrollable_size_ = scrollable_size;
- }
-
gfx::Vector2dF last_set_scroll_offset() {
return last_set_scroll_offset_;
}
EXPECT_EQ(0.5f, scroll_delegate.min_page_scale_factor());
EXPECT_EQ(4.f, scroll_delegate.max_page_scale_factor());
+ // The pinch gesture doesn't put the delegate into a state where the scroll
+ // offset is outside of the scroll range. (this is verified by DCHECKs in the
+ // delegate).
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture);
+ host_impl_->PinchGestureBegin();
+ host_impl_->PinchGestureUpdate(2.f, gfx::Point());
+ host_impl_->PinchGestureUpdate(.5f, gfx::Point());
+ host_impl_->PinchGestureEnd();
+ host_impl_->ScrollEnd();
+
// Scrolling should be relative to the offset as returned by the delegate.
gfx::Vector2dF scroll_delta(0.f, 10.f);
gfx::Vector2dF current_offset(7.f, 8.f);
EXPECT_EQ(current_offset + scroll_delta,
scroll_delegate.last_set_scroll_offset());
host_impl_->ScrollEnd();
+ scroll_delegate.set_getter_return_value(gfx::Vector2dF());
// Forces a full tree synchronization and ensures that the scroll delegate
// sees the correct size of the new tree.
gfx::Size new_size(42, 24);
host_impl_->CreatePendingTree();
CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size);
- host_impl_->ActivatePendingTree();
+ host_impl_->ActivateSyncTree();
EXPECT_EQ(new_size, scroll_delegate.scrollable_size());
// Un-setting the delegate should propagate the delegate's current offset to
scroll_layer->TotalScrollOffset().ToString());
}
+void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) {
+ const gfx::Transform target_space_transform =
+ layer->draw_properties().target_space_transform;
+ EXPECT_TRUE(target_space_transform.IsScaleOrTranslation());
+ gfx::Point translated_point;
+ target_space_transform.TransformPoint(&translated_point);
+ gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta);
+ EXPECT_EQ(expected_point.ToString(), translated_point.ToString());
+}
+
+TEST_F(LayerTreeHostImplTest,
+ ExternalRootLayerScrollOffsetDelegationReflectedInNextDraw) {
+ TestScrollOffsetDelegate scroll_delegate;
+ host_impl_->SetViewportSize(gfx::Size(10, 20));
+ LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
+ LayerImpl* clip_layer = scroll_layer->parent()->parent();
+ clip_layer->SetBounds(gfx::Size(10, 20));
+ host_impl_->SetRootLayerScrollOffsetDelegate(&scroll_delegate);
+
+ // Draw first frame to clear any pending draws and check scroll.
+ DrawFrame();
+ CheckLayerScrollDelta(scroll_layer, gfx::Vector2dF(0.f, 0.f));
+ EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties());
+
+ // Set external scroll delta on delegate and notify LayerTreeHost.
+ gfx::Vector2dF scroll_delta(10.f, 10.f);
+ scroll_delegate.set_getter_return_value(scroll_delta);
+ host_impl_->OnRootLayerDelegatedScrollOffsetChanged();
+
+ // Check scroll delta reflected in layer.
+ DrawFrame();
+ CheckLayerScrollDelta(scroll_layer, scroll_delta);
+
+ host_impl_->SetRootLayerScrollOffsetDelegate(NULL);
+}
+
TEST_F(LayerTreeHostImplTest, OverscrollRoot) {
SetupScrollAndContentsLayers(gfx::Size(100, 100));
host_impl_->SetViewportSize(gfx::Size(50, 50));
host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f);
DrawFrame();
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
- EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity());
// In-bounds scrolling does not affect overscroll.
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
- EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity());
// Overscroll events are reflected immediately.
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 50));
EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll());
- EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity());
// In-bounds scrolling resets accumulated overscroll for the scrolled axes.
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -50));
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20));
EXPECT_EQ(gfx::Vector2dF(0, -10), host_impl_->accumulated_root_overscroll());
host_impl_->ScrollEnd();
-
- EXPECT_EQ(InputHandler::ScrollStarted,
- host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
- // Fling velocity is reflected immediately.
- host_impl_->NotifyCurrentFlingVelocity(gfx::Vector2dF(10, 0));
- EXPECT_EQ(gfx::Vector2dF(10, 0), host_impl_->current_fling_velocity());
- host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -20));
- EXPECT_EQ(gfx::Vector2dF(0, -20), host_impl_->accumulated_root_overscroll());
- EXPECT_EQ(gfx::Vector2dF(10, 0), host_impl_->current_fling_velocity());
}
host_impl_->ScrollEnd();
// After scrolling the parent, another scroll on the opposite direction
- // should scroll the child, resetting the fling velocity.
+ // should scroll the child.
scroll_delta = gfx::Vector2d(0, 70);
- host_impl_->NotifyCurrentFlingVelocity(gfx::Vector2dF(10, 0));
- EXPECT_EQ(gfx::Vector2dF(10, 0), host_impl_->current_fling_velocity());
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(5, 5),
InputHandler::NonBubblingGesture));
host_impl_->ScrollBy(gfx::Point(), scroll_delta);
EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer);
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
- EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity());
host_impl_->ScrollEnd();
}
}
host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f);
DrawFrame();
EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
- EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity());
// Even though the layer can't scroll the overscroll still happens.
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10));
EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll());
- EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity());
}
-TEST_F(LayerTreeHostImplTest, UnnecessaryGlowEffectCallsWhileScrollingUp) {
- // Edge glow effect should be applicable only upon reaching Edges
- // of the content. unnecessary glow effect calls shouldn't be
- // called while scrolling up without reaching the edge of the content.
+TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) {
+ gfx::Size surface_size(980, 1439);
+ gfx::Size content_size(980, 1438);
+ float device_scale_factor = 1.5f;
+ scoped_ptr<LayerImpl> root_clip =
+ LayerImpl::Create(host_impl_->active_tree(), 3);
+ scoped_ptr<LayerImpl> root =
+ CreateScrollableLayer(1, content_size, root_clip.get());
+ root->SetIsContainerForFixedPositionLayers(true);
+ scoped_ptr<LayerImpl> child =
+ CreateScrollableLayer(2, content_size, root_clip.get());
+ root->scroll_clip_layer()->SetBounds(gfx::Size(320, 469));
+ host_impl_->active_tree()->SetPageScaleFactorAndLimits(
+ 0.326531f, 0.326531f, 5.f);
+ host_impl_->active_tree()->SetPageScaleDelta(1.f);
+ child->SetScrollClipLayer(Layer::INVALID_ID);
+ root->AddChild(child.Pass());
+ root_clip->AddChild(root.Pass());
+
+ host_impl_->SetViewportSize(surface_size);
+ host_impl_->SetDeviceScaleFactor(device_scale_factor);
+ host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
+ host_impl_->active_tree()->SetViewportLayersFromIds(3, 1, Layer::INVALID_ID);
+ host_impl_->active_tree()->DidBecomeActive();
+ DrawFrame();
+ {
+ // Horizontal & Vertical GlowEffect should not be applied when
+ // content size is less then view port size. For Example Horizontal &
+ // vertical GlowEffect should not be applied in about:blank page.
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel));
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -1));
+ EXPECT_EQ(gfx::Vector2dF().ToString(),
+ host_impl_->accumulated_root_overscroll().ToString());
+
+ host_impl_->ScrollEnd();
+ }
+}
+
+TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) {
gfx::Size surface_size(100, 100);
gfx::Size content_size(200, 200);
scoped_ptr<LayerImpl> root_clip =
host_impl_->active_tree()->DidBecomeActive();
DrawFrame();
{
+ // Edge glow effect should be applicable only upon reaching Edges
+ // of the content. unnecessary glow effect calls shouldn't be
+ // called while scrolling up without reaching the edge of the content.
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel));
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100));
EXPECT_EQ(gfx::Vector2dF().ToString(),
host_impl_->accumulated_root_overscroll().ToString());
host_impl_->ScrollEnd();
- }
-}
-
+ // unusedrootDelta should be subtracted from applied delta so that
+ // unwanted glow effect calls are not called.
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(gfx::Point(0, 0),
+ InputHandler::NonBubblingGesture));
+ EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin());
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 20));
+ EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(),
+ host_impl_->accumulated_root_overscroll().ToString());
+
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f));
+ EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(),
+ host_impl_->accumulated_root_overscroll().ToString());
+ host_impl_->ScrollEnd();
+ // TestCase to check kEpsilon, which prevents minute values to trigger
+ // gloweffect without reaching edge.
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel));
+ host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f));
+ EXPECT_EQ(gfx::Vector2dF().ToString(),
+ host_impl_->accumulated_root_overscroll().ToString());
+ host_impl_->ScrollEnd();
+ }
+}
+
class BlendStateCheckLayer : public LayerImpl {
public:
static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl,
resource_provider));
}
- virtual void AppendQuads(QuadSink* quad_sink,
+ virtual void AppendQuads(RenderPass* render_pass,
+ const OcclusionTracker<LayerImpl>& occlusion_tracker,
AppendQuadsData* append_quads_data) OVERRIDE {
quads_appended_ = true;
gfx::Rect visible_quad_rect = quad_rect_;
SharedQuadState* shared_quad_state =
- quad_sink->UseSharedQuadState(CreateSharedQuadState());
- scoped_ptr<TileDrawQuad> test_blending_draw_quad = TileDrawQuad::Create();
+ render_pass->CreateAndAppendSharedQuadState();
+ PopulateSharedQuadState(shared_quad_state);
+
+ TileDrawQuad* test_blending_draw_quad =
+ render_pass->CreateAndAppendDrawQuad<TileDrawQuad>();
test_blending_draw_quad->SetNew(shared_quad_state,
quad_rect_,
opaque_rect,
test_blending_draw_quad->visible_rect = quad_visible_rect_;
EXPECT_EQ(blend_, test_blending_draw_quad->ShouldDrawWithBlending());
EXPECT_EQ(has_render_surface_, !!render_surface());
- quad_sink->MaybeAppend(test_blending_draw_quad.PassAs<DrawQuad>());
}
void SetExpectation(bool blend, bool has_render_surface) {
ResourceProvider::TextureUsageAny,
RGBA_8888)) {
resource_provider->AllocateForTesting(resource_id_);
- SetAnchorPoint(gfx::PointF());
SetBounds(gfx::Size(10, 10));
SetContentBounds(gfx::Size(10, 10));
SetDrawsContent(true);
{
scoped_ptr<LayerImpl> root =
LayerImpl::Create(host_impl_->active_tree(), 1);
- root->SetAnchorPoint(gfx::PointF());
root->SetBounds(gfx::Size(10, 10));
root->SetContentBounds(root->bounds());
root->SetDrawsContent(false);
layer1->SetContentsOpaque(true);
layer1->SetExpectation(false, false);
layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
layer1->SetContentsOpaque(false);
layer1->SetExpectation(true, false);
layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
layer1->SetOpacity(0.5f);
layer1->SetExpectation(true, false);
layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
layer1->SetOpacity(0.5f);
layer1->SetExpectation(true, false);
layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
layer2->SetOpacity(1.f);
layer2->SetExpectation(false, false);
layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
EXPECT_TRUE(layer2->quads_appended());
layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
layer2->SetExpectation(false, false);
layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
EXPECT_TRUE(layer2->quads_appended());
layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
layer2->SetExpectation(false, false);
layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
EXPECT_TRUE(layer2->quads_appended());
layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
layer2->SetExpectation(false, false);
layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(
+ host_impl_->active_tree()->root_layer());
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
EXPECT_TRUE(layer2->quads_appended());
layer2->SetOpacity(0.5f);
layer2->SetExpectation(true, false);
layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
EXPECT_TRUE(layer2->quads_appended());
layer2->SetOpacity(1.f);
layer2->SetExpectation(true, false);
layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
EXPECT_TRUE(layer2->quads_appended());
layer2->SetOpacity(1.f);
layer2->SetExpectation(false, false);
layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
EXPECT_TRUE(layer2->quads_appended());
layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
layer1->SetExpectation(true, false);
layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
layer1->SetExpectation(true, false);
layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
layer1->SetExpectation(true, false);
layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5));
layer1->SetExpectation(false, false);
layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds()));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(layer1->quads_appended());
host_impl_->DidDrawAllLayers(frame);
child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list));
child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
EXPECT_EQ(1u, CountGutterQuads(frame.render_passes[0]->quad_list));
child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
EXPECT_EQ(4u, CountGutterQuads(frame.render_passes[0]->quad_list));
child_->SetQuadVisibleRect(gfx::Rect(layer_rect.size()));
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
EXPECT_EQ(0u, CountGutterQuads(frame.render_passes[0]->quad_list));
host_impl_->DidDrawAllLayers(frame);
}
- virtual void DidActivatePendingTree() OVERRIDE {
+ virtual void DidActivateSyncTree() OVERRIDE {
did_activate_pending_tree_ = true;
}
viewport_size_.height() + 100);
host_impl_->SetViewportSize(DipSizeToPixelSize(larger_viewport));
EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid());
- host_impl_->ActivatePendingTree();
+ host_impl_->ActivateSyncTree();
EXPECT_TRUE(did_activate_pending_tree_);
EXPECT_FALSE(host_impl_->active_tree()->ViewportSizeInvalid());
scoped_ptr<LayerImpl> root =
FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
- root->SetAnchorPoint(gfx::PointF());
root->SetBounds(gfx::Size(10, 10));
root->SetContentBounds(gfx::Size(10, 10));
root->SetDrawsContent(true);
LayerTreeHostImpl::FrameData frame;
host_impl_->SetViewportSize(gfx::Size(10, 10));
host_impl_->SetDeviceScaleFactor(1.f);
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(provider->TestContext3d()->reshape_called());
EXPECT_EQ(provider->TestContext3d()->width(), 10);
provider->TestContext3d()->clear_reshape_called();
host_impl_->SetViewportSize(gfx::Size(20, 30));
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(provider->TestContext3d()->reshape_called());
EXPECT_EQ(provider->TestContext3d()->width(), 20);
provider->TestContext3d()->clear_reshape_called();
host_impl_->SetDeviceScaleFactor(2.f);
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
EXPECT_TRUE(provider->TestContext3d()->reshape_called());
EXPECT_EQ(provider->TestContext3d()->width(), 20);
scoped_ptr<LayerImpl> child =
FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2);
child->SetPosition(gfx::PointF(12.f, 13.f));
- child->SetAnchorPoint(gfx::PointF());
child->SetBounds(gfx::Size(14, 15));
child->SetContentBounds(gfx::Size(14, 15));
child->SetDrawsContent(true);
- root->SetAnchorPoint(gfx::PointF());
root->SetBounds(gfx::Size(500, 500));
root->SetContentBounds(gfx::Size(500, 500));
root->SetDrawsContent(true);
LayerTreeHostImpl::FrameData frame;
// First frame, the entire screen should get swapped.
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
layer_tree_host_impl->DidDrawAllLayers(frame);
layer_tree_host_impl->SwapBuffers(frame);
// expected swap rect: vertically flipped, with origin at bottom left corner.
layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition(
gfx::PointF());
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
layer_tree_host_impl->SwapBuffers(frame);
// This will damage everything.
layer_tree_host_impl->active_tree()->root_layer()->SetBackgroundColor(
SK_ColorBLACK);
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- layer_tree_host_impl->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame));
layer_tree_host_impl->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
layer_tree_host_impl->SwapBuffers(frame);
FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1);
scoped_ptr<LayerImpl> child =
FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 2);
- child->SetAnchorPoint(gfx::PointF());
child->SetBounds(gfx::Size(10, 10));
child->SetContentBounds(gfx::Size(10, 10));
child->SetDrawsContent(true);
- root->SetAnchorPoint(gfx::PointF());
root->SetBounds(gfx::Size(10, 10));
root->SetContentBounds(gfx::Size(10, 10));
root->SetDrawsContent(true);
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
EXPECT_EQ(1u, frame.render_surface_layer_list->size());
EXPECT_EQ(1u, frame.render_passes.size());
host_impl_->DidDrawAllLayers(frame);
return scoped_ptr<LayerImpl>(new FakeLayerWithQuads(tree_impl, id));
}
- virtual void AppendQuads(QuadSink* quad_sink,
+ virtual void AppendQuads(RenderPass* render_pass,
+ const OcclusionTracker<LayerImpl>& occlusion_tracker,
AppendQuadsData* append_quads_data) OVERRIDE {
SharedQuadState* shared_quad_state =
- quad_sink->UseSharedQuadState(CreateSharedQuadState());
+ render_pass->CreateAndAppendSharedQuadState();
+ PopulateSharedQuadState(shared_quad_state);
SkColor gray = SkColorSetRGB(100, 100, 100);
gfx::Rect quad_rect(content_bounds());
gfx::Rect visible_quad_rect(quad_rect);
- scoped_ptr<SolidColorDrawQuad> my_quad = SolidColorDrawQuad::Create();
+ SolidColorDrawQuad* my_quad =
+ render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
my_quad->SetNew(
shared_quad_state, quad_rect, visible_quad_rect, gray, false);
- quad_sink->MaybeAppend(my_quad.PassAs<DrawQuad>());
}
private:
harness.MustSetNoScissor();
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
}
harness.MustSetScissor(0, 0, 10, 10);
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
}
harness.MustDrawSolidQuad();
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
}
harness.MustDrawSolidQuad();
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
}
gfx::Rect grand_child_rect(5, 5, 150, 150);
root->CreateRenderSurface();
- root->SetAnchorPoint(gfx::PointF());
root->SetPosition(root_rect.origin());
root->SetBounds(root_rect.size());
root->SetContentBounds(root->bounds());
root->SetDrawsContent(false);
root->render_surface()->SetContentRect(gfx::Rect(root_rect.size()));
- child->SetAnchorPoint(gfx::PointF());
child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y()));
child->SetOpacity(0.5f);
child->SetBounds(gfx::Size(child_rect.width(), child_rect.height()));
child->SetDrawsContent(false);
child->SetForceRenderSurface(true);
- grand_child->SetAnchorPoint(gfx::PointF());
grand_child->SetPosition(grand_child_rect.origin());
grand_child->SetBounds(grand_child_rect.size());
grand_child->SetContentBounds(grand_child->bounds());
&stats_instrumentation_);
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- my_host_impl->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame));
// Verify all quads have been computed
ASSERT_EQ(2U, frame.render_passes.size());
&stats_instrumentation_);
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- my_host_impl->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame));
// Verify all quads have been computed
ASSERT_EQ(2U, frame.render_passes.size());
scoped_ptr<LayerImpl> root_layer =
LayerImpl::Create(host_impl_->active_tree(), 1);
root_layer->SetBounds(gfx::Size(10, 10));
- root_layer->SetAnchorPoint(gfx::PointF());
scoped_refptr<VideoFrame> softwareFrame =
media::VideoFrame::CreateColorFrame(
gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta());
FakeVideoFrameProvider provider;
provider.set_frame(softwareFrame);
- scoped_ptr<VideoLayerImpl> video_layer =
- VideoLayerImpl::Create(host_impl_->active_tree(), 4, &provider);
+ scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create(
+ host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0);
video_layer->SetBounds(gfx::Size(10, 10));
- video_layer->SetAnchorPoint(gfx::PointF());
video_layer->SetContentBounds(gfx::Size(10, 10));
video_layer->SetDrawsContent(true);
root_layer->AddChild(video_layer.PassAs<LayerImpl>());
scoped_ptr<IOSurfaceLayerImpl> io_surface_layer =
IOSurfaceLayerImpl::Create(host_impl_->active_tree(), 5);
io_surface_layer->SetBounds(gfx::Size(10, 10));
- io_surface_layer->SetAnchorPoint(gfx::PointF());
io_surface_layer->SetContentBounds(gfx::Size(10, 10));
io_surface_layer->SetDrawsContent(true);
io_surface_layer->SetIOSurfaceProperties(1, gfx::Size(10, 10));
EXPECT_EQ(0u, context3d->NumTextures());
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
host_impl_->SwapBuffers(frame);
EXPECT_CALL(*mock_context, drawElements(_, _, _, _))
.Times(1);
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
Mock::VerifyAndClearExpectations(&mock_context);
// Verify no quads are drawn when transparent background is set.
host_impl_->active_tree()->set_has_transparent_background(true);
host_impl_->SetFullRootLayerDamage();
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
Mock::VerifyAndClearExpectations(&mock_context);
bool expect_to_draw = !expected_damage.IsEmpty();
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
if (!expect_to_draw) {
// With no damage, we don't draw, and no quads are created.
TEST_F(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) {
scoped_ptr<SolidColorLayerImpl> root =
SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
- root->SetAnchorPoint(gfx::PointF());
root->SetPosition(gfx::PointF());
root->SetBounds(gfx::Size(10, 10));
root->SetContentBounds(gfx::Size(10, 10));
// Child layer is in the bottom right corner.
scoped_ptr<SolidColorLayerImpl> child =
SolidColorLayerImpl::Create(host_impl_->active_tree(), 2);
- child->SetAnchorPoint(gfx::PointF(0.f, 0.f));
child->SetPosition(gfx::PointF(9.f, 9.f));
child->SetBounds(gfx::Size(1, 1));
child->SetContentBounds(gfx::Size(1, 1));
root->SetBounds(root_size);
root->SetContentBounds(root_size);
root->SetPosition(gfx::PointF());
- root->SetAnchorPoint(gfx::PointF());
gfx::Size scaling_layer_size(50, 50);
scaling_layer->SetBounds(scaling_layer_size);
scaling_layer->SetContentBounds(scaling_layer_size);
scaling_layer->SetPosition(gfx::PointF());
- scaling_layer->SetAnchorPoint(gfx::PointF());
gfx::Transform scale;
scale.Scale(2.f, 2.f);
scaling_layer->SetTransform(scale);
content_layer->SetBounds(scaling_layer_size);
content_layer->SetContentBounds(scaling_layer_size);
content_layer->SetPosition(gfx::PointF());
- content_layer->SetAnchorPoint(gfx::PointF());
content_layer->SetDrawsContent(true);
mask_layer->SetBounds(scaling_layer_size);
mask_layer->SetContentBounds(scaling_layer_size);
mask_layer->SetPosition(gfx::PointF());
- mask_layer->SetAnchorPoint(gfx::PointF());
mask_layer->SetDrawsContent(true);
host_impl_->SetDeviceScaleFactor(device_scale_factor);
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
host_impl_->active_tree()->set_needs_update_draw_properties();
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
host_impl_->active_tree()->set_needs_update_draw_properties();
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
root->SetBounds(root_size);
root->SetContentBounds(root_size);
root->SetPosition(gfx::PointF());
- root->SetAnchorPoint(gfx::PointF());
gfx::Size layer_size(50, 50);
content_layer->SetBounds(layer_size);
content_layer->SetContentBounds(layer_size);
content_layer->SetPosition(gfx::PointF());
- content_layer->SetAnchorPoint(gfx::PointF());
content_layer->SetDrawsContent(true);
gfx::Size mask_size(100, 100);
mask_layer->SetBounds(mask_size);
mask_layer->SetContentBounds(mask_size);
mask_layer->SetPosition(gfx::PointF());
- mask_layer->SetAnchorPoint(gfx::PointF());
mask_layer->SetDrawsContent(true);
// Check that the mask fills the surface.
host_impl_->SetDeviceScaleFactor(device_scale_factor);
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
host_impl_->active_tree()->set_needs_update_draw_properties();
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
host_impl_->active_tree()->set_needs_update_draw_properties();
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
host_impl_->active_tree()->set_needs_update_draw_properties();
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
root->SetBounds(root_size);
root->SetContentBounds(root_size);
root->SetPosition(gfx::PointF());
- root->SetAnchorPoint(gfx::PointF());
gfx::Size layer_size(50, 50);
content_layer->SetBounds(layer_size);
content_layer->SetContentBounds(layer_size);
content_layer->SetPosition(gfx::PointF());
- content_layer->SetAnchorPoint(gfx::PointF());
content_layer->SetDrawsContent(true);
gfx::Size mask_size(100, 100);
mask_layer->SetBounds(mask_size);
mask_layer->SetContentBounds(mask_size);
mask_layer->SetPosition(gfx::PointF());
- mask_layer->SetAnchorPoint(gfx::PointF());
mask_layer->SetDrawsContent(true);
// Check that the mask fills the surface.
host_impl_->SetDeviceScaleFactor(device_scale_factor);
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
frame.render_passes[0]->quad_list[1]->material);
const RenderPassDrawQuad* replica_quad =
RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
- EXPECT_TRUE(replica_quad->is_replica);
EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
replica_quad->rect.ToString());
EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
host_impl_->active_tree()->set_needs_update_draw_properties();
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
frame.render_passes[0]->quad_list[1]->material);
const RenderPassDrawQuad* replica_quad =
RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
- EXPECT_TRUE(replica_quad->is_replica);
EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
replica_quad->rect.ToString());
EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
host_impl_->active_tree()->set_needs_update_draw_properties();
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
frame.render_passes[0]->quad_list[1]->material);
const RenderPassDrawQuad* replica_quad =
RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
- EXPECT_TRUE(replica_quad->is_replica);
EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
replica_quad->rect.ToString());
EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
host_impl_->active_tree()->set_needs_update_draw_properties();
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
frame.render_passes[0]->quad_list[1]->material);
const RenderPassDrawQuad* replica_quad =
RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
- EXPECT_TRUE(replica_quad->is_replica);
EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
replica_quad->rect.ToString());
EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
root->SetBounds(root_size);
root->SetContentBounds(root_size);
root->SetPosition(gfx::PointF());
- root->SetAnchorPoint(gfx::PointF());
gfx::Size layer_size(50, 50);
content_layer->SetBounds(layer_size);
content_layer->SetContentBounds(layer_size);
content_layer->SetPosition(gfx::PointF());
- content_layer->SetAnchorPoint(gfx::PointF());
content_layer->SetDrawsContent(true);
gfx::Size child_size(50, 50);
content_child_layer->SetBounds(child_size);
content_child_layer->SetContentBounds(child_size);
content_child_layer->SetPosition(gfx::Point(50, 0));
- content_child_layer->SetAnchorPoint(gfx::PointF());
content_child_layer->SetDrawsContent(true);
gfx::Size mask_size(50, 50);
mask_layer->SetBounds(mask_size);
mask_layer->SetContentBounds(mask_size);
mask_layer->SetPosition(gfx::PointF());
- mask_layer->SetAnchorPoint(gfx::PointF());
mask_layer->SetDrawsContent(true);
float device_scale_factor = 1.f;
host_impl_->SetDeviceScaleFactor(device_scale_factor);
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
frame.render_passes[0]->quad_list[0]->material);
const RenderPassDrawQuad* render_pass_quad =
RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
- EXPECT_FALSE(render_pass_quad->is_replica);
EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
render_pass_quad->rect.ToString());
frame.render_passes[0]->quad_list[1]->material);
const RenderPassDrawQuad* replica_quad =
RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
- EXPECT_TRUE(replica_quad->is_replica);
EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
replica_quad->rect.ToString());
EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(),
content_child_layer->SetPosition(gfx::Point(-50, 0));
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_EQ(2u, frame.render_passes[0]->quad_list.size());
frame.render_passes[0]->quad_list[0]->material);
const RenderPassDrawQuad* render_pass_quad =
RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
- EXPECT_FALSE(render_pass_quad->is_replica);
EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(),
render_pass_quad->rect.ToString());
frame.render_passes[0]->quad_list[1]->material);
const RenderPassDrawQuad* replica_quad =
RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[1]);
- EXPECT_TRUE(replica_quad->is_replica);
EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(),
replica_quad->rect.ToString());
EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(),
root->SetBounds(root_size);
root->SetContentBounds(root_size);
root->SetPosition(gfx::PointF());
- root->SetAnchorPoint(gfx::PointF());
gfx::Rect clipping_rect(20, 10, 10, 20);
clipping_layer->SetBounds(clipping_rect.size());
clipping_layer->SetContentBounds(clipping_rect.size());
clipping_layer->SetPosition(clipping_rect.origin());
- clipping_layer->SetAnchorPoint(gfx::PointF());
clipping_layer->SetMasksToBounds(true);
gfx::Size layer_size(50, 50);
content_layer->SetBounds(layer_size);
content_layer->SetContentBounds(layer_size);
content_layer->SetPosition(gfx::Point() - clipping_rect.OffsetFromOrigin());
- content_layer->SetAnchorPoint(gfx::PointF());
content_layer->SetDrawsContent(true);
gfx::Size child_size(50, 50);
content_child_layer->SetBounds(child_size);
content_child_layer->SetContentBounds(child_size);
content_child_layer->SetPosition(gfx::Point(50, 0));
- content_child_layer->SetAnchorPoint(gfx::PointF());
content_child_layer->SetDrawsContent(true);
gfx::Size mask_size(100, 100);
mask_layer->SetBounds(mask_size);
mask_layer->SetContentBounds(mask_size);
mask_layer->SetPosition(gfx::PointF());
- mask_layer->SetAnchorPoint(gfx::PointF());
mask_layer->SetDrawsContent(true);
float device_scale_factor = 1.f;
host_impl_->SetDeviceScaleFactor(device_scale_factor);
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_EQ(1u, frame.render_passes[0]->quad_list.size());
frame.render_passes[0]->quad_list[0]->material);
const RenderPassDrawQuad* render_pass_quad =
RenderPassDrawQuad::MaterialCast(frame.render_passes[0]->quad_list[0]);
- EXPECT_FALSE(render_pass_quad->is_replica);
EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(),
render_pass_quad->rect.ToString());
scrolling_layer->SetScrollClipLayer(root->id());
scrolling_layer->SetScrollOffset(scroll_offset);
- host_impl_->ActivatePendingTree();
+ host_impl_->ActivateSyncTree();
host_impl_->active_tree()->UpdateDrawProperties();
ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size());
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
ASSERT_EQ(1u, frame.render_passes.size());
ASSERT_LE(1u, frame.render_passes[0]->quad_list.size());
CompositorFrameMetadataTest()
: swap_buffers_complete_(0) {}
- virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE {
+ virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE {
swap_buffers_complete_++;
}
SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
{
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, base::TimeTicks());
host_impl_->DidDrawAllLayers(frame);
}
CompositorFrameAck ack;
host_impl_->ReclaimResources(&ack);
- host_impl_->OnSwapBuffersComplete();
+ host_impl_->DidSwapBuffersComplete();
EXPECT_EQ(swap_buffers_complete_, 1);
}
// No main thread evictions in resourceless software mode.
set_reduce_memory_result(false);
CountingSoftwareDevice* software_device = new CountingSoftwareDevice();
- FakeOutputSurface* output_surface = FakeOutputSurface::CreateDeferredGL(
- scoped_ptr<SoftwareOutputDevice>(software_device)).release();
+ bool delegated_rendering = false;
+ FakeOutputSurface* output_surface =
+ FakeOutputSurface::CreateDeferredGL(
+ scoped_ptr<SoftwareOutputDevice>(software_device),
+ delegated_rendering).release();
EXPECT_TRUE(CreateHostImpl(DefaultSettings(),
scoped_ptr<OutputSurface>(output_surface)));
host_impl_->SetViewportSize(gfx::Size(50, 50));
SetupScrollAndContentsLayers(gfx::Size(100, 100));
- output_surface->set_forced_draw_to_software_device(true);
- EXPECT_TRUE(output_surface->ForcedDrawToSoftwareDevice());
+ const gfx::Transform external_transform;
+ const gfx::Rect external_viewport;
+ const gfx::Rect external_clip;
+ const bool resourceless_software_draw = true;
+ host_impl_->SetExternalDrawConstraints(external_transform,
+ external_viewport,
+ external_clip,
+ external_viewport,
+ external_transform,
+ resourceless_software_draw);
EXPECT_EQ(0, software_device->frames_began_);
EXPECT_EQ(0, software_device->frames_ended_);
TEST_F(LayerTreeHostImplTest,
ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) {
set_reduce_memory_result(false);
- FakeOutputSurface* output_surface = FakeOutputSurface::CreateDeferredGL(
- scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice())).release();
+ bool delegated_rendering = false;
+ FakeOutputSurface* output_surface =
+ FakeOutputSurface::CreateDeferredGL(
+ scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice()),
+ delegated_rendering).release();
EXPECT_TRUE(CreateHostImpl(DefaultSettings(),
scoped_ptr<OutputSurface>(output_surface)));
- output_surface->set_forced_draw_to_software_device(true);
- EXPECT_TRUE(output_surface->ForcedDrawToSoftwareDevice());
+ const gfx::Transform external_transform;
+ const gfx::Rect external_viewport;
+ const gfx::Rect external_clip;
+ const bool resourceless_software_draw = true;
+ host_impl_->SetExternalDrawConstraints(external_transform,
+ external_viewport,
+ external_clip,
+ external_viewport,
+ external_transform,
+ resourceless_software_draw);
// SolidColorLayerImpl will be drawn.
scoped_ptr<SolidColorLayerImpl> root_layer =
// VideoLayerImpl will not be drawn.
FakeVideoFrameProvider provider;
- scoped_ptr<VideoLayerImpl> video_layer =
- VideoLayerImpl::Create(host_impl_->active_tree(), 2, &provider);
+ scoped_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create(
+ host_impl_->active_tree(), 2, &provider, media::VIDEO_ROTATION_0);
video_layer->SetBounds(gfx::Size(10, 10));
video_layer->SetContentBounds(gfx::Size(10, 10));
video_layer->SetDrawsContent(true);
SetupRootLayerImpl(root_layer.PassAs<LayerImpl>());
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
set_reduce_memory_result(false);
+ bool delegated_rendering = false;
scoped_ptr<FakeOutputSurface> output_surface(
FakeOutputSurface::CreateDeferredGL(
- scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice())));
+ scoped_ptr<SoftwareOutputDevice>(new CountingSoftwareDevice()),
+ delegated_rendering));
output_surface_ = output_surface.get();
EXPECT_TRUE(CreateHostImpl(DefaultSettings(),
SetupRootLayerImpl(root_layer.PassAs<LayerImpl>());
onscreen_context_provider_ = TestContextProvider::Create();
- offscreen_context_provider_ = TestContextProvider::Create();
}
virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE {
FakeOutputSurface* output_surface_;
scoped_refptr<TestContextProvider> onscreen_context_provider_;
- scoped_refptr<TestContextProvider> offscreen_context_provider_;
bool did_update_renderer_capabilities_;
};
DrawFrame();
EXPECT_FALSE(host_impl_->output_surface()->context_provider());
- EXPECT_FALSE(host_impl_->offscreen_context_provider());
// DeferredInitialize and hardware draw.
did_update_renderer_capabilities_ = false;
- EXPECT_TRUE(output_surface_->InitializeAndSetContext3d(
- onscreen_context_provider_, offscreen_context_provider_));
+ EXPECT_TRUE(
+ output_surface_->InitializeAndSetContext3d(onscreen_context_provider_));
EXPECT_EQ(onscreen_context_provider_,
host_impl_->output_surface()->context_provider());
- EXPECT_EQ(offscreen_context_provider_,
- host_impl_->offscreen_context_provider());
EXPECT_TRUE(did_update_renderer_capabilities_);
// Defer intialized GL draw.
did_update_renderer_capabilities_ = false;
output_surface_->ReleaseGL();
EXPECT_FALSE(host_impl_->output_surface()->context_provider());
- EXPECT_FALSE(host_impl_->offscreen_context_provider());
EXPECT_TRUE(did_update_renderer_capabilities_);
// Software draw again.
DrawFrame();
}
-TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails_OnscreenContext_0) {
+TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails) {
// Software draw.
DrawFrame();
onscreen_context_provider_->UnboundTestContext3d()->set_context_lost(true);
EXPECT_FALSE(host_impl_->output_surface()->context_provider());
- EXPECT_FALSE(host_impl_->offscreen_context_provider());
// DeferredInitialize fails.
did_update_renderer_capabilities_ = false;
- EXPECT_FALSE(output_surface_->InitializeAndSetContext3d(
- onscreen_context_provider_, offscreen_context_provider_));
+ EXPECT_FALSE(
+ output_surface_->InitializeAndSetContext3d(onscreen_context_provider_));
EXPECT_FALSE(host_impl_->output_surface()->context_provider());
- EXPECT_FALSE(host_impl_->offscreen_context_provider());
EXPECT_FALSE(did_update_renderer_capabilities_);
// Software draw again.
DrawFrame();
}
-// TODO(boliu): After r239415, fails_OnscreenContext_1 and 2 are exactly the
-// same as 0. They were supposed to test makeCurrent failing in the
-// OutputSurface, LayerTreeHostImpl, and GLRenderer respectively.
-TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails_OnscreenContext_1) {
- // Software draw.
- DrawFrame();
-
- EXPECT_FALSE(host_impl_->output_surface()->context_provider());
- EXPECT_FALSE(host_impl_->offscreen_context_provider());
-
- onscreen_context_provider_->UnboundTestContext3d()->set_context_lost(true);
-
- EXPECT_FALSE(host_impl_->output_surface()->context_provider());
- // DeferredInitialize fails.
- did_update_renderer_capabilities_ = false;
- EXPECT_FALSE(output_surface_->InitializeAndSetContext3d(
- onscreen_context_provider_, offscreen_context_provider_));
- EXPECT_FALSE(host_impl_->output_surface()->context_provider());
- EXPECT_FALSE(host_impl_->offscreen_context_provider());
- EXPECT_FALSE(did_update_renderer_capabilities_);
-}
-
-TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails_OnscreenContext_2) {
- // Software draw.
- DrawFrame();
-
- EXPECT_FALSE(host_impl_->output_surface()->context_provider());
- EXPECT_FALSE(host_impl_->offscreen_context_provider());
-
- onscreen_context_provider_->UnboundTestContext3d()->set_context_lost(true);
-
- // DeferredInitialize fails.
- did_update_renderer_capabilities_ = false;
- EXPECT_FALSE(output_surface_->InitializeAndSetContext3d(
- onscreen_context_provider_, offscreen_context_provider_));
- EXPECT_FALSE(host_impl_->output_surface()->context_provider());
- EXPECT_FALSE(host_impl_->offscreen_context_provider());
- EXPECT_FALSE(did_update_renderer_capabilities_);
-}
-
-TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails_OffscreenContext) {
- // Software draw.
- DrawFrame();
-
- EXPECT_FALSE(host_impl_->output_surface()->context_provider());
- EXPECT_FALSE(host_impl_->offscreen_context_provider());
-
- // Fail initialization of the offscreen context.
- onscreen_context_provider_->UnboundTestContext3d()->set_context_lost(true);
-
- // DeferredInitialize fails.
- did_update_renderer_capabilities_ = false;
- EXPECT_FALSE(output_surface_->InitializeAndSetContext3d(
- onscreen_context_provider_, offscreen_context_provider_));
- EXPECT_FALSE(host_impl_->output_surface()->context_provider());
- EXPECT_FALSE(host_impl_->offscreen_context_provider());
- EXPECT_FALSE(did_update_renderer_capabilities_);
-}
-
// Checks that we have a non-0 default allocation if we pass a context that
// doesn't support memory management extensions.
TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) {
456, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 1000);
int everything_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue(
gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING);
- int required_only_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue(
- gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY);
+ int allow_nice_to_have_cutoff_value =
+ ManagedMemoryPolicy::PriorityCutoffToValue(
+ gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE);
int nothing_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue(
gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING);
- // GPU rasterization should be disabled by default.
- EXPECT_EQ(LayerTreeSettings::CpuRasterization,
- host_impl_->settings().rasterization_site);
+ // GPU rasterization should be disabled by default on the tree(s)
+ EXPECT_FALSE(host_impl_->active_tree()->use_gpu_rasterization());
+ EXPECT_TRUE(host_impl_->pending_tree() == NULL);
host_impl_->SetVisible(true);
host_impl_->SetMemoryPolicy(policy1);
EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_);
EXPECT_EQ(everything_cutoff_value, current_priority_cutoff_value_);
- // Now enable GPU rasterization and test if we get required only cutoff,
+ // Now enable GPU rasterization and test if we get nice to have cutoff,
// when visible.
LayerTreeSettings settings;
- settings.rasterization_site = LayerTreeSettings::GpuRasterization;
+ settings.gpu_rasterization_enabled = true;
host_impl_ = LayerTreeHostImpl::Create(
settings, this, &proxy_, &stats_instrumentation_, NULL, 0);
-
+ host_impl_->SetUseGpuRasterization(true);
host_impl_->SetVisible(true);
host_impl_->SetMemoryPolicy(policy1);
EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_);
- EXPECT_EQ(required_only_cutoff_value, current_priority_cutoff_value_);
+ EXPECT_EQ(allow_nice_to_have_cutoff_value, current_priority_cutoff_value_);
host_impl_->SetVisible(false);
EXPECT_EQ(0u, current_limit_bytes_);
EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_);
}
+TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) {
+ ASSERT_TRUE(host_impl_->active_tree());
+
+ EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw());
+ host_impl_->SetVisible(false);
+ EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw());
+ host_impl_->SetVisible(true);
+ EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw());
+ host_impl_->SetVisible(false);
+ EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw());
+
+ host_impl_->CreatePendingTree();
+ host_impl_->ActivateSyncTree();
+
+ EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw());
+ host_impl_->SetVisible(true);
+ EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw());
+}
+
+TEST_F(LayerTreeHostImplTest, RequireHighResAfterGpuRasterizationToggles) {
+ ASSERT_TRUE(host_impl_->active_tree());
+ EXPECT_FALSE(host_impl_->use_gpu_rasterization());
+
+ EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw());
+ host_impl_->SetUseGpuRasterization(false);
+ EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw());
+ host_impl_->SetUseGpuRasterization(true);
+ EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw());
+ host_impl_->SetUseGpuRasterization(false);
+ EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw());
+
+ host_impl_->CreatePendingTree();
+ host_impl_->ActivateSyncTree();
+
+ EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw());
+ host_impl_->SetUseGpuRasterization(true);
+ EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw());
+}
+
class LayerTreeHostImplTestManageTiles : public LayerTreeHostImplTest {
public:
virtual void SetUp() OVERRIDE {
host_impl_->active_tree()->root_layer()->PassCopyRequests(&requests);
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
}
}
+TEST_F(LayerTreeHostImplTest, ScrollUnknownNotOnAncestorChain) {
+ // If we ray cast a scroller that is not on the first layer's ancestor chain,
+ // we should return ScrollUnknown.
+ gfx::Size content_size(100, 100);
+ SetupScrollAndContentsLayers(content_size);
+
+ int scroll_layer_id = 2;
+ LayerImpl* scroll_layer =
+ host_impl_->active_tree()->LayerById(scroll_layer_id);
+ scroll_layer->SetDrawsContent(true);
+
+ int page_scale_layer_id = 5;
+ LayerImpl* page_scale_layer =
+ host_impl_->active_tree()->LayerById(page_scale_layer_id);
+
+ int occluder_layer_id = 6;
+ scoped_ptr<LayerImpl> occluder_layer =
+ LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id);
+ occluder_layer->SetDrawsContent(true);
+ occluder_layer->SetBounds(content_size);
+ occluder_layer->SetContentBounds(content_size);
+ occluder_layer->SetPosition(gfx::PointF());
+
+ // The parent of the occluder is *above* the scroller.
+ page_scale_layer->AddChild(occluder_layer.Pass());
+
+ DrawFrame();
+
+ EXPECT_EQ(InputHandler::ScrollUnknown,
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
+}
+
+TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) {
+ // If we ray cast a scroller this is on the first layer's ancestor chain, but
+ // is not the first scroller we encounter when walking up from the layer, we
+ // should also return ScrollUnknown.
+ gfx::Size content_size(100, 100);
+ SetupScrollAndContentsLayers(content_size);
+
+ int scroll_layer_id = 2;
+ LayerImpl* scroll_layer =
+ host_impl_->active_tree()->LayerById(scroll_layer_id);
+ scroll_layer->SetDrawsContent(true);
+
+ int occluder_layer_id = 6;
+ scoped_ptr<LayerImpl> occluder_layer =
+ LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id);
+ occluder_layer->SetDrawsContent(true);
+ occluder_layer->SetBounds(content_size);
+ occluder_layer->SetContentBounds(content_size);
+ occluder_layer->SetPosition(gfx::PointF(-10.f, -10.f));
+
+ int child_scroll_clip_layer_id = 7;
+ scoped_ptr<LayerImpl> child_scroll_clip =
+ LayerImpl::Create(host_impl_->active_tree(), child_scroll_clip_layer_id);
+
+ int child_scroll_layer_id = 8;
+ scoped_ptr<LayerImpl> child_scroll = CreateScrollableLayer(
+ child_scroll_layer_id, content_size, child_scroll_clip.get());
+
+ child_scroll->SetPosition(gfx::PointF(10.f, 10.f));
+
+ child_scroll->AddChild(occluder_layer.Pass());
+ scroll_layer->AddChild(child_scroll.Pass());
+
+ DrawFrame();
+
+ EXPECT_EQ(InputHandler::ScrollUnknown,
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
+}
+
+TEST_F(LayerTreeHostImplTest, ScrollInvisibleScroller) {
+ gfx::Size content_size(100, 100);
+ SetupScrollAndContentsLayers(content_size);
+
+ LayerImpl* root = host_impl_->active_tree()->LayerById(1);
+
+ int scroll_layer_id = 2;
+ LayerImpl* scroll_layer =
+ host_impl_->active_tree()->LayerById(scroll_layer_id);
+
+ int child_scroll_layer_id = 7;
+ scoped_ptr<LayerImpl> child_scroll =
+ CreateScrollableLayer(child_scroll_layer_id, content_size, root);
+ child_scroll->SetDrawsContent(false);
+
+ scroll_layer->AddChild(child_scroll.Pass());
+
+ DrawFrame();
+
+ // We should not have scrolled |child_scroll| even though we technically "hit"
+ // it. The reason for this is that if the scrolling the scroll would not move
+ // any layer that is a drawn RSLL member, then we can ignore the hit.
+ //
+ // Why ScrollStarted? In this case, it's because we've bubbled out and started
+ // overscrolling the inner viewport.
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
+
+ EXPECT_EQ(2, host_impl_->CurrentlyScrollingLayer()->id());
+}
+
+TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleScrollChild) {
+ // This test case is very similar to the one above with one key difference:
+ // the invisible scroller has a scroll child that is indeed draw contents.
+ // If we attempt to initiate a gesture scroll off of the visible scroll child
+ // we should still start the scroll child.
+ gfx::Size content_size(100, 100);
+ SetupScrollAndContentsLayers(content_size);
+
+ LayerImpl* root = host_impl_->active_tree()->LayerById(1);
+
+ int scroll_layer_id = 2;
+ LayerImpl* scroll_layer =
+ host_impl_->active_tree()->LayerById(scroll_layer_id);
+
+ int scroll_child_id = 6;
+ scoped_ptr<LayerImpl> scroll_child =
+ LayerImpl::Create(host_impl_->active_tree(), scroll_child_id);
+ scroll_child->SetDrawsContent(true);
+ scroll_child->SetBounds(content_size);
+ scroll_child->SetContentBounds(content_size);
+ // Move the scroll child so it's not hit by our test point.
+ scroll_child->SetPosition(gfx::PointF(10.f, 10.f));
+
+ int invisible_scroll_layer_id = 7;
+ scoped_ptr<LayerImpl> invisible_scroll =
+ CreateScrollableLayer(invisible_scroll_layer_id, content_size, root);
+ invisible_scroll->SetDrawsContent(false);
+
+ int container_id = 8;
+ scoped_ptr<LayerImpl> container =
+ LayerImpl::Create(host_impl_->active_tree(), container_id);
+
+ scoped_ptr<std::set<LayerImpl*> > scroll_children(new std::set<LayerImpl*>());
+ scroll_children->insert(scroll_child.get());
+ invisible_scroll->SetScrollChildren(scroll_children.release());
+
+ scroll_child->SetScrollParent(invisible_scroll.get());
+
+ container->AddChild(invisible_scroll.Pass());
+ container->AddChild(scroll_child.Pass());
+
+ scroll_layer->AddChild(container.Pass());
+
+ DrawFrame();
+
+ // We should not have scrolled |child_scroll| even though we technically "hit"
+ // it. The reason for this is that if the scrolling the scroll would not move
+ // any layer that is a drawn RSLL member, then we can ignore the hit.
+ //
+ // Why ScrollStarted? In this case, it's because we've bubbled out and started
+ // overscrolling the inner viewport.
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));
+
+ EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id());
+}
+
// Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed
// to CompositorFrameMetadata after SwapBuffers();
TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) {
scoped_ptr<SolidColorLayerImpl> root =
SolidColorLayerImpl::Create(host_impl_->active_tree(), 1);
- root->SetAnchorPoint(gfx::PointF());
root->SetPosition(gfx::PointF());
root->SetBounds(gfx::Size(10, 10));
root->SetContentBounds(gfx::Size(10, 10));
gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
LayerTreeHostImpl::FrameData frame;
- EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS,
- host_impl_->PrepareToDraw(&frame, gfx::Rect()));
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
host_impl_->DidDrawAllLayers(frame);
EXPECT_TRUE(host_impl_->SwapBuffers(frame));
ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, NULL));
}
+TEST_F(LayerTreeHostImplTest, SelectionBoundsPassedToCompositorFrameMetadata) {
+ int root_layer_id = 1;
+ scoped_ptr<SolidColorLayerImpl> root =
+ SolidColorLayerImpl::Create(host_impl_->active_tree(), root_layer_id);
+ root->SetPosition(gfx::PointF());
+ root->SetBounds(gfx::Size(10, 10));
+ root->SetContentBounds(gfx::Size(10, 10));
+ root->SetDrawsContent(true);
+
+ host_impl_->active_tree()->SetRootLayer(root.PassAs<LayerImpl>());
+
+ // Ensure the default frame selection bounds are empty.
+ FakeOutputSurface* fake_output_surface =
+ static_cast<FakeOutputSurface*>(host_impl_->output_surface());
+ const ViewportSelectionBound& selection_start_before =
+ fake_output_surface->last_sent_frame().metadata.selection_start;
+ const ViewportSelectionBound& selection_end_before =
+ fake_output_surface->last_sent_frame().metadata.selection_end;
+ EXPECT_EQ(ViewportSelectionBound(), selection_start_before);
+ EXPECT_EQ(ViewportSelectionBound(), selection_end_before);
+
+ // Plumb the layer-local selection bounds.
+ gfx::Rect selection_rect(5, 0, 0, 5);
+ LayerSelectionBound start, end;
+ start.type = SELECTION_BOUND_CENTER;
+ start.layer_id = root_layer_id;
+ start.layer_rect = selection_rect;
+ end = start;
+ host_impl_->active_tree()->RegisterSelection(start, end);
+
+ // Trigger a draw-swap sequence.
+ host_impl_->SetNeedsRedraw();
+
+ gfx::Rect full_frame_damage(host_impl_->DrawViewportSize());
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
+ host_impl_->DrawLayers(&frame, gfx::FrameTime::Now());
+ host_impl_->DidDrawAllLayers(frame);
+ EXPECT_TRUE(host_impl_->SwapBuffers(frame));
+
+ // Ensure the selection bounds have propagated to the frame metadata.
+ const ViewportSelectionBound& selection_start_after =
+ fake_output_surface->last_sent_frame().metadata.selection_start;
+ const ViewportSelectionBound& selection_end_after =
+ fake_output_surface->last_sent_frame().metadata.selection_end;
+ EXPECT_EQ(start.type, selection_start_after.type);
+ EXPECT_EQ(end.type, selection_end_after.type);
+ EXPECT_EQ(selection_rect, selection_start_after.viewport_rect);
+ EXPECT_EQ(selection_rect, selection_start_after.viewport_rect);
+ EXPECT_TRUE(selection_start_after.visible);
+ EXPECT_TRUE(selection_start_after.visible);
+}
+
class SimpleSwapPromiseMonitor : public SwapPromiseMonitor {
public:
SimpleSwapPromiseMonitor(LayerTreeHost* layer_tree_host,
LayerTreeHostImpl* layer_tree_host_impl,
int* set_needs_commit_count,
- int* set_needs_redraw_count)
+ int* set_needs_redraw_count,
+ int* forward_to_main_count)
: SwapPromiseMonitor(layer_tree_host, layer_tree_host_impl),
set_needs_commit_count_(set_needs_commit_count),
- set_needs_redraw_count_(set_needs_redraw_count) {}
+ set_needs_redraw_count_(set_needs_redraw_count),
+ forward_to_main_count_(forward_to_main_count) {}
virtual ~SimpleSwapPromiseMonitor() {}
(*set_needs_redraw_count_)++;
}
+ virtual void OnForwardScrollUpdateToMainThreadOnImpl() OVERRIDE {
+ (*forward_to_main_count_)++;
+ }
+
private:
int* set_needs_commit_count_;
int* set_needs_redraw_count_;
+ int* forward_to_main_count_;
};
TEST_F(LayerTreeHostImplTest, SimpleSwapPromiseMonitor) {
int set_needs_commit_count = 0;
int set_needs_redraw_count = 0;
+ int forward_to_main_count = 0;
{
scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor(
new SimpleSwapPromiseMonitor(NULL,
host_impl_.get(),
&set_needs_commit_count,
- &set_needs_redraw_count));
+ &set_needs_redraw_count,
+ &forward_to_main_count));
host_impl_->SetNeedsRedraw();
EXPECT_EQ(0, set_needs_commit_count);
EXPECT_EQ(1, set_needs_redraw_count);
+ EXPECT_EQ(0, forward_to_main_count);
}
// Now the monitor is destroyed, SetNeedsRedraw() is no longer being
host_impl_->SetNeedsRedraw();
EXPECT_EQ(0, set_needs_commit_count);
EXPECT_EQ(1, set_needs_redraw_count);
+ EXPECT_EQ(0, forward_to_main_count);
{
scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor(
new SimpleSwapPromiseMonitor(NULL,
host_impl_.get(),
&set_needs_commit_count,
- &set_needs_redraw_count));
+ &set_needs_redraw_count,
+ &forward_to_main_count));
host_impl_->SetNeedsRedrawRect(gfx::Rect(10, 10));
EXPECT_EQ(0, set_needs_commit_count);
EXPECT_EQ(2, set_needs_redraw_count);
+ EXPECT_EQ(0, forward_to_main_count);
}
{
new SimpleSwapPromiseMonitor(NULL,
host_impl_.get(),
&set_needs_commit_count,
- &set_needs_redraw_count));
+ &set_needs_redraw_count,
+ &forward_to_main_count));
// Empty damage rect won't signal the monitor.
host_impl_->SetNeedsRedrawRect(gfx::Rect());
EXPECT_EQ(0, set_needs_commit_count);
EXPECT_EQ(2, set_needs_redraw_count);
+ EXPECT_EQ(0, forward_to_main_count);
+ }
+
+ {
+ set_needs_commit_count = 0;
+ set_needs_redraw_count = 0;
+ forward_to_main_count = 0;
+ scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor(
+ new SimpleSwapPromiseMonitor(NULL,
+ host_impl_.get(),
+ &set_needs_commit_count,
+ &set_needs_redraw_count,
+ &forward_to_main_count));
+ LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
+
+ // Scrolling normally should not trigger any forwarding.
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
+ EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)));
+ host_impl_->ScrollEnd();
+
+ EXPECT_EQ(0, set_needs_commit_count);
+ EXPECT_EQ(1, set_needs_redraw_count);
+ EXPECT_EQ(0, forward_to_main_count);
+
+ // Scrolling with a scroll handler should defer the swap to the main
+ // thread.
+ scroll_layer->SetHaveScrollEventHandlers(true);
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
+ EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)));
+ host_impl_->ScrollEnd();
+
+ EXPECT_EQ(0, set_needs_commit_count);
+ EXPECT_EQ(2, set_needs_redraw_count);
+ EXPECT_EQ(1, forward_to_main_count);
}
}
EXPECT_FALSE(did_request_redraw_);
}
+TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) {
+ SetupScrollAndContentsLayers(gfx::Size(100, 100))
+ ->SetScrollOffset(gfx::Vector2d(0, 10));
+ host_impl_->DidChangeTopControlsPosition();
+ EXPECT_TRUE(did_request_animate_);
+ EXPECT_TRUE(did_request_redraw_);
+}
+
TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) {
LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
host_impl_->SetViewportSize(gfx::Size(100, 100));
host_impl_->ScrollEnd();
}
+TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) {
+ LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
+ host_impl_->SetViewportSize(gfx::Size(100, 200));
+ DrawFrame();
+
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
+ EXPECT_EQ(0, host_impl_->top_controls_manager()->controls_top_offset());
+ EXPECT_EQ(gfx::Vector2dF().ToString(),
+ scroll_layer->TotalScrollOffset().ToString());
+
+ // Scroll the top controls partially.
+ const float residue = 35;
+ float offset = top_controls_height_ - residue;
+ EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
+ EXPECT_EQ(-offset, host_impl_->top_controls_manager()->controls_top_offset());
+ EXPECT_EQ(gfx::Vector2dF().ToString(),
+ scroll_layer->TotalScrollOffset().ToString());
+
+ did_request_redraw_ = false;
+ did_request_animate_ = false;
+ did_request_commit_ = false;
+
+ // End the scroll while the controls are still offset from their limit.
+ host_impl_->ScrollEnd();
+ ASSERT_TRUE(host_impl_->top_controls_manager()->animation());
+ EXPECT_TRUE(did_request_animate_);
+ EXPECT_TRUE(did_request_redraw_);
+ EXPECT_FALSE(did_request_commit_);
+
+ // The top controls should properly animate until finished, despite the scroll
+ // offset being at the origin.
+ base::TimeTicks animation_time = gfx::FrameTime::Now();
+ while (did_request_animate_) {
+ did_request_redraw_ = false;
+ did_request_animate_ = false;
+ did_request_commit_ = false;
+
+ float old_offset =
+ host_impl_->top_controls_manager()->controls_top_offset();
+
+ animation_time += base::TimeDelta::FromMilliseconds(5);
+ host_impl_->Animate(animation_time);
+ EXPECT_EQ(gfx::Vector2dF().ToString(),
+ scroll_layer->TotalScrollOffset().ToString());
+
+ float new_offset =
+ host_impl_->top_controls_manager()->controls_top_offset();
+
+ // No commit is needed as the controls are animating the content offset,
+ // not the scroll offset.
+ EXPECT_FALSE(did_request_commit_);
+
+ if (new_offset != old_offset)
+ EXPECT_TRUE(did_request_redraw_);
+
+ if (new_offset != 0) {
+ EXPECT_TRUE(host_impl_->top_controls_manager()->animation());
+ EXPECT_TRUE(did_request_animate_);
+ }
+ }
+ EXPECT_FALSE(host_impl_->top_controls_manager()->animation());
+}
+
+TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) {
+ LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
+ host_impl_->SetViewportSize(gfx::Size(100, 100));
+ float initial_scroll_offset = 50;
+ scroll_layer->SetScrollOffset(gfx::Vector2d(0, initial_scroll_offset));
+ DrawFrame();
+
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
+ EXPECT_EQ(0, host_impl_->top_controls_manager()->controls_top_offset());
+ EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(),
+ scroll_layer->TotalScrollOffset().ToString());
+
+ // Scroll the top controls partially.
+ const float residue = 15;
+ float offset = top_controls_height_ - residue;
+ EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)));
+ EXPECT_EQ(-offset, host_impl_->top_controls_manager()->controls_top_offset());
+ EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(),
+ scroll_layer->TotalScrollOffset().ToString());
+
+ did_request_redraw_ = false;
+ did_request_animate_ = false;
+ did_request_commit_ = false;
+
+ // End the scroll while the controls are still offset from the limit.
+ host_impl_->ScrollEnd();
+ ASSERT_TRUE(host_impl_->top_controls_manager()->animation());
+ EXPECT_TRUE(did_request_animate_);
+ EXPECT_TRUE(did_request_redraw_);
+ EXPECT_FALSE(did_request_commit_);
+
+ // Animate the top controls to the limit.
+ base::TimeTicks animation_time = gfx::FrameTime::Now();
+ while (did_request_animate_) {
+ did_request_redraw_ = false;
+ did_request_animate_ = false;
+ did_request_commit_ = false;
+
+ float old_offset =
+ host_impl_->top_controls_manager()->controls_top_offset();
+
+ animation_time += base::TimeDelta::FromMilliseconds(5);
+ host_impl_->Animate(animation_time);
+
+ float new_offset =
+ host_impl_->top_controls_manager()->controls_top_offset();
+
+ if (new_offset != old_offset) {
+ EXPECT_TRUE(did_request_redraw_);
+ EXPECT_TRUE(did_request_commit_);
+ }
+ }
+ EXPECT_FALSE(host_impl_->top_controls_manager()->animation());
+}
+
class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest {
public:
void SetupVirtualViewportLayers(const gfx::Size& content_size,
inner_scroll->SetBounds(outer_viewport);
inner_scroll->SetContentBounds(outer_viewport);
inner_scroll->SetPosition(gfx::PointF());
- inner_scroll->SetAnchorPoint(gfx::PointF());
scoped_ptr<LayerImpl> outer_clip =
LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId);
outer_scroll->SetBounds(content_size);
outer_scroll->SetContentBounds(content_size);
outer_scroll->SetPosition(gfx::PointF());
- outer_scroll->SetAnchorPoint(gfx::PointF());
scoped_ptr<LayerImpl> contents =
LayerImpl::Create(layer_tree_impl, 8);
contents->SetBounds(content_size);
contents->SetContentBounds(content_size);
contents->SetPosition(gfx::PointF());
- contents->SetAnchorPoint(gfx::PointF());
outer_scroll->AddChild(contents.Pass());
outer_clip->AddChild(outer_scroll.Pass());
public:
virtual void SetUp() OVERRIDE {
LayerTreeSettings settings = DefaultSettings();
- settings.max_unused_resource_memory_percentage = 50;
settings.max_memory_for_prepaint_percentage = 50;
CreateHostImpl(settings, CreateOutputSurface());
}
300u * 1024u * 1024u);
EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes,
150u * 1024u * 1024u);
- EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes,
- 75u * 1024u * 1024u);
+}
+
+TEST_F(LayerTreeHostImplTest, ExternalTransformReflectedInNextDraw) {
+ const gfx::Size layer_size(100, 100);
+ gfx::Transform external_transform;
+ const gfx::Rect external_viewport(layer_size);
+ const gfx::Rect external_clip(layer_size);
+ const bool resourceless_software_draw = false;
+ LayerImpl* layer = SetupScrollAndContentsLayers(layer_size);
+
+ host_impl_->SetExternalDrawConstraints(external_transform,
+ external_viewport,
+ external_clip,
+ external_viewport,
+ external_transform,
+ resourceless_software_draw);
+ DrawFrame();
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ external_transform, layer->draw_properties().target_space_transform);
+
+ external_transform.Translate(20, 20);
+ host_impl_->SetExternalDrawConstraints(external_transform,
+ external_viewport,
+ external_clip,
+ external_viewport,
+ external_transform,
+ resourceless_software_draw);
+ DrawFrame();
+ EXPECT_TRANSFORMATION_MATRIX_EQ(
+ external_transform, layer->draw_properties().target_space_transform);
+}
+
+TEST_F(LayerTreeHostImplTest, ScrollAnimated) {
+ SetupScrollAndContentsLayers(gfx::Size(100, 150));
+ host_impl_->SetViewportSize(gfx::Size(50, 50));
+ DrawFrame();
+
+ base::TimeTicks start_time =
+ base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
+
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
+
+ LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
+
+ host_impl_->Animate(start_time);
+ host_impl_->UpdateAnimationState(true);
+
+ EXPECT_EQ(gfx::Vector2dF(), scrolling_layer->TotalScrollOffset());
+
+ host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50));
+ host_impl_->UpdateAnimationState(true);
+
+ float y = scrolling_layer->TotalScrollOffset().y();
+ EXPECT_TRUE(y > 1 && y < 49);
+
+ // Update target.
+ EXPECT_EQ(InputHandler::ScrollStarted,
+ host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
+
+ host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200));
+ host_impl_->UpdateAnimationState(true);
+
+ y = scrolling_layer->TotalScrollOffset().y();
+ EXPECT_TRUE(y > 50 && y < 100);
+ EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer());
+
+ host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250));
+ host_impl_->UpdateAnimationState(true);
+
+ EXPECT_EQ(gfx::Vector2dF(0, 100), scrolling_layer->TotalScrollOffset());
+ EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
+}
+
+TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) {
+ host_impl_->CreatePendingTree();
+ host_impl_->ActivateSyncTree();
+ host_impl_->CreatePendingTree();
+
+ LayerTreeImpl* active_tree = host_impl_->active_tree();
+ LayerTreeImpl* pending_tree = host_impl_->pending_tree();
+ EXPECT_NE(active_tree, pending_tree);
+
+ scoped_ptr<FakePictureLayerImpl> active_layer =
+ FakePictureLayerImpl::Create(active_tree, 10);
+ scoped_ptr<FakePictureLayerImpl> pending_layer =
+ FakePictureLayerImpl::Create(pending_tree, 10);
+
+ std::vector<PictureLayerImpl::Pair> layer_pairs;
+ host_impl_->GetPictureLayerImplPairs(&layer_pairs);
+
+ EXPECT_EQ(2u, layer_pairs.size());
+ if (layer_pairs[0].active) {
+ EXPECT_EQ(active_layer.get(), layer_pairs[0].active);
+ EXPECT_EQ(NULL, layer_pairs[0].pending);
+ } else {
+ EXPECT_EQ(pending_layer.get(), layer_pairs[0].pending);
+ EXPECT_EQ(NULL, layer_pairs[0].active);
+ }
+
+ if (layer_pairs[1].active) {
+ EXPECT_EQ(active_layer.get(), layer_pairs[1].active);
+ EXPECT_EQ(NULL, layer_pairs[1].pending);
+ } else {
+ EXPECT_EQ(pending_layer.get(), layer_pairs[1].pending);
+ EXPECT_EQ(NULL, layer_pairs[1].active);
+ }
+
+ active_layer->set_twin_layer(pending_layer.get());
+ pending_layer->set_twin_layer(active_layer.get());
+
+ layer_pairs.clear();
+ host_impl_->GetPictureLayerImplPairs(&layer_pairs);
+ EXPECT_EQ(1u, layer_pairs.size());
+
+ EXPECT_EQ(active_layer.get(), layer_pairs[0].active);
+ EXPECT_EQ(pending_layer.get(), layer_pairs[0].pending);
+}
+
+TEST_F(LayerTreeHostImplTest, DidBecomeActive) {
+ host_impl_->CreatePendingTree();
+ host_impl_->ActivateSyncTree();
+ host_impl_->CreatePendingTree();
+
+ LayerTreeImpl* pending_tree = host_impl_->pending_tree();
+
+ scoped_ptr<FakePictureLayerImpl> pending_layer =
+ FakePictureLayerImpl::Create(pending_tree, 10);
+ pending_layer->DoPostCommitInitializationIfNeeded();
+ FakePictureLayerImpl* raw_pending_layer = pending_layer.get();
+ pending_tree->SetRootLayer(pending_layer.PassAs<LayerImpl>());
+ ASSERT_EQ(raw_pending_layer, pending_tree->root_layer());
+
+ EXPECT_EQ(0u, raw_pending_layer->did_become_active_call_count());
+ pending_tree->DidBecomeActive();
+ EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count());
+
+ scoped_ptr<FakePictureLayerImpl> mask_layer =
+ FakePictureLayerImpl::Create(pending_tree, 11);
+ mask_layer->DoPostCommitInitializationIfNeeded();
+ FakePictureLayerImpl* raw_mask_layer = mask_layer.get();
+ raw_pending_layer->SetMaskLayer(mask_layer.PassAs<LayerImpl>());
+ ASSERT_EQ(raw_mask_layer, raw_pending_layer->mask_layer());
+
+ EXPECT_EQ(1u, raw_pending_layer->did_become_active_call_count());
+ EXPECT_EQ(0u, raw_mask_layer->did_become_active_call_count());
+ pending_tree->DidBecomeActive();
+ EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count());
+ EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count());
+
+ scoped_ptr<FakePictureLayerImpl> replica_layer =
+ FakePictureLayerImpl::Create(pending_tree, 12);
+ scoped_ptr<FakePictureLayerImpl> replica_mask_layer =
+ FakePictureLayerImpl::Create(pending_tree, 13);
+ replica_mask_layer->DoPostCommitInitializationIfNeeded();
+ FakePictureLayerImpl* raw_replica_mask_layer = replica_mask_layer.get();
+ replica_layer->SetMaskLayer(replica_mask_layer.PassAs<LayerImpl>());
+ raw_pending_layer->SetReplicaLayer(replica_layer.PassAs<LayerImpl>());
+ ASSERT_EQ(raw_replica_mask_layer,
+ raw_pending_layer->replica_layer()->mask_layer());
+
+ EXPECT_EQ(2u, raw_pending_layer->did_become_active_call_count());
+ EXPECT_EQ(1u, raw_mask_layer->did_become_active_call_count());
+ EXPECT_EQ(0u, raw_replica_mask_layer->did_become_active_call_count());
+ pending_tree->DidBecomeActive();
+ EXPECT_EQ(3u, raw_pending_layer->did_become_active_call_count());
+ EXPECT_EQ(2u, raw_mask_layer->did_become_active_call_count());
+ EXPECT_EQ(1u, raw_replica_mask_layer->did_become_active_call_count());
+}
+
+class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest {
+ public:
+ LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {}
+ virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE {
+ num_lost_surfaces_++;
+ }
+
+ protected:
+ int num_lost_surfaces_;
+};
+
+TEST_F(LayerTreeHostImplCountingLostSurfaces, TwiceLostSurface) {
+ // The medium term, we plan to remove LayerTreeHostImpl::IsContextLost().
+ // Until then, we need the state variable
+ // LayerTreeHostImpl::have_valid_output_surface_ and we can
+ // enforce the following behaviour, where calling DidLoseOutputSurface
+ // twice in a row only causes one subsequent
+ // call to LayerTreeHostImplClient::DidLoseOutputSurfaceOnImplThread().
+ // Really we just need at least one client notification each time
+ // we go from having a valid output surface to not having a valid output
+ // surface.
+ EXPECT_EQ(0, num_lost_surfaces_);
+ EXPECT_FALSE(host_impl_->IsContextLost());
+ host_impl_->DidLoseOutputSurface();
+ EXPECT_TRUE(host_impl_->IsContextLost());
+ EXPECT_EQ(1, num_lost_surfaces_);
+ host_impl_->DidLoseOutputSurface();
+ EXPECT_TRUE(host_impl_->IsContextLost());
+ EXPECT_EQ(1, num_lost_surfaces_);
}
} // namespace