OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 | 301 |
302 if (event.type() == ui::ET_GESTURE_BEGIN) { | 302 if (event.type() == ui::ET_GESTURE_BEGIN) { |
303 const ui::GestureEvent& gesture = | 303 const ui::GestureEvent& gesture = |
304 static_cast<const ui::GestureEvent&>(event); | 304 static_cast<const ui::GestureEvent&>(event); |
305 return gesture.details().touch_points() == 1; | 305 return gesture.details().touch_points() == 1; |
306 } | 306 } |
307 | 307 |
308 return false; | 308 return false; |
309 } | 309 } |
310 | 310 |
311 // Swap ack for the renderer when kCompositeToMailbox is enabled. | |
312 void SendCompositorFrameAck( | |
313 int32 route_id, | |
314 uint32 output_surface_id, | |
315 int renderer_host_id, | |
316 const gpu::Mailbox& received_mailbox, | |
317 const gfx::Size& received_size, | |
318 bool skip_frame, | |
319 const scoped_refptr<ui::Texture>& texture_to_produce) { | |
320 cc::CompositorFrameAck ack; | |
321 ack.gl_frame_data.reset(new cc::GLFrameData()); | |
322 DCHECK(!texture_to_produce.get() || !skip_frame); | |
323 if (texture_to_produce.get()) { | |
324 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); | |
325 std::string mailbox_name = texture_to_produce->Produce(); | |
326 std::copy(mailbox_name.data(), | |
327 mailbox_name.data() + mailbox_name.length(), | |
328 reinterpret_cast<char*>(ack.gl_frame_data->mailbox.name)); | |
329 ack.gl_frame_data->size = texture_to_produce->size(); | |
330 ack.gl_frame_data->sync_point = | |
331 gl_helper ? gl_helper->InsertSyncPoint() : 0; | |
332 } else if (skip_frame) { | |
333 // Skip the frame, i.e. tell the producer to reuse the same buffer that | |
334 // we just received. | |
335 ack.gl_frame_data->size = received_size; | |
336 ack.gl_frame_data->mailbox = received_mailbox; | |
337 } | |
338 | |
339 RenderWidgetHostImpl::SendSwapCompositorFrameAck( | |
340 route_id, output_surface_id, renderer_host_id, ack); | |
341 } | |
342 | |
343 void AcknowledgeBufferForGpu( | |
344 int32 route_id, | |
345 int gpu_host_id, | |
346 const std::string& received_mailbox, | |
347 bool skip_frame, | |
348 const scoped_refptr<ui::Texture>& texture_to_produce) { | |
349 AcceleratedSurfaceMsg_BufferPresented_Params ack; | |
350 uint32 sync_point = 0; | |
351 DCHECK(!texture_to_produce.get() || !skip_frame); | |
352 if (texture_to_produce.get()) { | |
353 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); | |
354 ack.mailbox_name = texture_to_produce->Produce(); | |
355 sync_point = gl_helper ? gl_helper->InsertSyncPoint() : 0; | |
356 } else if (skip_frame) { | |
357 ack.mailbox_name = received_mailbox; | |
358 ack.sync_point = 0; | |
359 } | |
360 | |
361 ack.sync_point = sync_point; | |
362 RenderWidgetHostImpl::AcknowledgeBufferPresent( | |
363 route_id, gpu_host_id, ack); | |
364 } | |
365 | |
366 } // namespace | 311 } // namespace |
367 | 312 |
368 // We need to watch for mouse events outside a Web Popup or its parent | 313 // We need to watch for mouse events outside a Web Popup or its parent |
369 // and dismiss the popup for certain events. | 314 // and dismiss the popup for certain events. |
370 class RenderWidgetHostViewAura::EventFilterForPopupExit : | 315 class RenderWidgetHostViewAura::EventFilterForPopupExit : |
371 public ui::EventHandler { | 316 public ui::EventHandler { |
372 public: | 317 public: |
373 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) | 318 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) |
374 : rwhva_(rwhva) { | 319 : rwhva_(rwhva) { |
375 DCHECK(rwhva_); | 320 DCHECK(rwhva_); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
461 popup_child_host_view_(NULL), | 406 popup_child_host_view_(NULL), |
462 is_loading_(false), | 407 is_loading_(false), |
463 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 408 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
464 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 409 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
465 can_compose_inline_(true), | 410 can_compose_inline_(true), |
466 has_composition_text_(false), | 411 has_composition_text_(false), |
467 accept_return_character_(false), | 412 accept_return_character_(false), |
468 last_output_surface_id_(0), | 413 last_output_surface_id_(0), |
469 pending_delegated_ack_count_(0), | 414 pending_delegated_ack_count_(0), |
470 skipped_frames_(false), | 415 skipped_frames_(false), |
471 last_swapped_surface_scale_factor_(1.f), | 416 last_swapped_software_frame_scale_factor_(1.f), |
472 paint_canvas_(NULL), | 417 paint_canvas_(NULL), |
473 synthetic_move_sent_(false), | 418 synthetic_move_sent_(false), |
474 accelerated_compositing_state_changed_(false), | |
475 can_lock_compositor_(YES), | 419 can_lock_compositor_(YES), |
476 cursor_visibility_state_in_renderer_(UNKNOWN), | 420 cursor_visibility_state_in_renderer_(UNKNOWN), |
477 touch_editing_client_(NULL), | 421 touch_editing_client_(NULL), |
478 delegated_frame_evictor_(new DelegatedFrameEvictor(this)), | 422 delegated_frame_evictor_(new DelegatedFrameEvictor(this)), |
479 weak_ptr_factory_(this) { | 423 weak_ptr_factory_(this) { |
480 host_->SetView(this); | 424 host_->SetView(this); |
481 window_observer_.reset(new WindowObserver(this)); | 425 window_observer_.reset(new WindowObserver(this)); |
482 aura::client::SetTooltipText(window_, &tooltip_); | 426 aura::client::SetTooltipText(window_, &tooltip_); |
483 aura::client::SetActivationDelegate(window_, this); | 427 aura::client::SetActivationDelegate(window_, this); |
484 aura::client::SetActivationChangeObserver(window_, this); | 428 aura::client::SetActivationChangeObserver(window_, this); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 delegated_frame_evictor_->SetVisible(true); | 547 delegated_frame_evictor_->SetVisible(true); |
604 | 548 |
605 aura::Window* root = window_->GetRootWindow(); | 549 aura::Window* root = window_->GetRootWindow(); |
606 if (root) { | 550 if (root) { |
607 aura::client::CursorClient* cursor_client = | 551 aura::client::CursorClient* cursor_client = |
608 aura::client::GetCursorClient(root); | 552 aura::client::GetCursorClient(root); |
609 if (cursor_client) | 553 if (cursor_client) |
610 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 554 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
611 } | 555 } |
612 | 556 |
613 if (!current_surface_.get() && host_->is_accelerated_compositing_active() && | 557 if (host_->is_accelerated_compositing_active() && |
614 !released_front_lock_.get()) { | 558 !released_front_lock_.get()) { |
615 ui::Compositor* compositor = GetCompositor(); | 559 ui::Compositor* compositor = GetCompositor(); |
616 if (compositor) | 560 if (compositor) |
617 released_front_lock_ = compositor->GetCompositorLock(); | 561 released_front_lock_ = compositor->GetCompositorLock(); |
618 } | 562 } |
619 | 563 |
620 #if defined(OS_WIN) | 564 #if defined(OS_WIN) |
621 LPARAM lparam = reinterpret_cast<LPARAM>(this); | 565 LPARAM lparam = reinterpret_cast<LPARAM>(this); |
622 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); | 566 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); |
623 | 567 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 | 656 |
713 if (resize_lock_) | 657 if (resize_lock_) |
714 return false; | 658 return false; |
715 | 659 |
716 if (host_->should_auto_resize()) | 660 if (host_->should_auto_resize()) |
717 return false; | 661 return false; |
718 if (!host_->is_accelerated_compositing_active()) | 662 if (!host_->is_accelerated_compositing_active()) |
719 return false; | 663 return false; |
720 | 664 |
721 gfx::Size desired_size = window_->bounds().size(); | 665 gfx::Size desired_size = window_->bounds().size(); |
722 if (desired_size == current_frame_size_) | 666 if (desired_size == current_frame_size_in_dip_) |
723 return false; | 667 return false; |
724 | 668 |
725 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); | 669 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); |
726 if (!dispatcher) | 670 if (!dispatcher) |
727 return false; | 671 return false; |
728 | 672 |
729 ui::Compositor* compositor = dispatcher->host()->compositor(); | 673 ui::Compositor* compositor = dispatcher->host()->compositor(); |
730 if (!compositor) | 674 if (!compositor) |
731 return false; | 675 return false; |
732 | 676 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
943 const gfx::Range& range, | 887 const gfx::Range& range, |
944 const std::vector<gfx::Rect>& character_bounds) { | 888 const std::vector<gfx::Rect>& character_bounds) { |
945 composition_character_bounds_ = character_bounds; | 889 composition_character_bounds_ = character_bounds; |
946 } | 890 } |
947 | 891 |
948 void RenderWidgetHostViewAura::DidUpdateBackingStore( | 892 void RenderWidgetHostViewAura::DidUpdateBackingStore( |
949 const gfx::Rect& scroll_rect, | 893 const gfx::Rect& scroll_rect, |
950 const gfx::Vector2d& scroll_delta, | 894 const gfx::Vector2d& scroll_delta, |
951 const std::vector<gfx::Rect>& copy_rects, | 895 const std::vector<gfx::Rect>& copy_rects, |
952 const std::vector<ui::LatencyInfo>& latency_info) { | 896 const std::vector<ui::LatencyInfo>& latency_info) { |
953 if (accelerated_compositing_state_changed_) | |
954 UpdateExternalTexture(); | |
955 | |
956 for (size_t i = 0; i < latency_info.size(); i++) | 897 for (size_t i = 0; i < latency_info.size(); i++) |
957 software_latency_info_.push_back(latency_info[i]); | 898 software_latency_info_.push_back(latency_info[i]); |
958 | 899 |
959 // Use the state of the RenderWidgetHost and not the window as the two may | 900 // Use the state of the RenderWidgetHost and not the window as the two may |
960 // differ. In particular if the window is hidden but the renderer isn't and we | 901 // differ. In particular if the window is hidden but the renderer isn't and we |
961 // ignore the update and the window is made visible again the layer isn't | 902 // ignore the update and the window is made visible again the layer isn't |
962 // marked as dirty and we show the wrong thing. | 903 // marked as dirty and we show the wrong thing. |
963 // We do this after UpdateExternalTexture() so that when we become visible | |
964 // we're not drawing a stale texture. | |
965 if (host_->is_hidden()) | 904 if (host_->is_hidden()) |
966 return; | 905 return; |
967 | 906 |
968 gfx::Rect clip_rect; | 907 gfx::Rect clip_rect; |
969 if (paint_canvas_) { | 908 if (paint_canvas_) { |
970 SkRect sk_clip_rect; | 909 SkRect sk_clip_rect; |
971 if (paint_canvas_->sk_canvas()->getClipBounds(&sk_clip_rect)) | 910 if (paint_canvas_->sk_canvas()->getClipBounds(&sk_clip_rect)) |
972 clip_rect = gfx::ToEnclosingRect(gfx::SkRectToRectF(sk_clip_rect)); | 911 clip_rect = gfx::ToEnclosingRect(gfx::SkRectToRectF(sk_clip_rect)); |
973 } | 912 } |
974 | 913 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1167 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { | 1106 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { |
1168 frame_subscriber_ = subscriber.Pass(); | 1107 frame_subscriber_ = subscriber.Pass(); |
1169 } | 1108 } |
1170 | 1109 |
1171 void RenderWidgetHostViewAura::EndFrameSubscription() { | 1110 void RenderWidgetHostViewAura::EndFrameSubscription() { |
1172 idle_frame_subscriber_textures_.clear(); | 1111 idle_frame_subscriber_textures_.clear(); |
1173 frame_subscriber_.reset(); | 1112 frame_subscriber_.reset(); |
1174 } | 1113 } |
1175 | 1114 |
1176 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { | 1115 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { |
1177 // Delay processing the state change until we either get a software frame if | |
1178 // switching to software mode or receive a buffers swapped notification | |
1179 // if switching to accelerated mode. | |
1180 // Sometimes (e.g. on a page load) the renderer will spuriously disable then | |
1181 // re-enable accelerated compositing, causing us to flash. | |
1182 // TODO(piman): factor the enable/disable accelerated compositing message into | |
1183 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have | |
1184 // fewer inconsistent temporary states. | |
1185 accelerated_compositing_state_changed_ = true; | |
1186 } | 1116 } |
1187 | 1117 |
1188 void RenderWidgetHostViewAura::AcceleratedSurfaceInitialized(int host_id, | 1118 void RenderWidgetHostViewAura::AcceleratedSurfaceInitialized(int host_id, |
1189 int route_id) { | 1119 int route_id) { |
1190 } | 1120 } |
1191 | 1121 |
1192 bool RenderWidgetHostViewAura::ShouldSkipFrame(gfx::Size size_in_dip) const { | 1122 bool RenderWidgetHostViewAura::ShouldSkipFrame(gfx::Size size_in_dip) const { |
1193 if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || | 1123 if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || |
1194 can_lock_compositor_ == NO_PENDING_COMMIT || | 1124 can_lock_compositor_ == NO_PENDING_COMMIT || |
1195 !resize_lock_.get()) | 1125 !resize_lock_.get()) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1231 if (::IsWindow(plugin_parent_window_)) { | 1161 if (::IsWindow(plugin_parent_window_)) { |
1232 gfx::Rect window_bounds = window_->GetBoundsInRootWindow(); | 1162 gfx::Rect window_bounds = window_->GetBoundsInRootWindow(); |
1233 ::SetWindowPos(plugin_parent_window_, NULL, window_bounds.x(), | 1163 ::SetWindowPos(plugin_parent_window_, NULL, window_bounds.x(), |
1234 window_bounds.y(), window_bounds.width(), | 1164 window_bounds.y(), window_bounds.width(), |
1235 window_bounds.height(), 0); | 1165 window_bounds.height(), 0); |
1236 } | 1166 } |
1237 #endif | 1167 #endif |
1238 } | 1168 } |
1239 | 1169 |
1240 void RenderWidgetHostViewAura::CheckResizeLock() { | 1170 void RenderWidgetHostViewAura::CheckResizeLock() { |
1241 if (!resize_lock_ || resize_lock_->expected_size() != current_frame_size_) | 1171 if (!resize_lock_ || |
1172 resize_lock_->expected_size() != current_frame_size_in_dip_) | |
1242 return; | 1173 return; |
1243 | 1174 |
1244 // Since we got the size we were looking for, unlock the compositor. But delay | 1175 // Since we got the size we were looking for, unlock the compositor. But delay |
1245 // the release of the lock until we've kicked a frame with the new texture, to | 1176 // the release of the lock until we've kicked a frame with the new texture, to |
1246 // avoid resizing the UI before we have a chance to draw a "good" frame. | 1177 // avoid resizing the UI before we have a chance to draw a "good" frame. |
1247 resize_lock_->UnlockCompositor(); | 1178 resize_lock_->UnlockCompositor(); |
1248 ui::Compositor* compositor = GetCompositor(); | 1179 ui::Compositor* compositor = GetCompositor(); |
1249 if (compositor) { | 1180 if (compositor) { |
1250 if (!compositor->HasObserver(this)) | 1181 if (!compositor->HasObserver(this)) |
1251 compositor->AddObserver(this); | 1182 compositor->AddObserver(this); |
1252 } | 1183 } |
1253 } | 1184 } |
1254 | 1185 |
1255 void RenderWidgetHostViewAura::UpdateExternalTexture() { | |
1256 // Delay processing accelerated compositing state change till here where we | |
1257 // act upon the state change. (Clear the external texture if switching to | |
1258 // software mode or set the external texture if going to accelerated mode). | |
1259 if (accelerated_compositing_state_changed_) | |
1260 accelerated_compositing_state_changed_ = false; | |
1261 | |
1262 bool is_compositing_active = host_->is_accelerated_compositing_active(); | |
1263 if (is_compositing_active && current_surface_.get()) { | |
1264 window_->layer()->SetExternalTexture(current_surface_.get()); | |
1265 current_frame_size_ = ConvertSizeToDIP( | |
1266 current_surface_->device_scale_factor(), current_surface_->size()); | |
1267 CheckResizeLock(); | |
1268 software_frame_manager_->DiscardCurrentFrame(); | |
1269 } else if (is_compositing_active && | |
1270 software_frame_manager_->HasCurrentFrame()) { | |
1271 cc::TextureMailbox mailbox; | |
1272 scoped_ptr<cc::SingleReleaseCallback> callback; | |
1273 software_frame_manager_->GetCurrentFrameMailbox(&mailbox, &callback); | |
1274 window_->layer()->SetTextureMailbox(mailbox, | |
1275 callback.Pass(), | |
1276 last_swapped_surface_scale_factor_); | |
1277 current_frame_size_ = ConvertSizeToDIP(last_swapped_surface_scale_factor_, | |
1278 mailbox.shared_memory_size()); | |
1279 CheckResizeLock(); | |
1280 } else { | |
1281 window_->layer()->SetShowPaintedContent(); | |
1282 resize_lock_.reset(); | |
1283 host_->WasResized(); | |
1284 software_frame_manager_->DiscardCurrentFrame(); | |
1285 } | |
1286 } | |
1287 | |
1288 bool RenderWidgetHostViewAura::SwapBuffersPrepare( | |
1289 const gfx::Rect& surface_rect, | |
1290 float surface_scale_factor, | |
1291 const gfx::Rect& damage_rect, | |
1292 const std::string& mailbox_name, | |
1293 const BufferPresentedCallback& ack_callback) { | |
1294 if (last_swapped_surface_size_ != surface_rect.size()) { | |
1295 // The surface could have shrunk since we skipped an update, in which | |
1296 // case we can expect a full update. | |
1297 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; | |
1298 skipped_damage_.setEmpty(); | |
1299 last_swapped_surface_size_ = surface_rect.size(); | |
1300 last_swapped_surface_scale_factor_ = surface_scale_factor; | |
1301 } | |
1302 | |
1303 if (ShouldSkipFrame(ConvertSizeToDIP(surface_scale_factor, | |
1304 surface_rect.size())) || | |
1305 mailbox_name.empty()) { | |
1306 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); | |
1307 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | |
1308 return false; | |
1309 } | |
1310 | |
1311 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | |
1312 current_surface_ = | |
1313 factory->CreateTransportClient(surface_scale_factor); | |
1314 if (!current_surface_.get()) { | |
1315 LOG(ERROR) << "Failed to create ImageTransport texture"; | |
1316 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | |
1317 return false; | |
1318 } | |
1319 | |
1320 current_surface_->Consume(mailbox_name, surface_rect.size()); | |
1321 released_front_lock_ = NULL; | |
1322 UpdateExternalTexture(); | |
1323 | |
1324 return true; | |
1325 } | |
1326 | |
1327 void RenderWidgetHostViewAura::SwapBuffersCompleted( | |
1328 const BufferPresentedCallback& ack_callback, | |
1329 const scoped_refptr<ui::Texture>& texture_to_return) { | |
1330 ui::Compositor* compositor = GetCompositor(); | |
1331 if (!compositor) { | |
1332 ack_callback.Run(false, texture_to_return); | |
1333 } else { | |
1334 AddOnCommitCallbackAndDisableLocks( | |
1335 base::Bind(ack_callback, false, texture_to_return)); | |
1336 } | |
1337 | |
1338 DidReceiveFrameFromRenderer(); | |
1339 } | |
1340 | |
1341 void RenderWidgetHostViewAura::DidReceiveFrameFromRenderer() { | 1186 void RenderWidgetHostViewAura::DidReceiveFrameFromRenderer() { |
1342 if (frame_subscriber() && CanCopyToVideoFrame()) { | 1187 if (frame_subscriber() && CanCopyToVideoFrame()) { |
1343 const base::TimeTicks present_time = base::TimeTicks::Now(); | 1188 const base::TimeTicks present_time = base::TimeTicks::Now(); |
1344 scoped_refptr<media::VideoFrame> frame; | 1189 scoped_refptr<media::VideoFrame> frame; |
1345 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; | 1190 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; |
1346 if (frame_subscriber()->ShouldCaptureFrame(present_time, | 1191 if (frame_subscriber()->ShouldCaptureFrame(present_time, |
1347 &frame, &callback)) { | 1192 &frame, &callback)) { |
1348 CopyFromCompositingSurfaceToVideoFrame( | 1193 CopyFromCompositingSurfaceToVideoFrame( |
1349 gfx::Rect(current_frame_size_), | 1194 gfx::Rect(current_frame_size_in_dip_), |
1350 frame, | 1195 frame, |
1351 base::Bind(callback, present_time)); | 1196 base::Bind(callback, present_time)); |
1352 } | 1197 } |
1353 } | 1198 } |
1354 } | 1199 } |
1355 | 1200 |
1356 #if defined(OS_WIN) | 1201 #if defined(OS_WIN) |
1357 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects( | 1202 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects( |
1358 const std::vector<gfx::Rect>& rects) { | 1203 const std::vector<gfx::Rect>& rects) { |
1359 // Check this before setting constrained_rects_, so that next time they're set | 1204 // Check this before setting constrained_rects_, so that next time they're set |
(...skipping 12 matching lines...) Expand all Loading... | |
1372 params.cutout_rects = constrained_rects_; | 1217 params.cutout_rects = constrained_rects_; |
1373 params.geometry = &plugin_window_moves_; | 1218 params.geometry = &plugin_window_moves_; |
1374 LPARAM lparam = reinterpret_cast<LPARAM>(¶ms); | 1219 LPARAM lparam = reinterpret_cast<LPARAM>(¶ms); |
1375 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); | 1220 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); |
1376 } | 1221 } |
1377 #endif | 1222 #endif |
1378 | 1223 |
1379 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | 1224 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
1380 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, | 1225 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, |
1381 int gpu_host_id) { | 1226 int gpu_host_id) { |
1382 BufferPresentedCallback ack_callback = base::Bind( | 1227 // Oldschool composited mode is no longer supported. |
jamesr
2014/02/07 20:43:49
should we NOTREACHED() this? why is this function
danakj
2014/02/07 20:48:06
It's a pure virtual method on RWHVPort, so we need
danakj
2014/02/07 20:49:03
I think we can remove this when GTK linux goes awa
| |
1383 &AcknowledgeBufferForGpu, | |
1384 params_in_pixel.route_id, | |
1385 gpu_host_id, | |
1386 params_in_pixel.mailbox_name); | |
1387 BuffersSwapped(params_in_pixel.size, | |
1388 gfx::Rect(params_in_pixel.size), | |
1389 params_in_pixel.scale_factor, | |
1390 params_in_pixel.mailbox_name, | |
1391 params_in_pixel.latency_info, | |
1392 ack_callback); | |
1393 } | 1228 } |
1394 | 1229 |
1395 void RenderWidgetHostViewAura::SwapDelegatedFrame( | 1230 void RenderWidgetHostViewAura::SwapDelegatedFrame( |
1396 uint32 output_surface_id, | 1231 uint32 output_surface_id, |
1397 scoped_ptr<cc::DelegatedFrameData> frame_data, | 1232 scoped_ptr<cc::DelegatedFrameData> frame_data, |
1398 float frame_device_scale_factor, | 1233 float frame_device_scale_factor, |
1399 const std::vector<ui::LatencyInfo>& latency_info) { | 1234 const std::vector<ui::LatencyInfo>& latency_info) { |
1400 DCHECK_NE(0u, frame_data->render_pass_list.size()); | 1235 DCHECK_NE(0u, frame_data->render_pass_list.size()); |
1401 | 1236 |
1402 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); | 1237 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1462 if (!resource_collection_) { | 1297 if (!resource_collection_) { |
1463 resource_collection_ = new cc::DelegatedFrameResourceCollection; | 1298 resource_collection_ = new cc::DelegatedFrameResourceCollection; |
1464 resource_collection_->SetClient(this); | 1299 resource_collection_->SetClient(this); |
1465 } | 1300 } |
1466 // If the physical frame size changes, we need a new |frame_provider_|. If | 1301 // If the physical frame size changes, we need a new |frame_provider_|. If |
1467 // the physical frame size is the same, but the size in DIP changed, we | 1302 // the physical frame size is the same, but the size in DIP changed, we |
1468 // need to adjust the scale at which the frames will be drawn, and we do | 1303 // need to adjust the scale at which the frames will be drawn, and we do |
1469 // this by making a new |frame_provider_| also to ensure the scale change | 1304 // this by making a new |frame_provider_| also to ensure the scale change |
1470 // is presented in sync with the new frame content. | 1305 // is presented in sync with the new frame content. |
1471 if (!frame_provider_.get() || frame_size != frame_provider_->frame_size() || | 1306 if (!frame_provider_.get() || frame_size != frame_provider_->frame_size() || |
1472 frame_size_in_dip != current_frame_size_) { | 1307 frame_size_in_dip != current_frame_size_in_dip_) { |
1473 frame_provider_ = new cc::DelegatedFrameProvider( | 1308 frame_provider_ = new cc::DelegatedFrameProvider( |
1474 resource_collection_.get(), frame_data.Pass()); | 1309 resource_collection_.get(), frame_data.Pass()); |
1475 window_->layer()->SetShowDelegatedContent(frame_provider_.get(), | 1310 window_->layer()->SetShowDelegatedContent(frame_provider_.get(), |
1476 frame_size_in_dip); | 1311 frame_size_in_dip); |
1477 } else { | 1312 } else { |
1478 frame_provider_->SetFrameData(frame_data.Pass()); | 1313 frame_provider_->SetFrameData(frame_data.Pass()); |
1479 } | 1314 } |
1480 } | 1315 } |
1481 released_front_lock_ = NULL; | 1316 released_front_lock_ = NULL; |
1482 current_frame_size_ = frame_size_in_dip; | 1317 current_frame_size_in_dip_ = frame_size_in_dip; |
1483 CheckResizeLock(); | 1318 CheckResizeLock(); |
1484 | 1319 |
1485 window_->SchedulePaintInRect(damage_rect_in_dip); | 1320 window_->SchedulePaintInRect(damage_rect_in_dip); |
1486 | 1321 |
1487 pending_delegated_ack_count_++; | 1322 pending_delegated_ack_count_++; |
1488 | 1323 |
1489 ui::Compositor* compositor = GetCompositor(); | 1324 ui::Compositor* compositor = GetCompositor(); |
1490 if (!compositor) { | 1325 if (!compositor) { |
1491 SendDelegatedFrameAck(output_surface_id); | 1326 SendDelegatedFrameAck(output_surface_id); |
1492 } else { | 1327 } else { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1561 if (!software_frame_manager_->SwapToNewFrame( | 1396 if (!software_frame_manager_->SwapToNewFrame( |
1562 output_surface_id, | 1397 output_surface_id, |
1563 frame_data.get(), | 1398 frame_data.get(), |
1564 frame_device_scale_factor, | 1399 frame_device_scale_factor, |
1565 host_->GetProcess()->GetHandle())) { | 1400 host_->GetProcess()->GetHandle())) { |
1566 ReleaseSoftwareFrame(output_surface_id, frame_data->id); | 1401 ReleaseSoftwareFrame(output_surface_id, frame_data->id); |
1567 SendSoftwareFrameAck(output_surface_id); | 1402 SendSoftwareFrameAck(output_surface_id); |
1568 return; | 1403 return; |
1569 } | 1404 } |
1570 | 1405 |
1571 if (last_swapped_surface_size_ != frame_size) { | 1406 frame_provider_ = NULL; |
1407 delegated_frame_evictor_->DiscardedFrame(); | |
1408 | |
1409 if (last_swapped_software_frame_size_ != frame_size) { | |
1572 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size)) | 1410 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size)) |
1573 << "Expected full damage rect"; | 1411 << "Expected full damage rect"; |
1574 } | 1412 } |
1575 last_swapped_surface_size_ = frame_size; | 1413 last_swapped_software_frame_size_ = frame_size; |
1576 last_swapped_surface_scale_factor_ = frame_device_scale_factor; | 1414 last_swapped_software_frame_scale_factor_ = frame_device_scale_factor; |
1577 | 1415 |
1578 cc::TextureMailbox mailbox; | 1416 cc::TextureMailbox mailbox; |
1579 scoped_ptr<cc::SingleReleaseCallback> callback; | 1417 scoped_ptr<cc::SingleReleaseCallback> callback; |
1580 software_frame_manager_->GetCurrentFrameMailbox(&mailbox, &callback); | 1418 software_frame_manager_->GetCurrentFrameMailbox(&mailbox, &callback); |
1581 DCHECK(mailbox.IsSharedMemory()); | 1419 DCHECK(mailbox.IsSharedMemory()); |
1582 current_frame_size_ = frame_size_in_dip; | 1420 current_frame_size_in_dip_ = frame_size_in_dip; |
1583 | 1421 |
1584 released_front_lock_ = NULL; | 1422 released_front_lock_ = NULL; |
1585 CheckResizeLock(); | 1423 CheckResizeLock(); |
1586 window_->layer()->SetTextureMailbox(mailbox, | 1424 window_->layer()->SetTextureMailbox(mailbox, |
1587 callback.Pass(), | 1425 callback.Pass(), |
1588 frame_device_scale_factor); | 1426 frame_device_scale_factor); |
1589 window_->SchedulePaintInRect( | 1427 window_->SchedulePaintInRect( |
1590 ConvertRectToDIP(frame_device_scale_factor, damage_rect)); | 1428 ConvertRectToDIP(frame_device_scale_factor, damage_rect)); |
1591 | 1429 |
1592 ui::Compositor* compositor = GetCompositor(); | 1430 ui::Compositor* compositor = GetCompositor(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1643 | 1481 |
1644 void RenderWidgetHostViewAura::OnSwapCompositorFrame( | 1482 void RenderWidgetHostViewAura::OnSwapCompositorFrame( |
1645 uint32 output_surface_id, | 1483 uint32 output_surface_id, |
1646 scoped_ptr<cc::CompositorFrame> frame) { | 1484 scoped_ptr<cc::CompositorFrame> frame) { |
1647 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); | 1485 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); |
1648 if (frame->delegated_frame_data) { | 1486 if (frame->delegated_frame_data) { |
1649 SwapDelegatedFrame(output_surface_id, | 1487 SwapDelegatedFrame(output_surface_id, |
1650 frame->delegated_frame_data.Pass(), | 1488 frame->delegated_frame_data.Pass(), |
1651 frame->metadata.device_scale_factor, | 1489 frame->metadata.device_scale_factor, |
1652 frame->metadata.latency_info); | 1490 frame->metadata.latency_info); |
1653 return; | 1491 } else if (frame->software_frame_data) { |
1654 } | |
1655 | |
1656 if (frame->software_frame_data) { | |
1657 SwapSoftwareFrame(output_surface_id, | 1492 SwapSoftwareFrame(output_surface_id, |
1658 frame->software_frame_data.Pass(), | 1493 frame->software_frame_data.Pass(), |
1659 frame->metadata.device_scale_factor, | 1494 frame->metadata.device_scale_factor, |
1660 frame->metadata.latency_info); | 1495 frame->metadata.latency_info); |
1661 return; | |
1662 } | 1496 } |
1663 | |
1664 if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero()) | |
1665 return; | |
1666 | |
1667 BufferPresentedCallback ack_callback = base::Bind( | |
1668 &SendCompositorFrameAck, | |
1669 host_->GetRoutingID(), output_surface_id, host_->GetProcess()->GetID(), | |
1670 frame->gl_frame_data->mailbox, frame->gl_frame_data->size); | |
1671 | |
1672 if (!frame->gl_frame_data->sync_point) { | |
1673 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; | |
1674 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | |
1675 return; | |
1676 } | |
1677 | |
1678 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); | |
1679 gl_helper->WaitSyncPoint(frame->gl_frame_data->sync_point); | |
1680 | |
1681 std::string mailbox_name( | |
1682 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), | |
1683 sizeof(frame->gl_frame_data->mailbox.name)); | |
1684 BuffersSwapped(frame->gl_frame_data->size, | |
1685 frame->gl_frame_data->sub_buffer_rect, | |
1686 frame->metadata.device_scale_factor, | |
1687 mailbox_name, | |
1688 frame->metadata.latency_info, | |
1689 ack_callback); | |
1690 } | 1497 } |
1691 | 1498 |
1692 #if defined(OS_WIN) | 1499 #if defined(OS_WIN) |
1693 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( | 1500 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( |
1694 gfx::NativeViewAccessible accessible_parent) { | 1501 gfx::NativeViewAccessible accessible_parent) { |
1695 if (GetBrowserAccessibilityManager()) { | 1502 if (GetBrowserAccessibilityManager()) { |
1696 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() | 1503 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() |
1697 ->set_parent_iaccessible(accessible_parent); | 1504 ->set_parent_iaccessible(accessible_parent); |
1698 } | 1505 } |
1699 } | 1506 } |
1700 | 1507 |
1701 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() | 1508 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() |
1702 const { | 1509 const { |
1703 return reinterpret_cast<gfx::NativeViewId>(plugin_parent_window_); | 1510 return reinterpret_cast<gfx::NativeViewId>(plugin_parent_window_); |
1704 } | 1511 } |
1705 #endif | 1512 #endif |
1706 | 1513 |
1707 void RenderWidgetHostViewAura::BuffersSwapped( | |
1708 const gfx::Size& surface_size, | |
1709 const gfx::Rect& damage_rect, | |
1710 float surface_scale_factor, | |
1711 const std::string& mailbox_name, | |
1712 const std::vector<ui::LatencyInfo>& latency_info, | |
1713 const BufferPresentedCallback& ack_callback) { | |
1714 scoped_refptr<ui::Texture> previous_texture(current_surface_); | |
1715 const gfx::Rect surface_rect = gfx::Rect(surface_size); | |
1716 software_frame_manager_->DiscardCurrentFrame(); | |
1717 | |
1718 if (!SwapBuffersPrepare(surface_rect, | |
1719 surface_scale_factor, | |
1720 damage_rect, | |
1721 mailbox_name, | |
1722 ack_callback)) { | |
1723 return; | |
1724 } | |
1725 | |
1726 SkRegion damage(RectToSkIRect(damage_rect)); | |
1727 if (!skipped_damage_.isEmpty()) { | |
1728 damage.op(skipped_damage_, SkRegion::kUnion_Op); | |
1729 skipped_damage_.setEmpty(); | |
1730 } | |
1731 | |
1732 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds()))); | |
1733 ui::Texture* current_texture = current_surface_.get(); | |
1734 | |
1735 const gfx::Size surface_size_in_pixel = surface_size; | |
1736 DLOG_IF(ERROR, previous_texture.get() && | |
1737 previous_texture->size() != current_texture->size() && | |
1738 SkIRectToRect(damage.getBounds()) != surface_rect) << | |
1739 "Expected full damage rect after size change"; | |
1740 if (previous_texture.get() && !previous_damage_.isEmpty() && | |
1741 previous_texture->size() == current_texture->size()) { | |
1742 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | |
1743 GLHelper* gl_helper = factory->GetGLHelper(); | |
1744 gl_helper->CopySubBufferDamage( | |
1745 current_texture->PrepareTexture(), | |
1746 previous_texture->PrepareTexture(), | |
1747 damage, | |
1748 previous_damage_); | |
1749 } | |
1750 previous_damage_ = damage; | |
1751 | |
1752 ui::Compositor* compositor = GetCompositor(); | |
1753 if (compositor) { | |
1754 // Co-ordinates come in OpenGL co-ordinate space. | |
1755 // We need to convert to layer space. | |
1756 gfx::Rect rect_to_paint = | |
1757 ConvertRectToDIP(surface_scale_factor, | |
1758 gfx::Rect(damage_rect.x(), | |
1759 surface_size_in_pixel.height() - | |
1760 damage_rect.y() - damage_rect.height(), | |
1761 damage_rect.width(), | |
1762 damage_rect.height())); | |
1763 | |
1764 // Damage may not have been DIP aligned, so inflate damage to compensate | |
1765 // for any round-off error. | |
1766 rect_to_paint.Inset(-1, -1); | |
1767 rect_to_paint.Intersect(window_->bounds()); | |
1768 | |
1769 window_->SchedulePaintInRect(rect_to_paint); | |
1770 for (size_t i = 0; i < latency_info.size(); i++) | |
1771 compositor->SetLatencyInfo(latency_info[i]); | |
1772 } | |
1773 | |
1774 SwapBuffersCompleted(ack_callback, previous_texture); | |
1775 } | |
1776 | |
1777 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | 1514 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
1778 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | 1515 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
1779 int gpu_host_id) { | 1516 int gpu_host_id) { |
1780 gfx::Rect damage_rect(params_in_pixel.x, | 1517 // Oldschool composited mode is no longer supported. |
jamesr
2014/02/07 20:43:49
ditto
| |
1781 params_in_pixel.y, | |
1782 params_in_pixel.width, | |
1783 params_in_pixel.height); | |
1784 BufferPresentedCallback ack_callback = | |
1785 base::Bind(&AcknowledgeBufferForGpu, | |
1786 params_in_pixel.route_id, | |
1787 gpu_host_id, | |
1788 params_in_pixel.mailbox_name); | |
1789 BuffersSwapped(params_in_pixel.surface_size, | |
1790 damage_rect, | |
1791 params_in_pixel.surface_scale_factor, | |
1792 params_in_pixel.mailbox_name, | |
1793 params_in_pixel.latency_info, | |
1794 ack_callback); | |
1795 } | 1518 } |
1796 | 1519 |
1797 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { | 1520 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { |
1798 } | 1521 } |
1799 | 1522 |
1800 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { | 1523 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { |
1801 // This really tells us to release the frontbuffer. | |
1802 if (current_surface_.get()) { | |
1803 ui::Compositor* compositor = GetCompositor(); | |
1804 if (compositor) { | |
1805 // We need to wait for a commit to clear to guarantee that all we | |
1806 // will not issue any more GL referencing the previous surface. | |
1807 AddOnCommitCallbackAndDisableLocks( | |
1808 base::Bind(&RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor, | |
1809 AsWeakPtr(), | |
1810 current_surface_)); // Hold a ref so the texture will not | |
1811 // get deleted until after commit. | |
1812 } | |
1813 current_surface_ = NULL; | |
1814 UpdateExternalTexture(); | |
1815 } | |
1816 } | 1524 } |
1817 | 1525 |
1818 bool RenderWidgetHostViewAura::HasAcceleratedSurface( | 1526 bool RenderWidgetHostViewAura::HasAcceleratedSurface( |
1819 const gfx::Size& desired_size) { | 1527 const gfx::Size& desired_size) { |
1820 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't | 1528 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't |
1821 // matter what is returned here as GetBackingStore is the only caller of this | 1529 // matter what is returned here as GetBackingStore is the only caller of this |
1822 // method. TODO(jbates) implement this if other Aura code needs it. | 1530 // method. TODO(jbates) implement this if other Aura code needs it. |
1823 return false; | 1531 return false; |
1824 } | 1532 } |
1825 | 1533 |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2668 } | 2376 } |
2669 | 2377 |
2670 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { | 2378 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { |
2671 } | 2379 } |
2672 | 2380 |
2673 void RenderWidgetHostViewAura::DidRecreateLayer(ui::Layer *old_layer, | 2381 void RenderWidgetHostViewAura::DidRecreateLayer(ui::Layer *old_layer, |
2674 ui::Layer *new_layer) { | 2382 ui::Layer *new_layer) { |
2675 float mailbox_scale_factor; | 2383 float mailbox_scale_factor; |
2676 cc::TextureMailbox old_mailbox = | 2384 cc::TextureMailbox old_mailbox = |
2677 old_layer->GetTextureMailbox(&mailbox_scale_factor); | 2385 old_layer->GetTextureMailbox(&mailbox_scale_factor); |
2678 scoped_refptr<ui::Texture> old_texture = old_layer->external_texture(); | |
2679 // The new_layer is the one that will be used by our Window, so that's the one | 2386 // The new_layer is the one that will be used by our Window, so that's the one |
2680 // that should keep our texture. old_layer will be returned to the | 2387 // that should keep our texture. old_layer will be returned to the |
2681 // RecreateLayer caller, and should have a copy. | 2388 // RecreateLayer caller, and should have a copy. |
2682 if (old_texture.get()) { | 2389 if (old_mailbox.IsSharedMemory()) { |
2683 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | |
2684 GLHelper* gl_helper = factory->GetGLHelper(); | |
2685 scoped_refptr<ui::Texture> new_texture; | |
2686 if (host_->is_accelerated_compositing_active() && | |
2687 gl_helper && current_surface_.get()) { | |
2688 GLuint texture_id = | |
2689 gl_helper->CopyTexture(current_surface_->PrepareTexture(), | |
2690 current_surface_->size()); | |
2691 if (texture_id) { | |
2692 new_texture = factory->CreateOwnedTexture( | |
2693 current_surface_->size(), | |
2694 current_surface_->device_scale_factor(), texture_id); | |
2695 } | |
2696 } | |
2697 if (new_texture.get()) | |
2698 old_layer->SetExternalTexture(new_texture.get()); | |
2699 else | |
2700 old_layer->SetShowPaintedContent(); | |
2701 new_layer->SetExternalTexture(old_texture.get()); | |
2702 } else if (old_mailbox.IsSharedMemory()) { | |
2703 base::SharedMemory* old_buffer = old_mailbox.shared_memory(); | 2390 base::SharedMemory* old_buffer = old_mailbox.shared_memory(); |
2704 const size_t size = old_mailbox.shared_memory_size_in_bytes(); | 2391 const size_t size = old_mailbox.shared_memory_size_in_bytes(); |
2705 | 2392 |
2706 scoped_ptr<base::SharedMemory> new_buffer(new base::SharedMemory); | 2393 scoped_ptr<base::SharedMemory> new_buffer(new base::SharedMemory); |
2707 new_buffer->CreateAndMapAnonymous(size); | 2394 new_buffer->CreateAndMapAnonymous(size); |
2708 | 2395 |
2709 if (old_buffer->memory() && new_buffer->memory()) { | 2396 if (old_buffer->memory() && new_buffer->memory()) { |
2710 memcpy(new_buffer->memory(), old_buffer->memory(), size); | 2397 memcpy(new_buffer->memory(), old_buffer->memory(), size); |
2711 base::SharedMemory* new_buffer_raw_ptr = new_buffer.get(); | 2398 base::SharedMemory* new_buffer_raw_ptr = new_buffer.get(); |
2712 scoped_ptr<cc::SingleReleaseCallback> callback = | 2399 scoped_ptr<cc::SingleReleaseCallback> callback = |
2713 cc::SingleReleaseCallback::Create(base::Bind(MailboxReleaseCallback, | 2400 cc::SingleReleaseCallback::Create(base::Bind(MailboxReleaseCallback, |
2714 Passed(&new_buffer))); | 2401 Passed(&new_buffer))); |
2715 cc::TextureMailbox new_mailbox(new_buffer_raw_ptr, | 2402 cc::TextureMailbox new_mailbox(new_buffer_raw_ptr, |
2716 old_mailbox.shared_memory_size()); | 2403 old_mailbox.shared_memory_size()); |
2717 new_layer->SetTextureMailbox(new_mailbox, | 2404 new_layer->SetTextureMailbox(new_mailbox, |
2718 callback.Pass(), | 2405 callback.Pass(), |
2719 mailbox_scale_factor); | 2406 mailbox_scale_factor); |
2720 } | 2407 } |
2721 } else if (frame_provider_.get()) { | 2408 } else if (frame_provider_.get()) { |
2722 new_layer->SetShowDelegatedContent(frame_provider_.get(), | 2409 new_layer->SetShowDelegatedContent(frame_provider_.get(), |
2723 current_frame_size_); | 2410 current_frame_size_in_dip_); |
2724 } | 2411 } |
2725 } | 2412 } |
2726 | 2413 |
2727 //////////////////////////////////////////////////////////////////////////////// | 2414 //////////////////////////////////////////////////////////////////////////////// |
2728 // RenderWidgetHostViewAura, ui::EventHandler implementation: | 2415 // RenderWidgetHostViewAura, ui::EventHandler implementation: |
2729 | 2416 |
2730 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { | 2417 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { |
2731 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); | 2418 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); |
2732 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | 2419 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) |
2733 return; | 2420 return; |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3150 uint32 output_surface_id, unsigned frame_id) { | 2837 uint32 output_surface_id, unsigned frame_id) { |
3151 ReleaseSoftwareFrame(output_surface_id, frame_id); | 2838 ReleaseSoftwareFrame(output_surface_id, frame_id); |
3152 } | 2839 } |
3153 | 2840 |
3154 void RenderWidgetHostViewAura::ReleaseReferencesToSoftwareFrame() { | 2841 void RenderWidgetHostViewAura::ReleaseReferencesToSoftwareFrame() { |
3155 ui::Compositor* compositor = GetCompositor(); | 2842 ui::Compositor* compositor = GetCompositor(); |
3156 if (compositor) { | 2843 if (compositor) { |
3157 AddOnCommitCallbackAndDisableLocks(base::Bind( | 2844 AddOnCommitCallbackAndDisableLocks(base::Bind( |
3158 &RenderWidgetHostViewAura::SendReclaimSoftwareFrames, AsWeakPtr())); | 2845 &RenderWidgetHostViewAura::SendReclaimSoftwareFrames, AsWeakPtr())); |
3159 } | 2846 } |
3160 UpdateExternalTexture(); | 2847 window_->layer()->SetShowPaintedContent(); |
3161 } | 2848 } |
3162 | 2849 |
3163 //////////////////////////////////////////////////////////////////////////////// | 2850 //////////////////////////////////////////////////////////////////////////////// |
3164 // RenderWidgetHostViewAura, ui::CompositorObserver implementation: | 2851 // RenderWidgetHostViewAura, ui::CompositorObserver implementation: |
3165 | 2852 |
3166 void RenderWidgetHostViewAura::OnCompositingDidCommit( | 2853 void RenderWidgetHostViewAura::OnCompositingDidCommit( |
3167 ui::Compositor* compositor) { | 2854 ui::Compositor* compositor) { |
3168 if (can_lock_compositor_ == NO_PENDING_COMMIT) { | 2855 if (can_lock_compositor_ == NO_PENDING_COMMIT) { |
3169 can_lock_compositor_ = YES; | 2856 can_lock_compositor_ = YES; |
3170 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) | 2857 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) |
3171 can_lock_compositor_ = YES_DID_LOCK; | 2858 can_lock_compositor_ = YES_DID_LOCK; |
3172 } | 2859 } |
3173 RunOnCommitCallbacks(); | 2860 RunOnCommitCallbacks(); |
3174 if (resize_lock_ && resize_lock_->expected_size() == current_frame_size_) { | 2861 if (resize_lock_ && |
2862 resize_lock_->expected_size() == current_frame_size_in_dip_) { | |
3175 resize_lock_.reset(); | 2863 resize_lock_.reset(); |
3176 host_->WasResized(); | 2864 host_->WasResized(); |
3177 // We may have had a resize while we had the lock (e.g. if the lock expired, | 2865 // We may have had a resize while we had the lock (e.g. if the lock expired, |
3178 // or if the UI still gave us some resizes), so make sure we grab a new lock | 2866 // or if the UI still gave us some resizes), so make sure we grab a new lock |
3179 // if necessary. | 2867 // if necessary. |
3180 MaybeCreateResizeLock(); | 2868 MaybeCreateResizeLock(); |
3181 } | 2869 } |
3182 } | 2870 } |
3183 | 2871 |
3184 void RenderWidgetHostViewAura::OnCompositingStarted( | 2872 void RenderWidgetHostViewAura::OnCompositingStarted( |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3269 | 2957 |
3270 void RenderWidgetHostViewAura::FatalAccessibilityTreeError() { | 2958 void RenderWidgetHostViewAura::FatalAccessibilityTreeError() { |
3271 host_->FatalAccessibilityTreeError(); | 2959 host_->FatalAccessibilityTreeError(); |
3272 SetBrowserAccessibilityManager(NULL); | 2960 SetBrowserAccessibilityManager(NULL); |
3273 } | 2961 } |
3274 | 2962 |
3275 //////////////////////////////////////////////////////////////////////////////// | 2963 //////////////////////////////////////////////////////////////////////////////// |
3276 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: | 2964 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: |
3277 | 2965 |
3278 void RenderWidgetHostViewAura::OnLostResources() { | 2966 void RenderWidgetHostViewAura::OnLostResources() { |
3279 current_surface_ = NULL; | 2967 if (frame_provider_.get()) |
3280 UpdateExternalTexture(); | 2968 EvictDelegatedFrame(); |
3281 | |
3282 idle_frame_subscriber_textures_.clear(); | 2969 idle_frame_subscriber_textures_.clear(); |
3283 yuv_readback_pipeline_.reset(); | 2970 yuv_readback_pipeline_.reset(); |
3284 | 2971 |
3285 // Make sure all ImageTransportClients are deleted now that the context those | |
3286 // are using is becoming invalid. This sends pending ACKs and needs to happen | |
3287 // after calling UpdateExternalTexture() which syncs with the impl thread. | |
3288 RunOnCommitCallbacks(); | |
3289 host_->ScheduleComposite(); | 2972 host_->ScheduleComposite(); |
3290 } | 2973 } |
3291 | 2974 |
3292 //////////////////////////////////////////////////////////////////////////////// | 2975 //////////////////////////////////////////////////////////////////////////////// |
3293 // RenderWidgetHostViewAura, private: | 2976 // RenderWidgetHostViewAura, private: |
3294 | 2977 |
3295 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { | 2978 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { |
3296 if (touch_editing_client_) | 2979 if (touch_editing_client_) |
3297 touch_editing_client_->OnViewDestroyed(); | 2980 touch_editing_client_->OnViewDestroyed(); |
3298 | 2981 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3485 window_->GetDispatcher()->AddRootWindowObserver(this); | 3168 window_->GetDispatcher()->AddRootWindowObserver(this); |
3486 host_->ParentChanged(GetNativeViewId()); | 3169 host_->ParentChanged(GetNativeViewId()); |
3487 UpdateScreenInfo(window_); | 3170 UpdateScreenInfo(window_); |
3488 | 3171 |
3489 aura::client::CursorClient* cursor_client = | 3172 aura::client::CursorClient* cursor_client = |
3490 aura::client::GetCursorClient(window_->GetRootWindow()); | 3173 aura::client::GetCursorClient(window_->GetRootWindow()); |
3491 if (cursor_client) { | 3174 if (cursor_client) { |
3492 cursor_client->AddObserver(this); | 3175 cursor_client->AddObserver(this); |
3493 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 3176 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
3494 } | 3177 } |
3495 if (current_surface_.get()) | |
3496 UpdateExternalTexture(); | |
3497 if (HasFocus()) { | 3178 if (HasFocus()) { |
3498 ui::InputMethod* input_method = GetInputMethod(); | 3179 ui::InputMethod* input_method = GetInputMethod(); |
3499 if (input_method) | 3180 if (input_method) |
3500 input_method->SetFocusedTextInputClient(this); | 3181 input_method->SetFocusedTextInputClient(this); |
3501 } | 3182 } |
3502 } | 3183 } |
3503 | 3184 |
3504 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 3185 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
3505 aura::client::CursorClient* cursor_client = | 3186 aura::client::CursorClient* cursor_client = |
3506 aura::client::GetCursorClient(window_->GetRootWindow()); | 3187 aura::client::GetCursorClient(window_->GetRootWindow()); |
3507 if (cursor_client) | 3188 if (cursor_client) |
3508 cursor_client->RemoveObserver(this); | 3189 cursor_client->RemoveObserver(this); |
3509 | 3190 |
3510 DetachFromInputMethod(); | 3191 DetachFromInputMethod(); |
3511 | 3192 |
3512 window_->GetDispatcher()->RemoveRootWindowObserver(this); | 3193 window_->GetDispatcher()->RemoveRootWindowObserver(this); |
3513 host_->ParentChanged(0); | 3194 host_->ParentChanged(0); |
3514 ui::Compositor* compositor = GetCompositor(); | |
3515 if (current_surface_.get()) { | |
3516 // We can't get notification for commits after this point, which would | |
3517 // guarantee that the compositor isn't using an old texture any more, so | |
3518 // instead we force the layer to stop using any external resources which | |
3519 // synchronizes with the compositor thread, and makes it safe to run the | |
3520 // callback. | |
3521 window_->layer()->SetShowPaintedContent(); | |
3522 } | |
3523 RunOnCommitCallbacks(); | 3195 RunOnCommitCallbacks(); |
3524 resize_lock_.reset(); | 3196 resize_lock_.reset(); |
3525 host_->WasResized(); | 3197 host_->WasResized(); |
3198 ui::Compositor* compositor = GetCompositor(); | |
3526 if (compositor && compositor->HasObserver(this)) | 3199 if (compositor && compositor->HasObserver(this)) |
3527 compositor->RemoveObserver(this); | 3200 compositor->RemoveObserver(this); |
3528 } | 3201 } |
3529 | 3202 |
3530 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const { | 3203 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const { |
3531 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); | 3204 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); |
3532 return dispatcher ? dispatcher->host()->compositor() : NULL; | 3205 return dispatcher ? dispatcher->host()->compositor() : NULL; |
3533 } | 3206 } |
3534 | 3207 |
3535 void RenderWidgetHostViewAura::DetachFromInputMethod() { | 3208 void RenderWidgetHostViewAura::DetachFromInputMethod() { |
(...skipping 20 matching lines...) Expand all Loading... | |
3556 RenderWidgetHost* widget) { | 3229 RenderWidgetHost* widget) { |
3557 return new RenderWidgetHostViewAura(widget); | 3230 return new RenderWidgetHostViewAura(widget); |
3558 } | 3231 } |
3559 | 3232 |
3560 // static | 3233 // static |
3561 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3234 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
3562 GetScreenInfoForWindow(results, NULL); | 3235 GetScreenInfoForWindow(results, NULL); |
3563 } | 3236 } |
3564 | 3237 |
3565 } // namespace content | 3238 } // namespace content |
OLD | NEW |