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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 | 303 |
304 if (event.type() == ui::ET_GESTURE_BEGIN) { | 304 if (event.type() == ui::ET_GESTURE_BEGIN) { |
305 const ui::GestureEvent& gesture = | 305 const ui::GestureEvent& gesture = |
306 static_cast<const ui::GestureEvent&>(event); | 306 static_cast<const ui::GestureEvent&>(event); |
307 return gesture.details().touch_points() == 1; | 307 return gesture.details().touch_points() == 1; |
308 } | 308 } |
309 | 309 |
310 return false; | 310 return false; |
311 } | 311 } |
312 | 312 |
313 // Swap ack for the renderer when kCompositeToMailbox is enabled. | |
314 void SendCompositorFrameAck( | |
315 int32 route_id, | |
316 uint32 output_surface_id, | |
317 int renderer_host_id, | |
318 const gpu::Mailbox& received_mailbox, | |
319 const gfx::Size& received_size, | |
320 bool skip_frame, | |
321 const scoped_refptr<ui::Texture>& texture_to_produce) { | |
322 cc::CompositorFrameAck ack; | |
323 ack.gl_frame_data.reset(new cc::GLFrameData()); | |
324 DCHECK(!texture_to_produce.get() || !skip_frame); | |
325 if (texture_to_produce.get()) { | |
326 std::string mailbox_name = texture_to_produce->Produce(); | |
327 std::copy(mailbox_name.data(), | |
328 mailbox_name.data() + mailbox_name.length(), | |
329 reinterpret_cast<char*>(ack.gl_frame_data->mailbox.name)); | |
330 ack.gl_frame_data->size = texture_to_produce->size(); | |
331 ack.gl_frame_data->sync_point = | |
332 content::ImageTransportFactory::GetInstance()->InsertSyncPoint(); | |
333 } else if (skip_frame) { | |
334 // Skip the frame, i.e. tell the producer to reuse the same buffer that | |
335 // we just received. | |
336 ack.gl_frame_data->size = received_size; | |
337 ack.gl_frame_data->mailbox = received_mailbox; | |
338 } | |
339 | |
340 RenderWidgetHostImpl::SendSwapCompositorFrameAck( | |
341 route_id, output_surface_id, renderer_host_id, ack); | |
342 } | |
343 | |
344 void AcknowledgeBufferForGpu( | |
345 int32 route_id, | |
346 int gpu_host_id, | |
347 const std::string& received_mailbox, | |
348 bool skip_frame, | |
349 const scoped_refptr<ui::Texture>& texture_to_produce) { | |
350 AcceleratedSurfaceMsg_BufferPresented_Params ack; | |
351 uint32 sync_point = 0; | |
352 DCHECK(!texture_to_produce.get() || !skip_frame); | |
353 if (texture_to_produce.get()) { | |
354 ack.mailbox_name = texture_to_produce->Produce(); | |
355 sync_point = | |
356 content::ImageTransportFactory::GetInstance()->InsertSyncPoint(); | |
357 } else if (skip_frame) { | |
358 ack.mailbox_name = received_mailbox; | |
359 ack.sync_point = 0; | |
360 } | |
361 | |
362 ack.sync_point = sync_point; | |
363 RenderWidgetHostImpl::AcknowledgeBufferPresent( | |
364 route_id, gpu_host_id, ack); | |
365 } | |
366 | |
367 } // namespace | 313 } // namespace |
368 | 314 |
369 // We need to watch for mouse events outside a Web Popup or its parent | 315 // We need to watch for mouse events outside a Web Popup or its parent |
370 // and dismiss the popup for certain events. | 316 // and dismiss the popup for certain events. |
371 class RenderWidgetHostViewAura::EventFilterForPopupExit : | 317 class RenderWidgetHostViewAura::EventFilterForPopupExit : |
372 public ui::EventHandler { | 318 public ui::EventHandler { |
373 public: | 319 public: |
374 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) | 320 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) |
375 : rwhva_(rwhva) { | 321 : rwhva_(rwhva) { |
376 DCHECK(rwhva_); | 322 DCHECK(rwhva_); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 popup_child_host_view_(NULL), | 406 popup_child_host_view_(NULL), |
461 is_loading_(false), | 407 is_loading_(false), |
462 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 408 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
463 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 409 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
464 can_compose_inline_(true), | 410 can_compose_inline_(true), |
465 has_composition_text_(false), | 411 has_composition_text_(false), |
466 accept_return_character_(false), | 412 accept_return_character_(false), |
467 last_output_surface_id_(0), | 413 last_output_surface_id_(0), |
468 pending_delegated_ack_count_(0), | 414 pending_delegated_ack_count_(0), |
469 skipped_frames_(false), | 415 skipped_frames_(false), |
470 last_swapped_surface_scale_factor_(1.f), | 416 last_swapped_software_frame_scale_factor_(1.f), |
471 paint_canvas_(NULL), | 417 paint_canvas_(NULL), |
472 synthetic_move_sent_(false), | 418 synthetic_move_sent_(false), |
473 accelerated_compositing_state_changed_(false), | 419 accelerated_compositing_state_changed_(false), |
474 can_lock_compositor_(YES), | 420 can_lock_compositor_(YES), |
475 cursor_visibility_state_in_renderer_(UNKNOWN), | 421 cursor_visibility_state_in_renderer_(UNKNOWN), |
476 paint_observer_(NULL), | 422 paint_observer_(NULL), |
477 touch_editing_client_(NULL), | 423 touch_editing_client_(NULL), |
478 delegated_frame_evictor_(new DelegatedFrameEvictor(this)), | 424 delegated_frame_evictor_(new DelegatedFrameEvictor(this)), |
479 weak_ptr_factory_(this) { | 425 weak_ptr_factory_(this) { |
480 host_->SetView(this); | 426 host_->SetView(this); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 delegated_frame_evictor_->SetVisible(true); | 531 delegated_frame_evictor_->SetVisible(true); |
586 | 532 |
587 aura::Window* root = window_->GetRootWindow(); | 533 aura::Window* root = window_->GetRootWindow(); |
588 if (root) { | 534 if (root) { |
589 aura::client::CursorClient* cursor_client = | 535 aura::client::CursorClient* cursor_client = |
590 aura::client::GetCursorClient(root); | 536 aura::client::GetCursorClient(root); |
591 if (cursor_client) | 537 if (cursor_client) |
592 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 538 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
593 } | 539 } |
594 | 540 |
595 if (!current_surface_.get() && host_->is_accelerated_compositing_active() && | 541 if (host_->is_accelerated_compositing_active() && |
596 !released_front_lock_.get()) { | 542 !released_front_lock_.get()) { |
597 ui::Compositor* compositor = GetCompositor(); | 543 ui::Compositor* compositor = GetCompositor(); |
598 if (compositor) | 544 if (compositor) |
599 released_front_lock_ = compositor->GetCompositorLock(); | 545 released_front_lock_ = compositor->GetCompositorLock(); |
600 } | 546 } |
601 | 547 |
602 #if defined(OS_WIN) | 548 #if defined(OS_WIN) |
603 LPARAM lparam = reinterpret_cast<LPARAM>(this); | 549 LPARAM lparam = reinterpret_cast<LPARAM>(this); |
604 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); | 550 EnumChildWindows(ui::GetHiddenWindow(), ShowWindowsCallback, lparam); |
605 | 551 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
694 | 640 |
695 if (resize_lock_) | 641 if (resize_lock_) |
696 return false; | 642 return false; |
697 | 643 |
698 if (host_->should_auto_resize()) | 644 if (host_->should_auto_resize()) |
699 return false; | 645 return false; |
700 if (!host_->is_accelerated_compositing_active()) | 646 if (!host_->is_accelerated_compositing_active()) |
701 return false; | 647 return false; |
702 | 648 |
703 gfx::Size desired_size = window_->bounds().size(); | 649 gfx::Size desired_size = window_->bounds().size(); |
704 if (desired_size == current_frame_size_) | 650 if (desired_size == current_frame_size_in_dip_) |
705 return false; | 651 return false; |
706 | 652 |
707 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); | 653 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); |
708 if (!dispatcher) | 654 if (!dispatcher) |
709 return false; | 655 return false; |
710 | 656 |
711 ui::Compositor* compositor = dispatcher->host()->compositor(); | 657 ui::Compositor* compositor = dispatcher->host()->compositor(); |
712 if (!compositor) | 658 if (!compositor) |
713 return false; | 659 return false; |
714 | 660 |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1188 if (::IsWindow(plugin_parent_window_)) { | 1134 if (::IsWindow(plugin_parent_window_)) { |
1189 gfx::Rect window_bounds = window_->GetBoundsInRootWindow(); | 1135 gfx::Rect window_bounds = window_->GetBoundsInRootWindow(); |
1190 ::SetWindowPos(plugin_parent_window_, NULL, window_bounds.x(), | 1136 ::SetWindowPos(plugin_parent_window_, NULL, window_bounds.x(), |
1191 window_bounds.y(), window_bounds.width(), | 1137 window_bounds.y(), window_bounds.width(), |
1192 window_bounds.height(), 0); | 1138 window_bounds.height(), 0); |
1193 } | 1139 } |
1194 #endif | 1140 #endif |
1195 } | 1141 } |
1196 | 1142 |
1197 void RenderWidgetHostViewAura::CheckResizeLock() { | 1143 void RenderWidgetHostViewAura::CheckResizeLock() { |
1198 if (!resize_lock_ || resize_lock_->expected_size() != current_frame_size_) | 1144 if (!resize_lock_ || |
1145 resize_lock_->expected_size() != current_frame_size_in_dip_) | |
1199 return; | 1146 return; |
1200 | 1147 |
1201 // Since we got the size we were looking for, unlock the compositor. But delay | 1148 // Since we got the size we were looking for, unlock the compositor. But delay |
1202 // the release of the lock until we've kicked a frame with the new texture, to | 1149 // the release of the lock until we've kicked a frame with the new texture, to |
1203 // avoid resizing the UI before we have a chance to draw a "good" frame. | 1150 // avoid resizing the UI before we have a chance to draw a "good" frame. |
1204 resize_lock_->UnlockCompositor(); | 1151 resize_lock_->UnlockCompositor(); |
1205 ui::Compositor* compositor = GetCompositor(); | 1152 ui::Compositor* compositor = GetCompositor(); |
1206 if (compositor) { | 1153 if (compositor) { |
1207 if (!compositor->HasObserver(this)) | 1154 if (!compositor->HasObserver(this)) |
1208 compositor->AddObserver(this); | 1155 compositor->AddObserver(this); |
1209 } | 1156 } |
1210 } | 1157 } |
1211 | 1158 |
1212 void RenderWidgetHostViewAura::UpdateExternalTexture() { | 1159 void RenderWidgetHostViewAura::UpdateExternalTexture() { |
1213 // Delay processing accelerated compositing state change till here where we | 1160 // Delay processing accelerated compositing state change till here where we |
1214 // act upon the state change. (Clear the external texture if switching to | 1161 // act upon the state change. (Clear the external texture if switching to |
1215 // software mode or set the external texture if going to accelerated mode). | 1162 // software mode or set the external texture if going to accelerated mode). |
1216 if (accelerated_compositing_state_changed_) | 1163 if (accelerated_compositing_state_changed_) |
1217 accelerated_compositing_state_changed_ = false; | 1164 accelerated_compositing_state_changed_ = false; |
1218 | 1165 |
1219 bool is_compositing_active = host_->is_accelerated_compositing_active(); | 1166 bool is_compositing_active = host_->is_accelerated_compositing_active(); |
1220 if (is_compositing_active && current_surface_.get()) { | 1167 if (is_compositing_active && software_frame_manager_->HasCurrentFrame()) { |
1221 window_->layer()->SetExternalTexture(current_surface_.get()); | |
1222 current_frame_size_ = ConvertSizeToDIP( | |
1223 current_surface_->device_scale_factor(), current_surface_->size()); | |
1224 CheckResizeLock(); | |
1225 software_frame_manager_->DiscardCurrentFrame(); | |
1226 } else if (is_compositing_active && | |
1227 software_frame_manager_->HasCurrentFrame()) { | |
1228 cc::TextureMailbox mailbox; | 1168 cc::TextureMailbox mailbox; |
1229 scoped_ptr<cc::SingleReleaseCallback> callback; | 1169 scoped_ptr<cc::SingleReleaseCallback> callback; |
1230 software_frame_manager_->GetCurrentFrameMailbox(&mailbox, &callback); | 1170 software_frame_manager_->GetCurrentFrameMailbox(&mailbox, &callback); |
1231 window_->layer()->SetTextureMailbox(mailbox, | 1171 window_->layer()->SetTextureMailbox( |
1232 callback.Pass(), | 1172 mailbox, callback.Pass(), last_swapped_software_frame_scale_factor_); |
1233 last_swapped_surface_scale_factor_); | 1173 current_frame_size_in_dip_ = |
1234 current_frame_size_ = ConvertSizeToDIP(last_swapped_surface_scale_factor_, | 1174 ConvertSizeToDIP(last_swapped_software_frame_scale_factor_, |
1235 mailbox.shared_memory_size()); | 1175 mailbox.shared_memory_size()); |
1236 CheckResizeLock(); | 1176 CheckResizeLock(); |
1237 } else { | 1177 } else { |
1238 window_->layer()->SetShowPaintedContent(); | 1178 window_->layer()->SetShowPaintedContent(); |
1239 resize_lock_.reset(); | 1179 resize_lock_.reset(); |
1240 host_->WasResized(); | 1180 host_->WasResized(); |
1241 software_frame_manager_->DiscardCurrentFrame(); | 1181 software_frame_manager_->DiscardCurrentFrame(); |
1242 } | 1182 } |
1243 } | 1183 } |
1244 | 1184 |
1245 bool RenderWidgetHostViewAura::SwapBuffersPrepare( | |
1246 const gfx::Rect& surface_rect, | |
1247 float surface_scale_factor, | |
1248 const gfx::Rect& damage_rect, | |
1249 const std::string& mailbox_name, | |
1250 const BufferPresentedCallback& ack_callback) { | |
1251 if (last_swapped_surface_size_ != surface_rect.size()) { | |
1252 // The surface could have shrunk since we skipped an update, in which | |
1253 // case we can expect a full update. | |
1254 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; | |
1255 skipped_damage_.setEmpty(); | |
1256 last_swapped_surface_size_ = surface_rect.size(); | |
1257 last_swapped_surface_scale_factor_ = surface_scale_factor; | |
1258 } | |
1259 | |
1260 if (ShouldSkipFrame(ConvertSizeToDIP(surface_scale_factor, | |
1261 surface_rect.size())) || | |
1262 mailbox_name.empty()) { | |
1263 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); | |
1264 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | |
1265 return false; | |
1266 } | |
1267 | |
1268 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | |
1269 current_surface_ = | |
1270 factory->CreateTransportClient(surface_scale_factor); | |
1271 if (!current_surface_.get()) { | |
1272 LOG(ERROR) << "Failed to create ImageTransport texture"; | |
1273 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | |
1274 return false; | |
1275 } | |
1276 | |
1277 current_surface_->Consume(mailbox_name, surface_rect.size()); | |
1278 released_front_lock_ = NULL; | |
1279 UpdateExternalTexture(); | |
1280 | |
1281 return true; | |
1282 } | |
1283 | |
1284 void RenderWidgetHostViewAura::SwapBuffersCompleted( | |
1285 const BufferPresentedCallback& ack_callback, | |
1286 const scoped_refptr<ui::Texture>& texture_to_return) { | |
1287 ui::Compositor* compositor = GetCompositor(); | |
1288 if (!compositor) { | |
1289 ack_callback.Run(false, texture_to_return); | |
1290 } else { | |
1291 AddOnCommitCallbackAndDisableLocks( | |
1292 base::Bind(ack_callback, false, texture_to_return)); | |
1293 } | |
1294 | |
1295 DidReceiveFrameFromRenderer(); | |
1296 } | |
1297 | |
1298 void RenderWidgetHostViewAura::DidReceiveFrameFromRenderer() { | 1185 void RenderWidgetHostViewAura::DidReceiveFrameFromRenderer() { |
1299 if (frame_subscriber() && CanCopyToVideoFrame()) { | 1186 if (frame_subscriber() && CanCopyToVideoFrame()) { |
1300 const base::TimeTicks present_time = base::TimeTicks::Now(); | 1187 const base::TimeTicks present_time = base::TimeTicks::Now(); |
1301 scoped_refptr<media::VideoFrame> frame; | 1188 scoped_refptr<media::VideoFrame> frame; |
1302 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; | 1189 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; |
1303 if (frame_subscriber()->ShouldCaptureFrame(present_time, | 1190 if (frame_subscriber()->ShouldCaptureFrame(present_time, |
1304 &frame, &callback)) { | 1191 &frame, &callback)) { |
1305 CopyFromCompositingSurfaceToVideoFrame( | 1192 CopyFromCompositingSurfaceToVideoFrame( |
1306 gfx::Rect(current_frame_size_), | 1193 gfx::Rect(current_frame_size_in_dip_), |
1307 frame, | 1194 frame, |
1308 base::Bind(callback, present_time)); | 1195 base::Bind(callback, present_time)); |
1309 } | 1196 } |
1310 } | 1197 } |
1311 } | 1198 } |
1312 | 1199 |
1313 #if defined(OS_WIN) | 1200 #if defined(OS_WIN) |
1314 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects( | 1201 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects( |
1315 const std::vector<gfx::Rect>& rects) { | 1202 const std::vector<gfx::Rect>& rects) { |
1316 if (rects == constrained_rects_) | 1203 if (rects == constrained_rects_) |
(...skipping 11 matching lines...) Expand all Loading... | |
1328 params.cutout_rects = constrained_rects_; | 1215 params.cutout_rects = constrained_rects_; |
1329 params.geometry = &plugin_window_moves_; | 1216 params.geometry = &plugin_window_moves_; |
1330 LPARAM lparam = reinterpret_cast<LPARAM>(¶ms); | 1217 LPARAM lparam = reinterpret_cast<LPARAM>(¶ms); |
1331 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); | 1218 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); |
1332 } | 1219 } |
1333 #endif | 1220 #endif |
1334 | 1221 |
1335 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | 1222 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
1336 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, | 1223 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, |
1337 int gpu_host_id) { | 1224 int gpu_host_id) { |
1338 BufferPresentedCallback ack_callback = base::Bind( | 1225 NOTREACHED(); |
piman
2014/01/09 23:24:19
nit: Technically, a malicious renderer could swap
| |
1339 &AcknowledgeBufferForGpu, | |
1340 params_in_pixel.route_id, | |
1341 gpu_host_id, | |
1342 params_in_pixel.mailbox_name); | |
1343 // TODO(miletus) : Pass the params_in_pixel.latency_info directly into | |
1344 // BuffersSwapped() once GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params | |
1345 // is converted to contain std::vector<ui::LatencyInfo>. | |
1346 std::vector<ui::LatencyInfo> latency_info; | |
1347 latency_info.push_back(params_in_pixel.latency_info); | |
1348 BuffersSwapped(params_in_pixel.size, | |
1349 gfx::Rect(params_in_pixel.size), | |
1350 params_in_pixel.scale_factor, | |
1351 params_in_pixel.mailbox_name, | |
1352 latency_info, | |
1353 ack_callback); | |
1354 } | 1226 } |
1355 | 1227 |
1356 void RenderWidgetHostViewAura::SwapDelegatedFrame( | 1228 void RenderWidgetHostViewAura::SwapDelegatedFrame( |
1357 uint32 output_surface_id, | 1229 uint32 output_surface_id, |
1358 scoped_ptr<cc::DelegatedFrameData> frame_data, | 1230 scoped_ptr<cc::DelegatedFrameData> frame_data, |
1359 float frame_device_scale_factor, | 1231 float frame_device_scale_factor, |
1360 const std::vector<ui::LatencyInfo>& latency_info) { | 1232 const std::vector<ui::LatencyInfo>& latency_info) { |
1361 DCHECK_NE(0u, frame_data->render_pass_list.size()); | 1233 DCHECK_NE(0u, frame_data->render_pass_list.size()); |
1362 | 1234 |
1363 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); | 1235 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1423 if (!resource_collection_) { | 1295 if (!resource_collection_) { |
1424 resource_collection_ = new cc::DelegatedFrameResourceCollection; | 1296 resource_collection_ = new cc::DelegatedFrameResourceCollection; |
1425 resource_collection_->SetClient(this); | 1297 resource_collection_->SetClient(this); |
1426 } | 1298 } |
1427 // If the physical frame size changes, we need a new |frame_provider_|. If | 1299 // If the physical frame size changes, we need a new |frame_provider_|. If |
1428 // the physical frame size is the same, but the size in DIP changed, we | 1300 // the physical frame size is the same, but the size in DIP changed, we |
1429 // need to adjust the scale at which the frames will be drawn, and we do | 1301 // need to adjust the scale at which the frames will be drawn, and we do |
1430 // this by making a new |frame_provider_| also to ensure the scale change | 1302 // this by making a new |frame_provider_| also to ensure the scale change |
1431 // is presented in sync with the new frame content. | 1303 // is presented in sync with the new frame content. |
1432 if (!frame_provider_.get() || frame_size != frame_provider_->frame_size() || | 1304 if (!frame_provider_.get() || frame_size != frame_provider_->frame_size() || |
1433 frame_size_in_dip != current_frame_size_) { | 1305 frame_size_in_dip != current_frame_size_in_dip_) { |
1434 frame_provider_ = new cc::DelegatedFrameProvider( | 1306 frame_provider_ = new cc::DelegatedFrameProvider( |
1435 resource_collection_.get(), frame_data.Pass()); | 1307 resource_collection_.get(), frame_data.Pass()); |
1436 window_->layer()->SetShowDelegatedContent(frame_provider_.get(), | 1308 window_->layer()->SetShowDelegatedContent(frame_provider_.get(), |
1437 frame_size_in_dip); | 1309 frame_size_in_dip); |
1438 } else { | 1310 } else { |
1439 frame_provider_->SetFrameData(frame_data.Pass()); | 1311 frame_provider_->SetFrameData(frame_data.Pass()); |
1440 } | 1312 } |
1441 } | 1313 } |
1442 released_front_lock_ = NULL; | 1314 released_front_lock_ = NULL; |
1443 current_frame_size_ = frame_size_in_dip; | 1315 current_frame_size_in_dip_ = frame_size_in_dip; |
1444 CheckResizeLock(); | 1316 CheckResizeLock(); |
1445 | 1317 |
1446 if (paint_observer_) | 1318 if (paint_observer_) |
1447 paint_observer_->OnUpdateCompositorContent(); | 1319 paint_observer_->OnUpdateCompositorContent(); |
1448 window_->SchedulePaintInRect(damage_rect_in_dip); | 1320 window_->SchedulePaintInRect(damage_rect_in_dip); |
1449 | 1321 |
1450 pending_delegated_ack_count_++; | 1322 pending_delegated_ack_count_++; |
1451 | 1323 |
1452 ui::Compositor* compositor = GetCompositor(); | 1324 ui::Compositor* compositor = GetCompositor(); |
1453 if (!compositor) { | 1325 if (!compositor) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1522 if (!software_frame_manager_->SwapToNewFrame( | 1394 if (!software_frame_manager_->SwapToNewFrame( |
1523 output_surface_id, | 1395 output_surface_id, |
1524 frame_data.get(), | 1396 frame_data.get(), |
1525 frame_device_scale_factor, | 1397 frame_device_scale_factor, |
1526 host_->GetProcess()->GetHandle())) { | 1398 host_->GetProcess()->GetHandle())) { |
1527 ReleaseSoftwareFrame(output_surface_id, frame_data->id); | 1399 ReleaseSoftwareFrame(output_surface_id, frame_data->id); |
1528 SendSoftwareFrameAck(output_surface_id); | 1400 SendSoftwareFrameAck(output_surface_id); |
1529 return; | 1401 return; |
1530 } | 1402 } |
1531 | 1403 |
1532 if (last_swapped_surface_size_ != frame_size) { | 1404 if (last_swapped_software_frame_size_ != frame_size) { |
1533 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size)) | 1405 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size)) |
1534 << "Expected full damage rect"; | 1406 << "Expected full damage rect"; |
1535 } | 1407 } |
1536 last_swapped_surface_size_ = frame_size; | 1408 last_swapped_software_frame_size_ = frame_size; |
1537 last_swapped_surface_scale_factor_ = frame_device_scale_factor; | 1409 last_swapped_software_frame_scale_factor_ = frame_device_scale_factor; |
1538 | 1410 |
1539 cc::TextureMailbox mailbox; | 1411 cc::TextureMailbox mailbox; |
1540 scoped_ptr<cc::SingleReleaseCallback> callback; | 1412 scoped_ptr<cc::SingleReleaseCallback> callback; |
1541 software_frame_manager_->GetCurrentFrameMailbox(&mailbox, &callback); | 1413 software_frame_manager_->GetCurrentFrameMailbox(&mailbox, &callback); |
1542 DCHECK(mailbox.IsSharedMemory()); | 1414 DCHECK(mailbox.IsSharedMemory()); |
1543 current_frame_size_ = frame_size_in_dip; | 1415 current_frame_size_in_dip_ = frame_size_in_dip; |
1544 | 1416 |
1545 released_front_lock_ = NULL; | 1417 released_front_lock_ = NULL; |
1546 CheckResizeLock(); | 1418 CheckResizeLock(); |
1547 window_->layer()->SetTextureMailbox(mailbox, | 1419 window_->layer()->SetTextureMailbox(mailbox, |
1548 callback.Pass(), | 1420 callback.Pass(), |
1549 frame_device_scale_factor); | 1421 frame_device_scale_factor); |
1550 window_->SchedulePaintInRect( | 1422 window_->SchedulePaintInRect( |
1551 ConvertRectToDIP(frame_device_scale_factor, damage_rect)); | 1423 ConvertRectToDIP(frame_device_scale_factor, damage_rect)); |
1552 | 1424 |
1553 ui::Compositor* compositor = GetCompositor(); | 1425 ui::Compositor* compositor = GetCompositor(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1609 scoped_ptr<cc::CompositorFrame> frame) { | 1481 scoped_ptr<cc::CompositorFrame> frame) { |
1610 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); | 1482 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); |
1611 if (frame->delegated_frame_data) { | 1483 if (frame->delegated_frame_data) { |
1612 SwapDelegatedFrame(output_surface_id, | 1484 SwapDelegatedFrame(output_surface_id, |
1613 frame->delegated_frame_data.Pass(), | 1485 frame->delegated_frame_data.Pass(), |
1614 frame->metadata.device_scale_factor, | 1486 frame->metadata.device_scale_factor, |
1615 frame->metadata.latency_info); | 1487 frame->metadata.latency_info); |
1616 return; | 1488 return; |
1617 } | 1489 } |
1618 | 1490 |
1619 if (frame->software_frame_data) { | 1491 DCHECK(frame->software_frame_data); |
piman
2014/01/09 23:24:19
Not DCHECK since a malicious renderer can still se
| |
1620 SwapSoftwareFrame(output_surface_id, | 1492 SwapSoftwareFrame(output_surface_id, |
1621 frame->software_frame_data.Pass(), | 1493 frame->software_frame_data.Pass(), |
1622 frame->metadata.device_scale_factor, | 1494 frame->metadata.device_scale_factor, |
1623 frame->metadata.latency_info); | 1495 frame->metadata.latency_info); |
1624 return; | |
1625 } | |
1626 | |
1627 if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero()) | |
1628 return; | |
1629 | |
1630 BufferPresentedCallback ack_callback = base::Bind( | |
1631 &SendCompositorFrameAck, | |
1632 host_->GetRoutingID(), output_surface_id, host_->GetProcess()->GetID(), | |
1633 frame->gl_frame_data->mailbox, frame->gl_frame_data->size); | |
1634 | |
1635 if (!frame->gl_frame_data->sync_point) { | |
1636 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; | |
1637 ack_callback.Run(true, scoped_refptr<ui::Texture>()); | |
1638 return; | |
1639 } | |
1640 | |
1641 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | |
1642 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); | |
1643 | |
1644 std::string mailbox_name( | |
1645 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), | |
1646 sizeof(frame->gl_frame_data->mailbox.name)); | |
1647 BuffersSwapped(frame->gl_frame_data->size, | |
1648 frame->gl_frame_data->sub_buffer_rect, | |
1649 frame->metadata.device_scale_factor, | |
1650 mailbox_name, | |
1651 frame->metadata.latency_info, | |
1652 ack_callback); | |
1653 } | 1496 } |
1654 | 1497 |
1655 #if defined(OS_WIN) | 1498 #if defined(OS_WIN) |
1656 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( | 1499 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( |
1657 gfx::NativeViewAccessible accessible_parent) { | 1500 gfx::NativeViewAccessible accessible_parent) { |
1658 if (GetBrowserAccessibilityManager()) { | 1501 if (GetBrowserAccessibilityManager()) { |
1659 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() | 1502 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() |
1660 ->set_parent_iaccessible(accessible_parent); | 1503 ->set_parent_iaccessible(accessible_parent); |
1661 } | 1504 } |
1662 } | 1505 } |
1663 | 1506 |
1664 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() | 1507 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() |
1665 const { | 1508 const { |
1666 return reinterpret_cast<gfx::NativeViewId>(plugin_parent_window_); | 1509 return reinterpret_cast<gfx::NativeViewId>(plugin_parent_window_); |
1667 } | 1510 } |
1668 #endif | 1511 #endif |
1669 | 1512 |
1670 void RenderWidgetHostViewAura::BuffersSwapped( | |
1671 const gfx::Size& surface_size, | |
1672 const gfx::Rect& damage_rect, | |
1673 float surface_scale_factor, | |
1674 const std::string& mailbox_name, | |
1675 const std::vector<ui::LatencyInfo>& latency_info, | |
1676 const BufferPresentedCallback& ack_callback) { | |
1677 scoped_refptr<ui::Texture> previous_texture(current_surface_); | |
1678 const gfx::Rect surface_rect = gfx::Rect(surface_size); | |
1679 software_frame_manager_->DiscardCurrentFrame(); | |
1680 | |
1681 if (!SwapBuffersPrepare(surface_rect, | |
1682 surface_scale_factor, | |
1683 damage_rect, | |
1684 mailbox_name, | |
1685 ack_callback)) { | |
1686 return; | |
1687 } | |
1688 | |
1689 SkRegion damage(RectToSkIRect(damage_rect)); | |
1690 if (!skipped_damage_.isEmpty()) { | |
1691 damage.op(skipped_damage_, SkRegion::kUnion_Op); | |
1692 skipped_damage_.setEmpty(); | |
1693 } | |
1694 | |
1695 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds()))); | |
1696 ui::Texture* current_texture = current_surface_.get(); | |
1697 | |
1698 const gfx::Size surface_size_in_pixel = surface_size; | |
1699 DLOG_IF(ERROR, previous_texture.get() && | |
1700 previous_texture->size() != current_texture->size() && | |
1701 SkIRectToRect(damage.getBounds()) != surface_rect) << | |
1702 "Expected full damage rect after size change"; | |
1703 if (previous_texture.get() && !previous_damage_.isEmpty() && | |
1704 previous_texture->size() == current_texture->size()) { | |
1705 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | |
1706 GLHelper* gl_helper = factory->GetGLHelper(); | |
1707 gl_helper->CopySubBufferDamage( | |
1708 current_texture->PrepareTexture(), | |
1709 previous_texture->PrepareTexture(), | |
1710 damage, | |
1711 previous_damage_); | |
1712 } | |
1713 previous_damage_ = damage; | |
1714 | |
1715 ui::Compositor* compositor = GetCompositor(); | |
1716 if (compositor) { | |
1717 // Co-ordinates come in OpenGL co-ordinate space. | |
1718 // We need to convert to layer space. | |
1719 gfx::Rect rect_to_paint = | |
1720 ConvertRectToDIP(surface_scale_factor, | |
1721 gfx::Rect(damage_rect.x(), | |
1722 surface_size_in_pixel.height() - | |
1723 damage_rect.y() - damage_rect.height(), | |
1724 damage_rect.width(), | |
1725 damage_rect.height())); | |
1726 | |
1727 // Damage may not have been DIP aligned, so inflate damage to compensate | |
1728 // for any round-off error. | |
1729 rect_to_paint.Inset(-1, -1); | |
1730 rect_to_paint.Intersect(window_->bounds()); | |
1731 | |
1732 if (paint_observer_) | |
1733 paint_observer_->OnUpdateCompositorContent(); | |
1734 window_->SchedulePaintInRect(rect_to_paint); | |
1735 for (size_t i = 0; i < latency_info.size(); i++) | |
1736 compositor->SetLatencyInfo(latency_info[i]); | |
1737 } | |
1738 | |
1739 SwapBuffersCompleted(ack_callback, previous_texture); | |
1740 } | |
1741 | |
1742 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | 1513 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
1743 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | 1514 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
1744 int gpu_host_id) { | 1515 int gpu_host_id) { |
1745 gfx::Rect damage_rect(params_in_pixel.x, | 1516 NOTREACHED(); |
piman
2014/01/09 23:24:19
nit: could be reached too.
| |
1746 params_in_pixel.y, | |
1747 params_in_pixel.width, | |
1748 params_in_pixel.height); | |
1749 BufferPresentedCallback ack_callback = | |
1750 base::Bind(&AcknowledgeBufferForGpu, | |
1751 params_in_pixel.route_id, | |
1752 gpu_host_id, | |
1753 params_in_pixel.mailbox_name); | |
1754 // TODO(miletus) : Pass the params_in_pixel.latency_info directly into | |
1755 // BuffersSwapped() once GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params | |
1756 // is converted to contain std::vector<ui::LatencyInfo>. | |
1757 std::vector<ui::LatencyInfo> latency_info; | |
1758 latency_info.push_back(params_in_pixel.latency_info); | |
1759 BuffersSwapped(params_in_pixel.surface_size, | |
1760 damage_rect, | |
1761 params_in_pixel.surface_scale_factor, | |
1762 params_in_pixel.mailbox_name, | |
1763 latency_info, | |
1764 ack_callback); | |
1765 } | 1517 } |
1766 | 1518 |
1767 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { | 1519 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { |
1768 } | 1520 } |
1769 | 1521 |
1770 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { | 1522 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { |
1771 // This really tells us to release the frontbuffer. | |
1772 if (current_surface_.get()) { | |
1773 ui::Compositor* compositor = GetCompositor(); | |
1774 if (compositor) { | |
1775 // We need to wait for a commit to clear to guarantee that all we | |
1776 // will not issue any more GL referencing the previous surface. | |
1777 AddOnCommitCallbackAndDisableLocks( | |
1778 base::Bind(&RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor, | |
1779 AsWeakPtr(), | |
1780 current_surface_)); // Hold a ref so the texture will not | |
1781 // get deleted until after commit. | |
1782 } | |
1783 current_surface_ = NULL; | |
1784 UpdateExternalTexture(); | |
1785 } | |
1786 } | 1523 } |
1787 | 1524 |
1788 bool RenderWidgetHostViewAura::HasAcceleratedSurface( | 1525 bool RenderWidgetHostViewAura::HasAcceleratedSurface( |
1789 const gfx::Size& desired_size) { | 1526 const gfx::Size& desired_size) { |
1790 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't | 1527 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't |
1791 // matter what is returned here as GetBackingStore is the only caller of this | 1528 // matter what is returned here as GetBackingStore is the only caller of this |
1792 // method. TODO(jbates) implement this if other Aura code needs it. | 1529 // method. TODO(jbates) implement this if other Aura code needs it. |
1793 return false; | 1530 return false; |
1794 } | 1531 } |
1795 | 1532 |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2616 } | 2353 } |
2617 | 2354 |
2618 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { | 2355 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { |
2619 } | 2356 } |
2620 | 2357 |
2621 void RenderWidgetHostViewAura::DidRecreateLayer(ui::Layer *old_layer, | 2358 void RenderWidgetHostViewAura::DidRecreateLayer(ui::Layer *old_layer, |
2622 ui::Layer *new_layer) { | 2359 ui::Layer *new_layer) { |
2623 float mailbox_scale_factor; | 2360 float mailbox_scale_factor; |
2624 cc::TextureMailbox old_mailbox = | 2361 cc::TextureMailbox old_mailbox = |
2625 old_layer->GetTextureMailbox(&mailbox_scale_factor); | 2362 old_layer->GetTextureMailbox(&mailbox_scale_factor); |
2626 scoped_refptr<ui::Texture> old_texture = old_layer->external_texture(); | |
2627 // The new_layer is the one that will be used by our Window, so that's the one | 2363 // The new_layer is the one that will be used by our Window, so that's the one |
2628 // that should keep our texture. old_layer will be returned to the | 2364 // that should keep our texture. old_layer will be returned to the |
2629 // RecreateLayer caller, and should have a copy. | 2365 // RecreateLayer caller, and should have a copy. |
2630 if (old_texture.get()) { | 2366 if (old_mailbox.IsValid()) { |
2631 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 2367 DCHECK(old_mailbox.IsSharedMemory()); |
piman
2014/01/10 01:45:09
nit: I think that code was still fine, since this
danakj
2014/01/10 17:51:42
You mean the if (IsSharedMemory)? I was thinking t
| |
2632 GLHelper* gl_helper = factory->GetGLHelper(); | |
2633 scoped_refptr<ui::Texture> new_texture; | |
2634 if (host_->is_accelerated_compositing_active() && | |
2635 gl_helper && current_surface_.get()) { | |
2636 GLuint texture_id = | |
2637 gl_helper->CopyTexture(current_surface_->PrepareTexture(), | |
2638 current_surface_->size()); | |
2639 if (texture_id) { | |
2640 new_texture = factory->CreateOwnedTexture( | |
2641 current_surface_->size(), | |
2642 current_surface_->device_scale_factor(), texture_id); | |
2643 } | |
2644 } | |
2645 if (new_texture.get()) | |
2646 old_layer->SetExternalTexture(new_texture.get()); | |
2647 else | |
2648 old_layer->SetShowPaintedContent(); | |
2649 new_layer->SetExternalTexture(old_texture.get()); | |
2650 } else if (old_mailbox.IsSharedMemory()) { | |
2651 base::SharedMemory* old_buffer = old_mailbox.shared_memory(); | 2368 base::SharedMemory* old_buffer = old_mailbox.shared_memory(); |
2652 const size_t size = old_mailbox.shared_memory_size_in_bytes(); | 2369 const size_t size = old_mailbox.shared_memory_size_in_bytes(); |
2653 | 2370 |
2654 scoped_ptr<base::SharedMemory> new_buffer(new base::SharedMemory); | 2371 scoped_ptr<base::SharedMemory> new_buffer(new base::SharedMemory); |
2655 new_buffer->CreateAndMapAnonymous(size); | 2372 new_buffer->CreateAndMapAnonymous(size); |
2656 | 2373 |
2657 if (old_buffer->memory() && new_buffer->memory()) { | 2374 if (old_buffer->memory() && new_buffer->memory()) { |
2658 memcpy(new_buffer->memory(), old_buffer->memory(), size); | 2375 memcpy(new_buffer->memory(), old_buffer->memory(), size); |
2659 base::SharedMemory* new_buffer_raw_ptr = new_buffer.get(); | 2376 base::SharedMemory* new_buffer_raw_ptr = new_buffer.get(); |
2660 scoped_ptr<cc::SingleReleaseCallback> callback = | 2377 scoped_ptr<cc::SingleReleaseCallback> callback = |
2661 cc::SingleReleaseCallback::Create(base::Bind(MailboxReleaseCallback, | 2378 cc::SingleReleaseCallback::Create(base::Bind(MailboxReleaseCallback, |
2662 Passed(&new_buffer))); | 2379 Passed(&new_buffer))); |
2663 cc::TextureMailbox new_mailbox(new_buffer_raw_ptr, | 2380 cc::TextureMailbox new_mailbox(new_buffer_raw_ptr, |
2664 old_mailbox.shared_memory_size()); | 2381 old_mailbox.shared_memory_size()); |
2665 new_layer->SetTextureMailbox(new_mailbox, | 2382 new_layer->SetTextureMailbox(new_mailbox, |
2666 callback.Pass(), | 2383 callback.Pass(), |
2667 mailbox_scale_factor); | 2384 mailbox_scale_factor); |
2668 } | 2385 } |
2669 } else if (frame_provider_.get()) { | 2386 } else if (frame_provider_.get()) { |
2670 new_layer->SetShowDelegatedContent(frame_provider_.get(), | 2387 new_layer->SetShowDelegatedContent(frame_provider_.get(), |
2671 current_frame_size_); | 2388 current_frame_size_in_dip_); |
2672 } | 2389 } |
2673 } | 2390 } |
2674 | 2391 |
2675 //////////////////////////////////////////////////////////////////////////////// | 2392 //////////////////////////////////////////////////////////////////////////////// |
2676 // RenderWidgetHostViewAura, ui::EventHandler implementation: | 2393 // RenderWidgetHostViewAura, ui::EventHandler implementation: |
2677 | 2394 |
2678 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { | 2395 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { |
2679 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); | 2396 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); |
2680 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | 2397 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) |
2681 return; | 2398 return; |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3106 // RenderWidgetHostViewAura, ui::CompositorObserver implementation: | 2823 // RenderWidgetHostViewAura, ui::CompositorObserver implementation: |
3107 | 2824 |
3108 void RenderWidgetHostViewAura::OnCompositingDidCommit( | 2825 void RenderWidgetHostViewAura::OnCompositingDidCommit( |
3109 ui::Compositor* compositor) { | 2826 ui::Compositor* compositor) { |
3110 if (can_lock_compositor_ == NO_PENDING_COMMIT) { | 2827 if (can_lock_compositor_ == NO_PENDING_COMMIT) { |
3111 can_lock_compositor_ = YES; | 2828 can_lock_compositor_ = YES; |
3112 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) | 2829 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) |
3113 can_lock_compositor_ = YES_DID_LOCK; | 2830 can_lock_compositor_ = YES_DID_LOCK; |
3114 } | 2831 } |
3115 RunOnCommitCallbacks(); | 2832 RunOnCommitCallbacks(); |
3116 if (resize_lock_ && resize_lock_->expected_size() == current_frame_size_) { | 2833 if (resize_lock_ && |
2834 resize_lock_->expected_size() == current_frame_size_in_dip_) { | |
3117 resize_lock_.reset(); | 2835 resize_lock_.reset(); |
3118 host_->WasResized(); | 2836 host_->WasResized(); |
3119 // We may have had a resize while we had the lock (e.g. if the lock expired, | 2837 // We may have had a resize while we had the lock (e.g. if the lock expired, |
3120 // or if the UI still gave us some resizes), so make sure we grab a new lock | 2838 // or if the UI still gave us some resizes), so make sure we grab a new lock |
3121 // if necessary. | 2839 // if necessary. |
3122 MaybeCreateResizeLock(); | 2840 MaybeCreateResizeLock(); |
3123 } | 2841 } |
3124 } | 2842 } |
3125 | 2843 |
3126 void RenderWidgetHostViewAura::OnCompositingStarted( | 2844 void RenderWidgetHostViewAura::OnCompositingStarted( |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3213 | 2931 |
3214 void RenderWidgetHostViewAura::FatalAccessibilityTreeError() { | 2932 void RenderWidgetHostViewAura::FatalAccessibilityTreeError() { |
3215 host_->FatalAccessibilityTreeError(); | 2933 host_->FatalAccessibilityTreeError(); |
3216 SetBrowserAccessibilityManager(NULL); | 2934 SetBrowserAccessibilityManager(NULL); |
3217 } | 2935 } |
3218 | 2936 |
3219 //////////////////////////////////////////////////////////////////////////////// | 2937 //////////////////////////////////////////////////////////////////////////////// |
3220 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: | 2938 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: |
3221 | 2939 |
3222 void RenderWidgetHostViewAura::OnLostResources() { | 2940 void RenderWidgetHostViewAura::OnLostResources() { |
3223 current_surface_ = NULL; | |
3224 UpdateExternalTexture(); | 2941 UpdateExternalTexture(); |
3225 | 2942 |
3226 idle_frame_subscriber_textures_.clear(); | 2943 idle_frame_subscriber_textures_.clear(); |
3227 | 2944 |
3228 // Make sure all ImageTransportClients are deleted now that the context those | 2945 // Make sure all ImageTransportClients are deleted now that the context those |
3229 // are using is becoming invalid. This sends pending ACKs and needs to happen | 2946 // are using is becoming invalid. This sends pending ACKs and needs to happen |
3230 // after calling UpdateExternalTexture() which syncs with the impl thread. | 2947 // after calling UpdateExternalTexture() which syncs with the impl thread. |
3231 RunOnCommitCallbacks(); | 2948 RunOnCommitCallbacks(); |
3232 | 2949 |
3233 DCHECK(!shared_surface_handle_.is_null()); | 2950 DCHECK(!shared_surface_handle_.is_null()); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3429 UpdateScreenInfo(window_); | 3146 UpdateScreenInfo(window_); |
3430 if (popup_type_ != blink::WebPopupTypeNone) | 3147 if (popup_type_ != blink::WebPopupTypeNone) |
3431 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); | 3148 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); |
3432 | 3149 |
3433 aura::client::CursorClient* cursor_client = | 3150 aura::client::CursorClient* cursor_client = |
3434 aura::client::GetCursorClient(window_->GetRootWindow()); | 3151 aura::client::GetCursorClient(window_->GetRootWindow()); |
3435 if (cursor_client) { | 3152 if (cursor_client) { |
3436 cursor_client->AddObserver(this); | 3153 cursor_client->AddObserver(this); |
3437 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 3154 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
3438 } | 3155 } |
3439 if (current_surface_.get()) | |
3440 UpdateExternalTexture(); | |
3441 if (HasFocus()) { | 3156 if (HasFocus()) { |
3442 ui::InputMethod* input_method = GetInputMethod(); | 3157 ui::InputMethod* input_method = GetInputMethod(); |
3443 if (input_method) | 3158 if (input_method) |
3444 input_method->SetFocusedTextInputClient(this); | 3159 input_method->SetFocusedTextInputClient(this); |
3445 } | 3160 } |
3446 } | 3161 } |
3447 | 3162 |
3448 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 3163 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
3449 aura::client::CursorClient* cursor_client = | 3164 aura::client::CursorClient* cursor_client = |
3450 aura::client::GetCursorClient(window_->GetRootWindow()); | 3165 aura::client::GetCursorClient(window_->GetRootWindow()); |
3451 if (cursor_client) | 3166 if (cursor_client) |
3452 cursor_client->RemoveObserver(this); | 3167 cursor_client->RemoveObserver(this); |
3453 | 3168 |
3454 DetachFromInputMethod(); | 3169 DetachFromInputMethod(); |
3455 | 3170 |
3456 event_filter_for_popup_exit_.reset(); | 3171 event_filter_for_popup_exit_.reset(); |
3457 window_->GetDispatcher()->RemoveRootWindowObserver(this); | 3172 window_->GetDispatcher()->RemoveRootWindowObserver(this); |
3458 host_->ParentChanged(0); | 3173 host_->ParentChanged(0); |
3459 ui::Compositor* compositor = GetCompositor(); | |
3460 if (current_surface_.get()) { | |
3461 // We can't get notification for commits after this point, which would | |
3462 // guarantee that the compositor isn't using an old texture any more, so | |
3463 // instead we force the layer to stop using any external resources which | |
3464 // synchronizes with the compositor thread, and makes it safe to run the | |
3465 // callback. | |
3466 window_->layer()->SetShowPaintedContent(); | |
3467 } | |
3468 RunOnCommitCallbacks(); | 3174 RunOnCommitCallbacks(); |
3469 resize_lock_.reset(); | 3175 resize_lock_.reset(); |
3470 host_->WasResized(); | 3176 host_->WasResized(); |
3177 ui::Compositor* compositor = GetCompositor(); | |
3471 if (compositor && compositor->HasObserver(this)) | 3178 if (compositor && compositor->HasObserver(this)) |
3472 compositor->RemoveObserver(this); | 3179 compositor->RemoveObserver(this); |
3473 } | 3180 } |
3474 | 3181 |
3475 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const { | 3182 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const { |
3476 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); | 3183 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); |
3477 return dispatcher ? dispatcher->host()->compositor() : NULL; | 3184 return dispatcher ? dispatcher->host()->compositor() : NULL; |
3478 } | 3185 } |
3479 | 3186 |
3480 void RenderWidgetHostViewAura::DetachFromInputMethod() { | 3187 void RenderWidgetHostViewAura::DetachFromInputMethod() { |
(...skipping 20 matching lines...) Expand all Loading... | |
3501 RenderWidgetHost* widget) { | 3208 RenderWidgetHost* widget) { |
3502 return new RenderWidgetHostViewAura(widget); | 3209 return new RenderWidgetHostViewAura(widget); |
3503 } | 3210 } |
3504 | 3211 |
3505 // static | 3212 // static |
3506 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3213 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
3507 GetScreenInfoForWindow(results, NULL); | 3214 GetScreenInfoForWindow(results, NULL); |
3508 } | 3215 } |
3509 | 3216 |
3510 } // namespace content | 3217 } // namespace content |
OLD | NEW |