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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_cast.cc

Issue 223583003: Exclude wifi_data_provider_linux.cc for chromecast build as chromecast uses wpa_supplicant instead … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add chromecast-specific content port implementation. Created 6 years, 8 months 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/renderer_host/render_widget_host_view_cast.h"
6
7 #include "base/debug/trace_event.h"
8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h"
10 #include "content/browser/renderer_host/render_view_host_impl.h"
11 #include "content/common/gpu/gpu_messages.h"
12 #include "content/common/host_shared_bitmap_manager.h"
13 #include "content/common/view_messages.h"
14 #include "content/port/browser/render_widget_host_view_port.h"
15 #include "skia/ext/platform_canvas.h"
16 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
17 #include "ui/gfx/chromecast/gfx_plane.h"
18 #include "ui/gfx/chromecast/surface.h"
19
20 namespace content {
21
22 namespace {
23 const int kARGBSizeInBytes = 4;
24 } // namespace
25
26 // static
27 void RenderWidgetHostViewPort::GetDefaultScreenInfo(
28 blink::WebScreenInfo* results) {
29 results->depthPerComponent = 8;
30 results->depth = 8;
31 results->isMonochrome = false;
32 results->rect = blink::WebRect(0, 0, 1280, 720);
33 results->availableRect = results->rect;
34 NOTIMPLEMENTED();
35 }
36
37 RenderWidgetHostViewCast::RenderWidgetHostViewCast(
38 RenderWidgetHost* widget_host)
39 : host_(RenderWidgetHostImpl::From(widget_host)),
40 about_to_validate_and_paint_(false),
41 is_hidden_(false),
42 is_loading_(false),
43 is_fullscreen_(false) {
44 host_->SetView(this);
45 }
46
47 RenderWidgetHostViewCast::~RenderWidgetHostViewCast() {
48 UnlockMouse();
49 }
50
51 void RenderWidgetHostViewCast::InitAsChild(
52 gfx::NativeView parent_view) {
53 NOTIMPLEMENTED();
54 }
55
56 void RenderWidgetHostViewCast::InitAsPopup(
57 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) {
58 NOTIMPLEMENTED();
59 }
60
61 void RenderWidgetHostViewCast::InitAsFullscreen(
62 RenderWidgetHostView* parent_view) {
63 is_fullscreen_ = true;
64 NOTIMPLEMENTED();
65 }
66
67 RenderWidgetHost* RenderWidgetHostViewCast::GetRenderWidgetHost() const {
68 return host_;
69 }
70
71 void RenderWidgetHostViewCast::WasShown() {
72 if (!is_hidden_)
73 return;
74
75 is_hidden_ = false;
76 host_->WasShown();
77 }
78
79 void RenderWidgetHostViewCast::WasHidden() {
80 if (is_hidden_)
81 return;
82
83 // If we receive any more paint messages while we are hidden, we want to
84 // ignore them so we don't re-allocate the backing store. We will paint
85 // everything again when we become selected again.
86 is_hidden_ = true;
87
88 // If we have a renderer, then inform it that we are being hidden so it can
89 // reduce its resource utilization.
90 host_->WasHidden();
91 }
92
93 void RenderWidgetHostViewCast::SetSize(const gfx::Size& size) {
94 // Update the size of the RWH.
95 if (requested_size_.width() != size.width() ||
96 requested_size_.height() != size.height()) {
97 requested_size_ = size;
98 host_->WasResized();
99 }
100 }
101
102 void RenderWidgetHostViewCast::SetBounds(const gfx::Rect& rect) {
103 // This is called when webkit has sent us a Move message.
104 SetSize(rect.size());
105 }
106
107 gfx::NativeView RenderWidgetHostViewCast::GetNativeView() const {
108 NOTIMPLEMENTED();
109 return NULL;
110 }
111
112 gfx::NativeViewId RenderWidgetHostViewCast::GetNativeViewId() const {
113 NOTIMPLEMENTED();
114 return 0;
115 }
116
117 gfx::NativeViewAccessible
118 RenderWidgetHostViewCast::GetNativeViewAccessible() {
119 NOTIMPLEMENTED();
120 return NULL;
121 }
122
123 void RenderWidgetHostViewCast::MovePluginWindows(
124 const gfx::Vector2d& scroll_offset,
125 const std::vector<WebPluginGeometry>& moves) {
126 // Nothing to do since Chromecast doesn't use plugin.
127 }
128
129 void RenderWidgetHostViewCast::Focus() {
130 NOTIMPLEMENTED();
131 }
132
133 void RenderWidgetHostViewCast::Blur() {
134 host_->Blur();
135 }
136
137 bool RenderWidgetHostViewCast::HasFocus() const {
138 NOTIMPLEMENTED() << "Bogus value returned";
139 return true;
140 }
141
142 bool RenderWidgetHostViewCast::IsSurfaceAvailableForCopy() const {
143 return true;
144 }
145
146 void RenderWidgetHostViewCast::Show() {
147 is_hidden_ = false;
148 }
149
150 void RenderWidgetHostViewCast::Hide() {
151 is_hidden_ = true;
152 }
153
154 bool RenderWidgetHostViewCast::IsShowing() {
155 return !is_hidden_;
156 }
157
158 gfx::Rect RenderWidgetHostViewCast::GetViewBounds() const {
159 return gfx::Rect(0, 0, requested_size_.width(), requested_size_.height());
160 }
161
162 void RenderWidgetHostViewCast::UpdateCursor(const WebCursor& cursor) {
163 NOTIMPLEMENTED();
164 }
165
166 void RenderWidgetHostViewCast::SetIsLoading(bool is_loading) {
167 is_loading_ = is_loading;
168 }
169
170 void RenderWidgetHostViewCast::TextInputTypeChanged(
171 ui::TextInputType type, ui::TextInputMode mode, bool can_compose_inline) {
172 NOTIMPLEMENTED();
173 }
174
175 void RenderWidgetHostViewCast::ImeCancelComposition() {
176 NOTIMPLEMENTED();
177 }
178
179 void RenderWidgetHostViewCast::DidUpdateBackingStore(
180 const gfx::Rect& scroll_rect,
181 const gfx::Vector2d& scroll_delta,
182 const std::vector<gfx::Rect>& copy_rects,
183 const std::vector<ui::LatencyInfo>& latency_info) {
184 for (size_t i = 0; i < latency_info.size(); i++)
185 software_latency_info_.push_back(latency_info[i]);
186 TRACE_EVENT0("ui::chromecast",
187 "RenderWidgetHostViewCast::DidUpdateBackingStore");
188
189 if (is_hidden_)
190 return;
191
192 if (about_to_validate_and_paint_)
193 invalid_rect_.Union(scroll_rect);
194 else
195 Paint(scroll_rect);
196
197 for (size_t i = 0; i < copy_rects.size(); ++i) {
198 // Avoid double painting. NOTE: This is only relevant given the call to
199 // Paint(scroll_rect) above.
200 gfx::Rect rect = gfx::SubtractRects(copy_rects[i], scroll_rect);
201 if (rect.IsEmpty())
202 continue;
203
204 if (about_to_validate_and_paint_)
205 invalid_rect_.Union(rect);
206 else
207 Paint(rect);
208 }
209 }
210
211 void RenderWidgetHostViewCast::RenderProcessGone(
212 base::TerminationStatus status, int error_code) {
213 Destroy();
214 }
215
216 void RenderWidgetHostViewCast::Destroy() {
217 // The RenderWidgetHost's destruction led here, so don't call it.
218 host_ = NULL;
219
220 // Delete the surface so that GfxPlane will not complain if/when we
221 // destroy the plane.
222 if (surface_) {
223 VLOG(1) << "gfx surface on the primary plane deleted.";
224 surface_.reset();
225 }
226
227 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
228 }
229
230 void RenderWidgetHostViewCast::SetTooltipText(
231 const base::string16& tooltip_text) {
232 NOTIMPLEMENTED();
233 }
234
235 void RenderWidgetHostViewCast::SelectionBoundsChanged(
236 const ViewHostMsg_SelectionBounds_Params& params) {
237 NOTIMPLEMENTED();
238 }
239
240 void RenderWidgetHostViewCast::ScrollOffsetChanged() {
241 NOTIMPLEMENTED();
242 }
243
244 void RenderWidgetHostViewCast::CopyFromCompositingSurface(
245 const gfx::Rect& subrect,
246 const gfx::Size& size,
247 const base::Callback<void(bool, const SkBitmap&)>& callback,
248 const SkBitmap::Config config) {
249 NOTIMPLEMENTED();
250 callback.Run(false, SkBitmap());
251 }
252
253 void RenderWidgetHostViewCast::CopyFromCompositingSurfaceToVideoFrame(
254 const gfx::Rect& src_subrect,
255 const scoped_refptr<media::VideoFrame>& target,
256 const base::Callback<void(bool)>& callback) {
257 NOTIMPLEMENTED();
258 callback.Run(false);
259 }
260
261 bool RenderWidgetHostViewCast::CanCopyToVideoFrame() const {
262 return false;
263 }
264
265 void RenderWidgetHostViewCast::AcceleratedSurfaceInitialized(int host_id,
266 int route_id) {
267 NOTIMPLEMENTED();
268 }
269
270 void RenderWidgetHostViewCast::AcceleratedSurfaceBuffersSwapped(
271 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
272 int gpu_host_id) {
273 AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
274 ack_params.sync_point = 0;
275 RenderWidgetHostImpl::AcknowledgeBufferPresent(
276 params.route_id, gpu_host_id, ack_params);
277 }
278
279 void RenderWidgetHostViewCast::AcceleratedSurfacePostSubBuffer(
280 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
281 int gpu_host_id) {
282 AcceleratedSurfaceMsg_BufferPresented_Params ack_params;
283 ack_params.sync_point = 0;
284 RenderWidgetHostImpl::AcknowledgeBufferPresent(
285 params.route_id, gpu_host_id, ack_params);
286 }
287
288 void RenderWidgetHostViewCast::AcceleratedSurfaceSuspend() {
289 NOTIMPLEMENTED();
290 }
291
292 void RenderWidgetHostViewCast::AcceleratedSurfaceRelease() {
293 NOTIMPLEMENTED();
294 }
295
296 bool RenderWidgetHostViewCast::HasAcceleratedSurface(
297 const gfx::Size& desired_size) {
298 return false;
299 }
300
301 void RenderWidgetHostViewCast::SetBackground(const SkBitmap& background) {
302 RenderWidgetHostViewBase::SetBackground(background);
303 host_->Send(new ViewMsg_SetBackground(host_->GetRoutingID(), background));
304 }
305
306 void RenderWidgetHostViewCast::Paint(const gfx::Rect& damage_rect) {
307 TRACE_EVENT0("ui::chromecast", "RenderWidgetHostViewCast::Paint");
308
309 // If the GPU process is rendering directly into the View,
310 // call the compositor directly.
311 RenderWidgetHostImpl* render_widget_host =
312 RenderWidgetHostImpl::From(GetRenderWidgetHost());
313 if (render_widget_host->is_accelerated_compositing_active()) {
314 host_->ScheduleComposite();
315 return;
316 }
317 NOTREACHED() << "Software rendering is deprecated";
318 }
319
320 void RenderWidgetHostViewCast::SetHasHorizontalScrollbar(
321 bool has_horizontal_scrollbar) {
322 }
323
324 void RenderWidgetHostViewCast::SetScrollOffsetPinning(
325 bool is_pinned_to_left, bool is_pinned_to_right) {
326 }
327
328 void RenderWidgetHostViewCast::OnAcceleratedCompositingStateChange() {
329 // TODO(lcwu): Work out if this is the right place to create the surface.
330 if (host_->is_accelerated_compositing_active()) {
331 DCHECK(!surface_);
332 VLOG(1) << "Creating chromecast surface";
333 surface_.reset(gfx::chromecast::GfxPlane::GetPrimary()->CreateSurface(
334 requested_size_));
335 } else {
336 surface_.reset();
337 }
338 NOTIMPLEMENTED();
339 }
340
341 void RenderWidgetHostViewCast::GetScreenInfo(blink::WebScreenInfo* results) {
342 NOTIMPLEMENTED();
343 }
344
345 gfx::Rect RenderWidgetHostViewCast::GetBoundsInRootWindow() {
346 NOTIMPLEMENTED() << "Bogus size returned";
347 return gfx::Rect(0, 0, 1280, 720);
348 }
349
350 gfx::GLSurfaceHandle RenderWidgetHostViewCast::GetCompositingSurface() {
351 NOTIMPLEMENTED();
352 return gfx::GLSurfaceHandle();
353 }
354
355 bool RenderWidgetHostViewCast::LockMouse() {
356 NOTIMPLEMENTED();
357 return false;
358 }
359
360 void RenderWidgetHostViewCast::UnlockMouse() {
361 NOTIMPLEMENTED();
362 }
363
364 void RenderWidgetHostViewCast::OnSwapCompositorFrame(
365 uint32 output_surface_id,
366 scoped_ptr<cc::CompositorFrame> frame) {
367 DCHECK(frame->software_frame_data);
368 scoped_ptr<cc::SoftwareFrameData> sw_frame_data(
369 frame->software_frame_data.Pass());
370 if (surface_) {
371 const gfx::Size& frame_size = sw_frame_data->size;
372 const gfx::Rect& damage_rect = sw_frame_data->damage_rect;
373 VLOG(1) << "damaged rect: " << damage_rect.ToString();
374
375 scoped_ptr<cc::SharedBitmap> bitmap =
376 HostSharedBitmapManager::current()->GetSharedBitmapFromId(
377 frame_size, sw_frame_data->bitmap_id);
378 if (!bitmap) {
379 LOG(ERROR) << "Cannot get the shared bitmap by id.";
380 return;
381 }
382
383 base::SharedMemory* shared_memory = bitmap->memory();
384
385 const size_t size_in_bytes = kARGBSizeInBytes * frame_size.GetArea();
386 shared_memory->Map(size_in_bytes);
387
388 void* memory = shared_memory->memory();
389
390 gfx::Rect fullFrame(frame_size.width(), frame_size.height());
391
392 surface_->CopyBitmap(static_cast<char*>(memory), fullFrame, damage_rect,
393 damage_rect.origin());
394
395 surface_->Display(damage_rect, damage_rect.origin());
396 }
397
398 cc::CompositorFrameAck ack;
399 ack.last_software_frame_id = sw_frame_data->id;
400 RenderWidgetHostImpl::SendSwapCompositorFrameAck(
401 host_->GetRoutingID(), output_surface_id, host_->GetProcess()->GetID(),
402 ack);
403 }
404
405 ////////////////////////////////////////////////////////////////////////////////
406 // RenderWidgetHostView, public:
407
408 // static
409 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
410 RenderWidgetHost* widget) {
411 return new RenderWidgetHostViewCast(widget);
412 }
413
414 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698