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

Side by Side Diff: sky/viewer/platform/weblayertreeview_impl.cc

Issue 737793006: Add compile flag for enabling the compostior (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: cleanup Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/viewer/platform/weblayertreeview_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sky/viewer/platform/weblayertreeview_impl.h" 5 #include "sky/viewer/platform/weblayertreeview_impl.h"
6 6
7 #include "base/message_loop/message_loop_proxy.h" 7 #include "base/message_loop/message_loop_proxy.h"
8 #include "cc/layers/layer.h" 8 #include "cc/layers/layer.h"
9 #include "cc/output/begin_frame_args.h" 9 #include "cc/output/begin_frame_args.h"
10 #include "cc/scheduler/begin_frame_source.h" 10 #include "cc/scheduler/begin_frame_source.h"
11 #include "cc/trees/layer_tree_host.h" 11 #include "cc/trees/layer_tree_host.h"
12 #include "mojo/cc/context_provider_mojo.h" 12 #include "mojo/cc/context_provider_mojo.h"
13 #include "mojo/cc/output_surface_mojo.h" 13 #include "mojo/cc/output_surface_mojo.h"
14 #include "mojo/converters/surfaces/surfaces_type_converters.h" 14 #include "mojo/converters/surfaces/surfaces_type_converters.h"
15 #include "mojo/services/public/cpp/view_manager/view.h" 15 #include "mojo/services/public/cpp/view_manager/view.h"
16 #include "sky/engine/public/web/WebSettings.h"
17 #include "sky/engine/public/web/WebView.h"
16 #include "sky/engine/public/web/WebWidget.h" 18 #include "sky/engine/public/web/WebWidget.h"
17 #include "sky/viewer/cc/web_layer_impl.h" 19 #include "sky/viewer/cc/web_layer_impl.h"
20 #include "third_party/skia/include/core/SkCanvas.h"
18 21
19 namespace sky { 22 namespace sky {
20 23
21 WebLayerTreeViewImpl::WebLayerTreeViewImpl( 24 WebLayerTreeViewImpl::WebLayerTreeViewImpl(
22 scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy, 25 scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy,
23 mojo::SurfacesServicePtr surfaces_service, 26 mojo::SurfacesServicePtr surfaces_service,
24 mojo::GpuPtr gpu_service) 27 mojo::GpuPtr gpu_service)
25 : widget_(NULL), 28 : widget_(NULL),
26 view_(NULL), 29 view_(NULL),
27 surfaces_service_(surfaces_service.Pass()), 30 surfaces_service_(surfaces_service.Pass()),
(...skipping 22 matching lines...) Expand all
50 base::MessageLoopProxy::current(), 53 base::MessageLoopProxy::current(),
51 compositor_message_loop_proxy, 54 compositor_message_loop_proxy,
52 nullptr); 55 nullptr);
53 DCHECK(layer_tree_host_); 56 DCHECK(layer_tree_host_);
54 } 57 }
55 58
56 WebLayerTreeViewImpl::~WebLayerTreeViewImpl() { 59 WebLayerTreeViewImpl::~WebLayerTreeViewImpl() {
57 layer_tree_host_.reset(); 60 layer_tree_host_.reset();
58 } 61 }
59 62
63 void WebLayerTreeViewImpl::PaintContents(SkCanvas* canvas,
64 const gfx::Rect& clip,
65 GraphicsContextStatus gc_status) {
66 blink::WebRect rect(clip.x(), clip.y(), clip.width(), clip.height());
67 widget_->paint(canvas, rect);
68 canvas->flush();
69 }
70
71 bool WebLayerTreeViewImpl::FillsBoundsCompletely() const {
72 // TODO(abarth): We should be able to return true when we're opaque.
73 return false;
74 }
75
60 void WebLayerTreeViewImpl::WillBeginMainFrame(int frame_id) { 76 void WebLayerTreeViewImpl::WillBeginMainFrame(int frame_id) {
61 } 77 }
62 78
63 void WebLayerTreeViewImpl::DidBeginMainFrame() { 79 void WebLayerTreeViewImpl::DidBeginMainFrame() {
64 } 80 }
65 81
66 void WebLayerTreeViewImpl::BeginMainFrame(const cc::BeginFrameArgs& args) { 82 void WebLayerTreeViewImpl::BeginMainFrame(const cc::BeginFrameArgs& args) {
67 VLOG(2) << "WebLayerTreeViewImpl::BeginMainFrame"; 83 VLOG(2) << "WebLayerTreeViewImpl::BeginMainFrame";
68 double frame_time_sec = (args.frame_time - base::TimeTicks()).InSecondsF(); 84 double frame_time_sec = (args.frame_time - base::TimeTicks()).InSecondsF();
69 double deadline_sec = (args.deadline - base::TimeTicks()).InSecondsF(); 85 double deadline_sec = (args.deadline - base::TimeTicks()).InSecondsF();
70 double interval_sec = args.interval.InSecondsF(); 86 double interval_sec = args.interval.InSecondsF();
71 blink::WebBeginFrameArgs web_begin_frame_args( 87 blink::WebBeginFrameArgs web_begin_frame_args(
72 frame_time_sec, deadline_sec, interval_sec); 88 frame_time_sec, deadline_sec, interval_sec);
73 widget_->beginFrame(web_begin_frame_args); 89 widget_->beginFrame(web_begin_frame_args);
74 } 90 }
75 91
92 void WebLayerTreeViewImpl::set_widget(blink::WebWidget* widget) {
93 widget_ = widget;
94
95 // TODO(sky): The only reason this is here is because we need the widget to
96 // check whether the compositor is enabled.
97 if (!static_cast<blink::WebView*>(widget_)->settings()->compositorIsEnabled()) {
98 root_layer_ = cc::ContentLayer::Create(this);
99 layer_tree_host_->SetRootLayer(root_layer_);
100 }
101 }
102
76 void WebLayerTreeViewImpl::Layout() { 103 void WebLayerTreeViewImpl::Layout() {
77 widget_->layout(); 104 widget_->layout();
105 blink::WebSize size = widget_->size();
106
107 if (!static_cast<blink::WebView*>(widget_)->settings()->compositorIsEnabled()) {
108 root_layer_->SetBounds(gfx::Size(size.width, size.height));
109 root_layer_->SetIsDrawable(true);
110 root_layer_->SetNeedsDisplay();
111 }
78 } 112 }
79 113
80 void WebLayerTreeViewImpl::ApplyViewportDeltas( 114 void WebLayerTreeViewImpl::ApplyViewportDeltas(
81 const gfx::Vector2d& scroll_delta, 115 const gfx::Vector2d& scroll_delta,
82 float page_scale, 116 float page_scale,
83 float top_controls_delta) { 117 float top_controls_delta) {
84 } 118 }
85 119
86 void WebLayerTreeViewImpl::ApplyViewportDeltas(const gfx::Vector2d& inner_delta, 120 void WebLayerTreeViewImpl::ApplyViewportDeltas(const gfx::Vector2d& inner_delta,
87 const gfx::Vector2d& outer_delta, 121 const gfx::Vector2d& outer_delta,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 base::Bind(&WebLayerTreeViewImpl::DidCreateSurfaceOnMainThread, 245 base::Bind(&WebLayerTreeViewImpl::DidCreateSurfaceOnMainThread,
212 main_thread_bound_weak_ptr_, 246 main_thread_bound_weak_ptr_,
213 id)); 247 id));
214 } 248 }
215 249
216 void WebLayerTreeViewImpl::DidCreateSurfaceOnMainThread(cc::SurfaceId id) { 250 void WebLayerTreeViewImpl::DidCreateSurfaceOnMainThread(cc::SurfaceId id) {
217 view_->SetSurfaceId(mojo::SurfaceId::From(id)); 251 view_->SetSurfaceId(mojo::SurfaceId::From(id));
218 } 252 }
219 253
220 } // namespace sky 254 } // namespace sky
OLDNEW
« no previous file with comments | « sky/viewer/platform/weblayertreeview_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698