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

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

Issue 131443007: aura: Remove old GL paths from RenderWidgetHostViewAura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removecode: ackpreviousframe Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 315
316 if (event.type() == ui::ET_GESTURE_BEGIN) { 316 if (event.type() == ui::ET_GESTURE_BEGIN) {
317 const ui::GestureEvent& gesture = 317 const ui::GestureEvent& gesture =
318 static_cast<const ui::GestureEvent&>(event); 318 static_cast<const ui::GestureEvent&>(event);
319 return gesture.details().touch_points() == 1; 319 return gesture.details().touch_points() == 1;
320 } 320 }
321 321
322 return false; 322 return false;
323 } 323 }
324 324
325 // Swap ack for the renderer when kCompositeToMailbox is enabled.
326 void SendCompositorFrameAck(
327 int32 route_id,
328 uint32 output_surface_id,
329 int renderer_host_id,
330 const gpu::Mailbox& received_mailbox,
331 const gfx::Size& received_size,
332 bool skip_frame,
333 const scoped_refptr<ui::Texture>& texture_to_produce) {
334 cc::CompositorFrameAck ack;
335 ack.gl_frame_data.reset(new cc::GLFrameData());
336 DCHECK(!texture_to_produce.get() || !skip_frame);
337 if (texture_to_produce.get()) {
338 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
339 ack.gl_frame_data->mailbox = texture_to_produce->Produce();
340 ack.gl_frame_data->size = texture_to_produce->size();
341 ack.gl_frame_data->sync_point =
342 gl_helper ? gl_helper->InsertSyncPoint() : 0;
343 } else if (skip_frame) {
344 // Skip the frame, i.e. tell the producer to reuse the same buffer that
345 // we just received.
346 ack.gl_frame_data->size = received_size;
347 ack.gl_frame_data->mailbox = received_mailbox;
348 }
349
350 RenderWidgetHostImpl::SendSwapCompositorFrameAck(
351 route_id, output_surface_id, renderer_host_id, ack);
352 }
353
354 void AcknowledgeBufferForGpu(
355 int32 route_id,
356 int gpu_host_id,
357 const gpu::Mailbox& received_mailbox,
358 bool skip_frame,
359 const scoped_refptr<ui::Texture>& texture_to_produce) {
360 AcceleratedSurfaceMsg_BufferPresented_Params ack;
361 uint32 sync_point = 0;
362 DCHECK(!texture_to_produce.get() || !skip_frame);
363 if (texture_to_produce.get()) {
364 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
365 ack.mailbox = texture_to_produce->Produce();
366 sync_point = gl_helper ? gl_helper->InsertSyncPoint() : 0;
367 } else if (skip_frame) {
368 ack.mailbox = received_mailbox;
369 ack.sync_point = 0;
370 }
371
372 ack.sync_point = sync_point;
373 RenderWidgetHostImpl::AcknowledgeBufferPresent(
374 route_id, gpu_host_id, ack);
375 }
376
377 } // namespace 325 } // namespace
378 326
379 // We need to watch for mouse events outside a Web Popup or its parent 327 // We need to watch for mouse events outside a Web Popup or its parent
380 // and dismiss the popup for certain events. 328 // and dismiss the popup for certain events.
381 class RenderWidgetHostViewAura::EventFilterForPopupExit 329 class RenderWidgetHostViewAura::EventFilterForPopupExit
382 : public ui::EventHandler { 330 : public ui::EventHandler {
383 public: 331 public:
384 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) 332 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva)
385 : rwhva_(rwhva) { 333 : rwhva_(rwhva) {
386 DCHECK(rwhva_); 334 DCHECK(rwhva_);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 popup_child_host_view_(NULL), 421 popup_child_host_view_(NULL),
474 is_loading_(false), 422 is_loading_(false),
475 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 423 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
476 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), 424 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
477 can_compose_inline_(true), 425 can_compose_inline_(true),
478 has_composition_text_(false), 426 has_composition_text_(false),
479 accept_return_character_(false), 427 accept_return_character_(false),
480 last_output_surface_id_(0), 428 last_output_surface_id_(0),
481 pending_delegated_ack_count_(0), 429 pending_delegated_ack_count_(0),
482 skipped_frames_(false), 430 skipped_frames_(false),
483 last_swapped_surface_scale_factor_(1.f), 431 last_swapped_software_frame_scale_factor_(1.f),
484 paint_canvas_(NULL), 432 paint_canvas_(NULL),
485 synthetic_move_sent_(false), 433 synthetic_move_sent_(false),
486 accelerated_compositing_state_changed_(false),
487 can_lock_compositor_(YES), 434 can_lock_compositor_(YES),
488 cursor_visibility_state_in_renderer_(UNKNOWN), 435 cursor_visibility_state_in_renderer_(UNKNOWN),
489 touch_editing_client_(NULL), 436 touch_editing_client_(NULL),
490 delegated_frame_evictor_(new DelegatedFrameEvictor(this)), 437 delegated_frame_evictor_(new DelegatedFrameEvictor(this)),
491 weak_ptr_factory_(this) { 438 weak_ptr_factory_(this) {
492 host_->SetView(this); 439 host_->SetView(this);
493 window_observer_.reset(new WindowObserver(this)); 440 window_observer_.reset(new WindowObserver(this));
494 aura::client::SetTooltipText(window_, &tooltip_); 441 aura::client::SetTooltipText(window_, &tooltip_);
495 aura::client::SetActivationDelegate(window_, this); 442 aura::client::SetActivationDelegate(window_, this);
496 aura::client::SetActivationChangeObserver(window_, this); 443 aura::client::SetActivationChangeObserver(window_, this);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 delegated_frame_evictor_->SetVisible(true); 559 delegated_frame_evictor_->SetVisible(true);
613 560
614 aura::Window* root = window_->GetRootWindow(); 561 aura::Window* root = window_->GetRootWindow();
615 if (root) { 562 if (root) {
616 aura::client::CursorClient* cursor_client = 563 aura::client::CursorClient* cursor_client =
617 aura::client::GetCursorClient(root); 564 aura::client::GetCursorClient(root);
618 if (cursor_client) 565 if (cursor_client)
619 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); 566 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible());
620 } 567 }
621 568
622 if (!current_surface_.get() && host_->is_accelerated_compositing_active() && 569 if (host_->is_accelerated_compositing_active() &&
623 !released_front_lock_.get()) { 570 !released_front_lock_.get()) {
624 ui::Compositor* compositor = GetCompositor(); 571 ui::Compositor* compositor = GetCompositor();
625 if (compositor) 572 if (compositor)
626 released_front_lock_ = compositor->GetCompositorLock(); 573 released_front_lock_ = compositor->GetCompositorLock();
627 } 574 }
628 575
629 #if defined(OS_WIN) 576 #if defined(OS_WIN)
630 if (legacy_render_widget_host_HWND_) { 577 if (legacy_render_widget_host_HWND_) {
631 // Reparent the legacy Chrome_RenderWidgetHostHWND window to the parent 578 // Reparent the legacy Chrome_RenderWidgetHostHWND window to the parent
632 // window before reparenting any plugins. This ensures that the plugin 579 // window before reparenting any plugins. This ensures that the plugin
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 #else 671 #else
725 if (resize_lock_) 672 if (resize_lock_)
726 return false; 673 return false;
727 674
728 if (host_->should_auto_resize()) 675 if (host_->should_auto_resize())
729 return false; 676 return false;
730 if (!host_->is_accelerated_compositing_active()) 677 if (!host_->is_accelerated_compositing_active())
731 return false; 678 return false;
732 679
733 gfx::Size desired_size = window_->bounds().size(); 680 gfx::Size desired_size = window_->bounds().size();
734 if (desired_size == current_frame_size_) 681 if (desired_size == current_frame_size_in_dip_)
735 return false; 682 return false;
736 683
737 aura::WindowTreeHost* host = window_->GetHost(); 684 aura::WindowTreeHost* host = window_->GetHost();
738 if (!host) 685 if (!host)
739 return false; 686 return false;
740 687
741 ui::Compositor* compositor = host->compositor(); 688 ui::Compositor* compositor = host->compositor();
742 if (!compositor) 689 if (!compositor)
743 return false; 690 return false;
744 691
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 const gfx::Range& range, 910 const gfx::Range& range,
964 const std::vector<gfx::Rect>& character_bounds) { 911 const std::vector<gfx::Rect>& character_bounds) {
965 composition_character_bounds_ = character_bounds; 912 composition_character_bounds_ = character_bounds;
966 } 913 }
967 914
968 void RenderWidgetHostViewAura::DidUpdateBackingStore( 915 void RenderWidgetHostViewAura::DidUpdateBackingStore(
969 const gfx::Rect& scroll_rect, 916 const gfx::Rect& scroll_rect,
970 const gfx::Vector2d& scroll_delta, 917 const gfx::Vector2d& scroll_delta,
971 const std::vector<gfx::Rect>& copy_rects, 918 const std::vector<gfx::Rect>& copy_rects,
972 const std::vector<ui::LatencyInfo>& latency_info) { 919 const std::vector<ui::LatencyInfo>& latency_info) {
973 if (accelerated_compositing_state_changed_)
974 UpdateExternalTexture();
975
976 for (size_t i = 0; i < latency_info.size(); i++) 920 for (size_t i = 0; i < latency_info.size(); i++)
977 software_latency_info_.push_back(latency_info[i]); 921 software_latency_info_.push_back(latency_info[i]);
978 922
979 // Use the state of the RenderWidgetHost and not the window as the two may 923 // Use the state of the RenderWidgetHost and not the window as the two may
980 // differ. In particular if the window is hidden but the renderer isn't and we 924 // differ. In particular if the window is hidden but the renderer isn't and we
981 // ignore the update and the window is made visible again the layer isn't 925 // ignore the update and the window is made visible again the layer isn't
982 // marked as dirty and we show the wrong thing. 926 // marked as dirty and we show the wrong thing.
983 // We do this after UpdateExternalTexture() so that when we become visible
984 // we're not drawing a stale texture.
985 if (host_->is_hidden()) 927 if (host_->is_hidden())
986 return; 928 return;
987 929
988 gfx::Rect clip_rect; 930 gfx::Rect clip_rect;
989 if (paint_canvas_) { 931 if (paint_canvas_) {
990 SkRect sk_clip_rect; 932 SkRect sk_clip_rect;
991 if (paint_canvas_->sk_canvas()->getClipBounds(&sk_clip_rect)) 933 if (paint_canvas_->sk_canvas()->getClipBounds(&sk_clip_rect))
992 clip_rect = gfx::ToEnclosingRect(gfx::SkRectToRectF(sk_clip_rect)); 934 clip_rect = gfx::ToEnclosingRect(gfx::SkRectToRectF(sk_clip_rect));
993 } 935 }
994 936
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { 1137 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) {
1196 frame_subscriber_ = subscriber.Pass(); 1138 frame_subscriber_ = subscriber.Pass();
1197 } 1139 }
1198 1140
1199 void RenderWidgetHostViewAura::EndFrameSubscription() { 1141 void RenderWidgetHostViewAura::EndFrameSubscription() {
1200 idle_frame_subscriber_textures_.clear(); 1142 idle_frame_subscriber_textures_.clear();
1201 frame_subscriber_.reset(); 1143 frame_subscriber_.reset();
1202 } 1144 }
1203 1145
1204 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { 1146 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() {
1205 // Delay processing the state change until we either get a software frame if
1206 // switching to software mode or receive a buffers swapped notification
1207 // if switching to accelerated mode.
1208 // Sometimes (e.g. on a page load) the renderer will spuriously disable then
1209 // re-enable accelerated compositing, causing us to flash.
1210 // TODO(piman): factor the enable/disable accelerated compositing message into
1211 // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have
1212 // fewer inconsistent temporary states.
1213 accelerated_compositing_state_changed_ = true;
1214 } 1147 }
1215 1148
1216 void RenderWidgetHostViewAura::AcceleratedSurfaceInitialized(int host_id, 1149 void RenderWidgetHostViewAura::AcceleratedSurfaceInitialized(int host_id,
1217 int route_id) { 1150 int route_id) {
1218 } 1151 }
1219 1152
1220 bool RenderWidgetHostViewAura::ShouldSkipFrame(gfx::Size size_in_dip) const { 1153 bool RenderWidgetHostViewAura::ShouldSkipFrame(gfx::Size size_in_dip) const {
1221 if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME || 1154 if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME ||
1222 can_lock_compositor_ == NO_PENDING_COMMIT || 1155 can_lock_compositor_ == NO_PENDING_COMMIT ||
1223 !resize_lock_.get()) 1156 !resize_lock_.get())
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 } 1191 }
1259 if (legacy_render_widget_host_HWND_) { 1192 if (legacy_render_widget_host_HWND_) {
1260 legacy_render_widget_host_HWND_->SetBounds( 1193 legacy_render_widget_host_HWND_->SetBounds(
1261 window_->GetBoundsInRootWindow()); 1194 window_->GetBoundsInRootWindow());
1262 } 1195 }
1263 } 1196 }
1264 #endif 1197 #endif
1265 } 1198 }
1266 1199
1267 void RenderWidgetHostViewAura::CheckResizeLock() { 1200 void RenderWidgetHostViewAura::CheckResizeLock() {
1268 if (!resize_lock_ || resize_lock_->expected_size() != current_frame_size_) 1201 if (!resize_lock_ ||
1202 resize_lock_->expected_size() != current_frame_size_in_dip_)
1269 return; 1203 return;
1270 1204
1271 // Since we got the size we were looking for, unlock the compositor. But delay 1205 // Since we got the size we were looking for, unlock the compositor. But delay
1272 // the release of the lock until we've kicked a frame with the new texture, to 1206 // the release of the lock until we've kicked a frame with the new texture, to
1273 // avoid resizing the UI before we have a chance to draw a "good" frame. 1207 // avoid resizing the UI before we have a chance to draw a "good" frame.
1274 resize_lock_->UnlockCompositor(); 1208 resize_lock_->UnlockCompositor();
1275 ui::Compositor* compositor = GetCompositor(); 1209 ui::Compositor* compositor = GetCompositor();
1276 if (compositor) { 1210 if (compositor) {
1277 if (!compositor->HasObserver(this)) 1211 if (!compositor->HasObserver(this))
1278 compositor->AddObserver(this); 1212 compositor->AddObserver(this);
1279 } 1213 }
1280 } 1214 }
1281 1215
1282 void RenderWidgetHostViewAura::UpdateExternalTexture() {
1283 // Delay processing accelerated compositing state change till here where we
1284 // act upon the state change. (Clear the external texture if switching to
1285 // software mode or set the external texture if going to accelerated mode).
1286 if (accelerated_compositing_state_changed_)
1287 accelerated_compositing_state_changed_ = false;
1288
1289 bool is_compositing_active = host_->is_accelerated_compositing_active();
1290 if (is_compositing_active && current_surface_.get()) {
1291 window_->layer()->SetExternalTexture(current_surface_.get());
1292 current_frame_size_ = ConvertSizeToDIP(
1293 current_surface_->device_scale_factor(), current_surface_->size());
1294 CheckResizeLock();
1295 software_frame_manager_->DiscardCurrentFrame();
1296 } else if (is_compositing_active &&
1297 software_frame_manager_->HasCurrentFrame()) {
1298 cc::TextureMailbox mailbox;
1299 scoped_ptr<cc::SingleReleaseCallback> callback;
1300 software_frame_manager_->GetCurrentFrameMailbox(&mailbox, &callback);
1301 window_->layer()->SetTextureMailbox(mailbox,
1302 callback.Pass(),
1303 last_swapped_surface_scale_factor_);
1304 current_frame_size_ = ConvertSizeToDIP(last_swapped_surface_scale_factor_,
1305 mailbox.shared_memory_size());
1306 CheckResizeLock();
1307 } else {
1308 window_->layer()->SetShowPaintedContent();
1309 resize_lock_.reset();
1310 host_->WasResized();
1311 software_frame_manager_->DiscardCurrentFrame();
1312 }
1313 }
1314
1315 bool RenderWidgetHostViewAura::SwapBuffersPrepare(
1316 const gfx::Rect& surface_rect,
1317 float surface_scale_factor,
1318 const gfx::Rect& damage_rect,
1319 const gpu::Mailbox& mailbox,
1320 const BufferPresentedCallback& ack_callback) {
1321 if (last_swapped_surface_size_ != surface_rect.size()) {
1322 // The surface could have shrunk since we skipped an update, in which
1323 // case we can expect a full update.
1324 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect";
1325 skipped_damage_.setEmpty();
1326 last_swapped_surface_size_ = surface_rect.size();
1327 last_swapped_surface_scale_factor_ = surface_scale_factor;
1328 }
1329
1330 if (ShouldSkipFrame(ConvertSizeToDIP(surface_scale_factor,
1331 surface_rect.size())) ||
1332 mailbox.IsZero()) {
1333 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op);
1334 ack_callback.Run(true, scoped_refptr<ui::Texture>());
1335 return false;
1336 }
1337
1338 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1339 current_surface_ =
1340 factory->CreateTransportClient(surface_scale_factor);
1341 if (!current_surface_.get()) {
1342 LOG(ERROR) << "Failed to create ImageTransport texture";
1343 ack_callback.Run(true, scoped_refptr<ui::Texture>());
1344 return false;
1345 }
1346
1347 current_surface_->Consume(mailbox, surface_rect.size());
1348 released_front_lock_ = NULL;
1349 UpdateExternalTexture();
1350
1351 return true;
1352 }
1353
1354 void RenderWidgetHostViewAura::SwapBuffersCompleted(
1355 const BufferPresentedCallback& ack_callback,
1356 const scoped_refptr<ui::Texture>& texture_to_return) {
1357 ui::Compositor* compositor = GetCompositor();
1358 if (!compositor) {
1359 ack_callback.Run(false, texture_to_return);
1360 } else {
1361 AddOnCommitCallbackAndDisableLocks(
1362 base::Bind(ack_callback, false, texture_to_return));
1363 }
1364
1365 DidReceiveFrameFromRenderer();
1366 }
1367
1368 void RenderWidgetHostViewAura::DidReceiveFrameFromRenderer() { 1216 void RenderWidgetHostViewAura::DidReceiveFrameFromRenderer() {
1369 if (frame_subscriber() && CanCopyToVideoFrame()) { 1217 if (frame_subscriber() && CanCopyToVideoFrame()) {
1370 const base::TimeTicks present_time = base::TimeTicks::Now(); 1218 const base::TimeTicks present_time = base::TimeTicks::Now();
1371 scoped_refptr<media::VideoFrame> frame; 1219 scoped_refptr<media::VideoFrame> frame;
1372 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; 1220 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback;
1373 if (frame_subscriber()->ShouldCaptureFrame(present_time, 1221 if (frame_subscriber()->ShouldCaptureFrame(present_time,
1374 &frame, &callback)) { 1222 &frame, &callback)) {
1375 CopyFromCompositingSurfaceToVideoFrame( 1223 CopyFromCompositingSurfaceToVideoFrame(
1376 gfx::Rect(current_frame_size_), 1224 gfx::Rect(current_frame_size_in_dip_),
1377 frame, 1225 frame,
1378 base::Bind(callback, present_time)); 1226 base::Bind(callback, present_time));
1379 } 1227 }
1380 } 1228 }
1381 } 1229 }
1382 1230
1383 #if defined(OS_WIN) 1231 #if defined(OS_WIN)
1384 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects( 1232 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects(
1385 const std::vector<gfx::Rect>& rects) { 1233 const std::vector<gfx::Rect>& rects) {
1386 // Check this before setting constrained_rects_, so that next time they're set 1234 // Check this before setting constrained_rects_, so that next time they're set
(...skipping 12 matching lines...) Expand all
1399 params.cutout_rects = constrained_rects_; 1247 params.cutout_rects = constrained_rects_;
1400 params.geometry = &plugin_window_moves_; 1248 params.geometry = &plugin_window_moves_;
1401 LPARAM lparam = reinterpret_cast<LPARAM>(&params); 1249 LPARAM lparam = reinterpret_cast<LPARAM>(&params);
1402 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); 1250 EnumChildWindows(parent, SetCutoutRectsCallback, lparam);
1403 } 1251 }
1404 #endif 1252 #endif
1405 1253
1406 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( 1254 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
1407 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, 1255 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
1408 int gpu_host_id) { 1256 int gpu_host_id) {
1409 BufferPresentedCallback ack_callback = base::Bind( 1257 // Oldschool composited mode is no longer supported.
1410 &AcknowledgeBufferForGpu,
1411 params_in_pixel.route_id,
1412 gpu_host_id,
1413 params_in_pixel.mailbox);
1414 BuffersSwapped(params_in_pixel.size,
1415 gfx::Rect(params_in_pixel.size),
1416 params_in_pixel.scale_factor,
1417 params_in_pixel.mailbox,
1418 params_in_pixel.latency_info,
1419 ack_callback);
1420 } 1258 }
1421 1259
1422 void RenderWidgetHostViewAura::SwapDelegatedFrame( 1260 void RenderWidgetHostViewAura::SwapDelegatedFrame(
1423 uint32 output_surface_id, 1261 uint32 output_surface_id,
1424 scoped_ptr<cc::DelegatedFrameData> frame_data, 1262 scoped_ptr<cc::DelegatedFrameData> frame_data,
1425 float frame_device_scale_factor, 1263 float frame_device_scale_factor,
1426 const std::vector<ui::LatencyInfo>& latency_info) { 1264 const std::vector<ui::LatencyInfo>& latency_info) {
1427 DCHECK_NE(0u, frame_data->render_pass_list.size()); 1265 DCHECK_NE(0u, frame_data->render_pass_list.size());
1428 1266
1429 cc::RenderPass* root_pass = frame_data->render_pass_list.back(); 1267 cc::RenderPass* root_pass = frame_data->render_pass_list.back();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 if (!resource_collection_) { 1327 if (!resource_collection_) {
1490 resource_collection_ = new cc::DelegatedFrameResourceCollection; 1328 resource_collection_ = new cc::DelegatedFrameResourceCollection;
1491 resource_collection_->SetClient(this); 1329 resource_collection_->SetClient(this);
1492 } 1330 }
1493 // If the physical frame size changes, we need a new |frame_provider_|. If 1331 // If the physical frame size changes, we need a new |frame_provider_|. If
1494 // the physical frame size is the same, but the size in DIP changed, we 1332 // the physical frame size is the same, but the size in DIP changed, we
1495 // need to adjust the scale at which the frames will be drawn, and we do 1333 // need to adjust the scale at which the frames will be drawn, and we do
1496 // this by making a new |frame_provider_| also to ensure the scale change 1334 // this by making a new |frame_provider_| also to ensure the scale change
1497 // is presented in sync with the new frame content. 1335 // is presented in sync with the new frame content.
1498 if (!frame_provider_.get() || frame_size != frame_provider_->frame_size() || 1336 if (!frame_provider_.get() || frame_size != frame_provider_->frame_size() ||
1499 frame_size_in_dip != current_frame_size_) { 1337 frame_size_in_dip != current_frame_size_in_dip_) {
1500 frame_provider_ = new cc::DelegatedFrameProvider( 1338 frame_provider_ = new cc::DelegatedFrameProvider(
1501 resource_collection_.get(), frame_data.Pass()); 1339 resource_collection_.get(), frame_data.Pass());
1502 window_->layer()->SetShowDelegatedContent(frame_provider_.get(), 1340 window_->layer()->SetShowDelegatedContent(frame_provider_.get(),
1503 frame_size_in_dip); 1341 frame_size_in_dip);
1504 } else { 1342 } else {
1505 frame_provider_->SetFrameData(frame_data.Pass()); 1343 frame_provider_->SetFrameData(frame_data.Pass());
1506 } 1344 }
1507 } 1345 }
1508 released_front_lock_ = NULL; 1346 released_front_lock_ = NULL;
1509 current_frame_size_ = frame_size_in_dip; 1347 current_frame_size_in_dip_ = frame_size_in_dip;
1510 CheckResizeLock(); 1348 CheckResizeLock();
1511 1349
1512 window_->SchedulePaintInRect(damage_rect_in_dip); 1350 window_->SchedulePaintInRect(damage_rect_in_dip);
1513 1351
1514 pending_delegated_ack_count_++; 1352 pending_delegated_ack_count_++;
1515 1353
1516 ui::Compositor* compositor = GetCompositor(); 1354 ui::Compositor* compositor = GetCompositor();
1517 if (!compositor) { 1355 if (!compositor) {
1518 SendDelegatedFrameAck(output_surface_id); 1356 SendDelegatedFrameAck(output_surface_id);
1519 } else { 1357 } else {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 if (!software_frame_manager_->SwapToNewFrame( 1426 if (!software_frame_manager_->SwapToNewFrame(
1589 output_surface_id, 1427 output_surface_id,
1590 frame_data.get(), 1428 frame_data.get(),
1591 frame_device_scale_factor, 1429 frame_device_scale_factor,
1592 host_->GetProcess()->GetHandle())) { 1430 host_->GetProcess()->GetHandle())) {
1593 ReleaseSoftwareFrame(output_surface_id, frame_data->id); 1431 ReleaseSoftwareFrame(output_surface_id, frame_data->id);
1594 SendSoftwareFrameAck(output_surface_id); 1432 SendSoftwareFrameAck(output_surface_id);
1595 return; 1433 return;
1596 } 1434 }
1597 1435
1598 if (last_swapped_surface_size_ != frame_size) { 1436 frame_provider_ = NULL;
1437 delegated_frame_evictor_->DiscardedFrame();
1438
1439 if (last_swapped_software_frame_size_ != frame_size) {
1599 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size)) 1440 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size))
1600 << "Expected full damage rect"; 1441 << "Expected full damage rect";
1601 } 1442 }
1602 last_swapped_surface_size_ = frame_size; 1443 last_swapped_software_frame_size_ = frame_size;
1603 last_swapped_surface_scale_factor_ = frame_device_scale_factor; 1444 last_swapped_software_frame_scale_factor_ = frame_device_scale_factor;
1604 1445
1605 cc::TextureMailbox mailbox; 1446 cc::TextureMailbox mailbox;
1606 scoped_ptr<cc::SingleReleaseCallback> callback; 1447 scoped_ptr<cc::SingleReleaseCallback> callback;
1607 software_frame_manager_->GetCurrentFrameMailbox(&mailbox, &callback); 1448 software_frame_manager_->GetCurrentFrameMailbox(&mailbox, &callback);
1608 DCHECK(mailbox.IsSharedMemory()); 1449 DCHECK(mailbox.IsSharedMemory());
1609 current_frame_size_ = frame_size_in_dip; 1450 current_frame_size_in_dip_ = frame_size_in_dip;
1610 1451
1611 released_front_lock_ = NULL; 1452 released_front_lock_ = NULL;
1612 CheckResizeLock(); 1453 CheckResizeLock();
1613 window_->layer()->SetTextureMailbox(mailbox, 1454 window_->layer()->SetTextureMailbox(mailbox,
1614 callback.Pass(), 1455 callback.Pass(),
1615 frame_device_scale_factor); 1456 frame_device_scale_factor);
1616 window_->SchedulePaintInRect( 1457 window_->SchedulePaintInRect(
1617 ConvertRectToDIP(frame_device_scale_factor, damage_rect)); 1458 ConvertRectToDIP(frame_device_scale_factor, damage_rect));
1618 1459
1619 ui::Compositor* compositor = GetCompositor(); 1460 ui::Compositor* compositor = GetCompositor();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 1513
1673 void RenderWidgetHostViewAura::OnSwapCompositorFrame( 1514 void RenderWidgetHostViewAura::OnSwapCompositorFrame(
1674 uint32 output_surface_id, 1515 uint32 output_surface_id,
1675 scoped_ptr<cc::CompositorFrame> frame) { 1516 scoped_ptr<cc::CompositorFrame> frame) {
1676 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); 1517 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame");
1677 if (frame->delegated_frame_data) { 1518 if (frame->delegated_frame_data) {
1678 SwapDelegatedFrame(output_surface_id, 1519 SwapDelegatedFrame(output_surface_id,
1679 frame->delegated_frame_data.Pass(), 1520 frame->delegated_frame_data.Pass(),
1680 frame->metadata.device_scale_factor, 1521 frame->metadata.device_scale_factor,
1681 frame->metadata.latency_info); 1522 frame->metadata.latency_info);
1682 return; 1523 } else if (frame->software_frame_data) {
1683 }
1684
1685 if (frame->software_frame_data) {
1686 SwapSoftwareFrame(output_surface_id, 1524 SwapSoftwareFrame(output_surface_id,
1687 frame->software_frame_data.Pass(), 1525 frame->software_frame_data.Pass(),
1688 frame->metadata.device_scale_factor, 1526 frame->metadata.device_scale_factor,
1689 frame->metadata.latency_info); 1527 frame->metadata.latency_info);
1690 return;
1691 } 1528 }
1692
1693 if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero())
1694 return;
1695
1696 BufferPresentedCallback ack_callback = base::Bind(
1697 &SendCompositorFrameAck,
1698 host_->GetRoutingID(), output_surface_id, host_->GetProcess()->GetID(),
1699 frame->gl_frame_data->mailbox, frame->gl_frame_data->size);
1700
1701 if (!frame->gl_frame_data->sync_point) {
1702 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame...";
1703 ack_callback.Run(true, scoped_refptr<ui::Texture>());
1704 return;
1705 }
1706
1707 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
1708 gl_helper->WaitSyncPoint(frame->gl_frame_data->sync_point);
1709
1710 BuffersSwapped(frame->gl_frame_data->size,
1711 frame->gl_frame_data->sub_buffer_rect,
1712 frame->metadata.device_scale_factor,
1713 frame->gl_frame_data->mailbox,
1714 frame->metadata.latency_info,
1715 ack_callback);
1716 } 1529 }
1717 1530
1718 #if defined(OS_WIN) 1531 #if defined(OS_WIN)
1719 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( 1532 void RenderWidgetHostViewAura::SetParentNativeViewAccessible(
1720 gfx::NativeViewAccessible accessible_parent) { 1533 gfx::NativeViewAccessible accessible_parent) {
1721 if (GetBrowserAccessibilityManager()) { 1534 if (GetBrowserAccessibilityManager()) {
1722 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() 1535 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin()
1723 ->set_parent_iaccessible(accessible_parent); 1536 ->set_parent_iaccessible(accessible_parent);
1724 } 1537 }
1725 } 1538 }
1726 1539
1727 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() 1540 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin()
1728 const { 1541 const {
1729 if (legacy_render_widget_host_HWND_) { 1542 if (legacy_render_widget_host_HWND_) {
1730 return reinterpret_cast<gfx::NativeViewId>( 1543 return reinterpret_cast<gfx::NativeViewId>(
1731 legacy_render_widget_host_HWND_->hwnd()); 1544 legacy_render_widget_host_HWND_->hwnd());
1732 } 1545 }
1733 return NULL; 1546 return NULL;
1734 } 1547 }
1735 #endif 1548 #endif
1736 1549
1737 void RenderWidgetHostViewAura::BuffersSwapped(
1738 const gfx::Size& surface_size,
1739 const gfx::Rect& damage_rect,
1740 float surface_scale_factor,
1741 const gpu::Mailbox& mailbox,
1742 const std::vector<ui::LatencyInfo>& latency_info,
1743 const BufferPresentedCallback& ack_callback) {
1744 scoped_refptr<ui::Texture> previous_texture(current_surface_);
1745 const gfx::Rect surface_rect = gfx::Rect(surface_size);
1746 software_frame_manager_->DiscardCurrentFrame();
1747
1748 if (!SwapBuffersPrepare(surface_rect,
1749 surface_scale_factor,
1750 damage_rect,
1751 mailbox,
1752 ack_callback)) {
1753 return;
1754 }
1755
1756 SkRegion damage(RectToSkIRect(damage_rect));
1757 if (!skipped_damage_.isEmpty()) {
1758 damage.op(skipped_damage_, SkRegion::kUnion_Op);
1759 skipped_damage_.setEmpty();
1760 }
1761
1762 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds())));
1763 ui::Texture* current_texture = current_surface_.get();
1764
1765 const gfx::Size surface_size_in_pixel = surface_size;
1766 DLOG_IF(ERROR, previous_texture.get() &&
1767 previous_texture->size() != current_texture->size() &&
1768 SkIRectToRect(damage.getBounds()) != surface_rect) <<
1769 "Expected full damage rect after size change";
1770 if (previous_texture.get() && !previous_damage_.isEmpty() &&
1771 previous_texture->size() == current_texture->size()) {
1772 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1773 GLHelper* gl_helper = factory->GetGLHelper();
1774 gl_helper->CopySubBufferDamage(
1775 current_texture->PrepareTexture(),
1776 previous_texture->PrepareTexture(),
1777 damage,
1778 previous_damage_);
1779 }
1780 previous_damage_ = damage;
1781
1782 ui::Compositor* compositor = GetCompositor();
1783 if (compositor) {
1784 // Co-ordinates come in OpenGL co-ordinate space.
1785 // We need to convert to layer space.
1786 gfx::Rect rect_to_paint =
1787 ConvertRectToDIP(surface_scale_factor,
1788 gfx::Rect(damage_rect.x(),
1789 surface_size_in_pixel.height() -
1790 damage_rect.y() - damage_rect.height(),
1791 damage_rect.width(),
1792 damage_rect.height()));
1793
1794 // Damage may not have been DIP aligned, so inflate damage to compensate
1795 // for any round-off error.
1796 rect_to_paint.Inset(-1, -1);
1797 rect_to_paint.Intersect(window_->bounds());
1798
1799 window_->SchedulePaintInRect(rect_to_paint);
1800 for (size_t i = 0; i < latency_info.size(); i++)
1801 compositor->SetLatencyInfo(latency_info[i]);
1802 }
1803
1804 SwapBuffersCompleted(ack_callback, previous_texture);
1805 }
1806
1807 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( 1550 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
1808 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, 1551 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
1809 int gpu_host_id) { 1552 int gpu_host_id) {
1810 gfx::Rect damage_rect(params_in_pixel.x, 1553 // Oldschool composited mode is no longer supported.
1811 params_in_pixel.y,
1812 params_in_pixel.width,
1813 params_in_pixel.height);
1814 BufferPresentedCallback ack_callback =
1815 base::Bind(&AcknowledgeBufferForGpu,
1816 params_in_pixel.route_id,
1817 gpu_host_id,
1818 params_in_pixel.mailbox);
1819 BuffersSwapped(params_in_pixel.surface_size,
1820 damage_rect,
1821 params_in_pixel.surface_scale_factor,
1822 params_in_pixel.mailbox,
1823 params_in_pixel.latency_info,
1824 ack_callback);
1825 } 1554 }
1826 1555
1827 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { 1556 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() {
1828 } 1557 }
1829 1558
1830 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { 1559 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() {
1831 // This really tells us to release the frontbuffer.
1832 if (current_surface_.get()) {
1833 ui::Compositor* compositor = GetCompositor();
1834 if (compositor) {
1835 // We need to wait for a commit to clear to guarantee that all we
1836 // will not issue any more GL referencing the previous surface.
1837 AddOnCommitCallbackAndDisableLocks(
1838 base::Bind(&RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor,
1839 AsWeakPtr(),
1840 current_surface_)); // Hold a ref so the texture will not
1841 // get deleted until after commit.
1842 }
1843 current_surface_ = NULL;
1844 UpdateExternalTexture();
1845 }
1846 } 1560 }
1847 1561
1848 bool RenderWidgetHostViewAura::HasAcceleratedSurface( 1562 bool RenderWidgetHostViewAura::HasAcceleratedSurface(
1849 const gfx::Size& desired_size) { 1563 const gfx::Size& desired_size) {
1850 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't 1564 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't
1851 // matter what is returned here as GetBackingStore is the only caller of this 1565 // matter what is returned here as GetBackingStore is the only caller of this
1852 // method. TODO(jbates) implement this if other Aura code needs it. 1566 // method. TODO(jbates) implement this if other Aura code needs it.
1853 return false; 1567 return false;
1854 } 1568 }
1855 1569
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 } 2421 }
2708 2422
2709 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { 2423 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const {
2710 } 2424 }
2711 2425
2712 void RenderWidgetHostViewAura::DidRecreateLayer(ui::Layer *old_layer, 2426 void RenderWidgetHostViewAura::DidRecreateLayer(ui::Layer *old_layer,
2713 ui::Layer *new_layer) { 2427 ui::Layer *new_layer) {
2714 float mailbox_scale_factor; 2428 float mailbox_scale_factor;
2715 cc::TextureMailbox old_mailbox = 2429 cc::TextureMailbox old_mailbox =
2716 old_layer->GetTextureMailbox(&mailbox_scale_factor); 2430 old_layer->GetTextureMailbox(&mailbox_scale_factor);
2717 scoped_refptr<ui::Texture> old_texture = old_layer->external_texture();
2718 // The new_layer is the one that will be used by our Window, so that's the one 2431 // The new_layer is the one that will be used by our Window, so that's the one
2719 // that should keep our texture. old_layer will be returned to the 2432 // that should keep our texture. old_layer will be returned to the
2720 // RecreateLayer caller, and should have a copy. 2433 // RecreateLayer caller, and should have a copy.
2721 if (old_texture.get()) { 2434 if (old_mailbox.IsSharedMemory()) {
2722 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
2723 GLHelper* gl_helper = factory->GetGLHelper();
2724 scoped_refptr<ui::Texture> new_texture;
2725 if (host_->is_accelerated_compositing_active() &&
2726 gl_helper && current_surface_.get()) {
2727 GLuint texture_id =
2728 gl_helper->CopyTexture(current_surface_->PrepareTexture(),
2729 current_surface_->size());
2730 if (texture_id) {
2731 new_texture = factory->CreateOwnedTexture(
2732 current_surface_->size(),
2733 current_surface_->device_scale_factor(), texture_id);
2734 }
2735 }
2736 if (new_texture.get())
2737 old_layer->SetExternalTexture(new_texture.get());
2738 else
2739 old_layer->SetShowPaintedContent();
2740 new_layer->SetExternalTexture(old_texture.get());
2741 } else if (old_mailbox.IsSharedMemory()) {
2742 base::SharedMemory* old_buffer = old_mailbox.shared_memory(); 2435 base::SharedMemory* old_buffer = old_mailbox.shared_memory();
2743 const size_t size = old_mailbox.shared_memory_size_in_bytes(); 2436 const size_t size = old_mailbox.shared_memory_size_in_bytes();
2744 2437
2745 scoped_ptr<base::SharedMemory> new_buffer(new base::SharedMemory); 2438 scoped_ptr<base::SharedMemory> new_buffer(new base::SharedMemory);
2746 new_buffer->CreateAndMapAnonymous(size); 2439 new_buffer->CreateAndMapAnonymous(size);
2747 2440
2748 if (old_buffer->memory() && new_buffer->memory()) { 2441 if (old_buffer->memory() && new_buffer->memory()) {
2749 memcpy(new_buffer->memory(), old_buffer->memory(), size); 2442 memcpy(new_buffer->memory(), old_buffer->memory(), size);
2750 base::SharedMemory* new_buffer_raw_ptr = new_buffer.get(); 2443 base::SharedMemory* new_buffer_raw_ptr = new_buffer.get();
2751 scoped_ptr<cc::SingleReleaseCallback> callback = 2444 scoped_ptr<cc::SingleReleaseCallback> callback =
2752 cc::SingleReleaseCallback::Create(base::Bind(MailboxReleaseCallback, 2445 cc::SingleReleaseCallback::Create(base::Bind(MailboxReleaseCallback,
2753 Passed(&new_buffer))); 2446 Passed(&new_buffer)));
2754 cc::TextureMailbox new_mailbox(new_buffer_raw_ptr, 2447 cc::TextureMailbox new_mailbox(new_buffer_raw_ptr,
2755 old_mailbox.shared_memory_size()); 2448 old_mailbox.shared_memory_size());
2756 new_layer->SetTextureMailbox(new_mailbox, 2449 new_layer->SetTextureMailbox(new_mailbox,
2757 callback.Pass(), 2450 callback.Pass(),
2758 mailbox_scale_factor); 2451 mailbox_scale_factor);
2759 } 2452 }
2760 } else if (frame_provider_.get()) { 2453 } else if (frame_provider_.get()) {
2761 new_layer->SetShowDelegatedContent(frame_provider_.get(), 2454 new_layer->SetShowDelegatedContent(frame_provider_.get(),
2762 current_frame_size_); 2455 current_frame_size_in_dip_);
2763 } 2456 }
2764 } 2457 }
2765 2458
2766 //////////////////////////////////////////////////////////////////////////////// 2459 ////////////////////////////////////////////////////////////////////////////////
2767 // RenderWidgetHostViewAura, ui::EventHandler implementation: 2460 // RenderWidgetHostViewAura, ui::EventHandler implementation:
2768 2461
2769 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { 2462 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) {
2770 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); 2463 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent");
2771 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) 2464 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
2772 return; 2465 return;
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
3188 uint32 output_surface_id, unsigned frame_id) { 2881 uint32 output_surface_id, unsigned frame_id) {
3189 ReleaseSoftwareFrame(output_surface_id, frame_id); 2882 ReleaseSoftwareFrame(output_surface_id, frame_id);
3190 } 2883 }
3191 2884
3192 void RenderWidgetHostViewAura::ReleaseReferencesToSoftwareFrame() { 2885 void RenderWidgetHostViewAura::ReleaseReferencesToSoftwareFrame() {
3193 ui::Compositor* compositor = GetCompositor(); 2886 ui::Compositor* compositor = GetCompositor();
3194 if (compositor) { 2887 if (compositor) {
3195 AddOnCommitCallbackAndDisableLocks(base::Bind( 2888 AddOnCommitCallbackAndDisableLocks(base::Bind(
3196 &RenderWidgetHostViewAura::SendReclaimSoftwareFrames, AsWeakPtr())); 2889 &RenderWidgetHostViewAura::SendReclaimSoftwareFrames, AsWeakPtr()));
3197 } 2890 }
3198 UpdateExternalTexture(); 2891 window_->layer()->SetShowPaintedContent();
3199 } 2892 }
3200 2893
3201 //////////////////////////////////////////////////////////////////////////////// 2894 ////////////////////////////////////////////////////////////////////////////////
3202 // RenderWidgetHostViewAura, ui::CompositorObserver implementation: 2895 // RenderWidgetHostViewAura, ui::CompositorObserver implementation:
3203 2896
3204 void RenderWidgetHostViewAura::OnCompositingDidCommit( 2897 void RenderWidgetHostViewAura::OnCompositingDidCommit(
3205 ui::Compositor* compositor) { 2898 ui::Compositor* compositor) {
3206 if (can_lock_compositor_ == NO_PENDING_COMMIT) { 2899 if (can_lock_compositor_ == NO_PENDING_COMMIT) {
3207 can_lock_compositor_ = YES; 2900 can_lock_compositor_ = YES;
3208 if (resize_lock_.get() && resize_lock_->GrabDeferredLock()) 2901 if (resize_lock_.get() && resize_lock_->GrabDeferredLock())
3209 can_lock_compositor_ = YES_DID_LOCK; 2902 can_lock_compositor_ = YES_DID_LOCK;
3210 } 2903 }
3211 RunOnCommitCallbacks(); 2904 RunOnCommitCallbacks();
3212 if (resize_lock_ && resize_lock_->expected_size() == current_frame_size_) { 2905 if (resize_lock_ &&
2906 resize_lock_->expected_size() == current_frame_size_in_dip_) {
3213 resize_lock_.reset(); 2907 resize_lock_.reset();
3214 host_->WasResized(); 2908 host_->WasResized();
3215 // We may have had a resize while we had the lock (e.g. if the lock expired, 2909 // We may have had a resize while we had the lock (e.g. if the lock expired,
3216 // or if the UI still gave us some resizes), so make sure we grab a new lock 2910 // or if the UI still gave us some resizes), so make sure we grab a new lock
3217 // if necessary. 2911 // if necessary.
3218 MaybeCreateResizeLock(); 2912 MaybeCreateResizeLock();
3219 } 2913 }
3220 } 2914 }
3221 2915
3222 void RenderWidgetHostViewAura::OnCompositingStarted( 2916 void RenderWidgetHostViewAura::OnCompositingStarted(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3297 2991
3298 void RenderWidgetHostViewAura::FatalAccessibilityTreeError() { 2992 void RenderWidgetHostViewAura::FatalAccessibilityTreeError() {
3299 host_->FatalAccessibilityTreeError(); 2993 host_->FatalAccessibilityTreeError();
3300 SetBrowserAccessibilityManager(NULL); 2994 SetBrowserAccessibilityManager(NULL);
3301 } 2995 }
3302 2996
3303 //////////////////////////////////////////////////////////////////////////////// 2997 ////////////////////////////////////////////////////////////////////////////////
3304 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation: 2998 // RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation:
3305 2999
3306 void RenderWidgetHostViewAura::OnLostResources() { 3000 void RenderWidgetHostViewAura::OnLostResources() {
3307 current_surface_ = NULL; 3001 if (frame_provider_.get())
3308 UpdateExternalTexture(); 3002 EvictDelegatedFrame();
3309
3310 idle_frame_subscriber_textures_.clear(); 3003 idle_frame_subscriber_textures_.clear();
3311 yuv_readback_pipeline_.reset(); 3004 yuv_readback_pipeline_.reset();
3312 3005
3313 // Make sure all ImageTransportClients are deleted now that the context those
3314 // are using is becoming invalid. This sends pending ACKs and needs to happen
3315 // after calling UpdateExternalTexture() which syncs with the impl thread.
3316 RunOnCommitCallbacks();
3317 host_->ScheduleComposite(); 3006 host_->ScheduleComposite();
3318 } 3007 }
3319 3008
3320 //////////////////////////////////////////////////////////////////////////////// 3009 ////////////////////////////////////////////////////////////////////////////////
3321 // RenderWidgetHostViewAura, private: 3010 // RenderWidgetHostViewAura, private:
3322 3011
3323 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { 3012 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
3324 if (touch_editing_client_) 3013 if (touch_editing_client_)
3325 touch_editing_client_->OnViewDestroyed(); 3014 touch_editing_client_->OnViewDestroyed();
3326 3015
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
3513 void RenderWidgetHostViewAura::AddedToRootWindow() { 3202 void RenderWidgetHostViewAura::AddedToRootWindow() {
3514 window_->GetHost()->AddObserver(this); 3203 window_->GetHost()->AddObserver(this);
3515 UpdateScreenInfo(window_); 3204 UpdateScreenInfo(window_);
3516 3205
3517 aura::client::CursorClient* cursor_client = 3206 aura::client::CursorClient* cursor_client =
3518 aura::client::GetCursorClient(window_->GetRootWindow()); 3207 aura::client::GetCursorClient(window_->GetRootWindow());
3519 if (cursor_client) { 3208 if (cursor_client) {
3520 cursor_client->AddObserver(this); 3209 cursor_client->AddObserver(this);
3521 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); 3210 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible());
3522 } 3211 }
3523 if (current_surface_.get())
3524 UpdateExternalTexture();
3525 if (HasFocus()) { 3212 if (HasFocus()) {
3526 ui::InputMethod* input_method = GetInputMethod(); 3213 ui::InputMethod* input_method = GetInputMethod();
3527 if (input_method) 3214 if (input_method)
3528 input_method->SetFocusedTextInputClient(this); 3215 input_method->SetFocusedTextInputClient(this);
3529 } 3216 }
3530 3217
3531 #if defined(OS_WIN) 3218 #if defined(OS_WIN)
3532 // The parent may have changed here. Ensure that the legacy window is 3219 // The parent may have changed here. Ensure that the legacy window is
3533 // reparented accordingly. 3220 // reparented accordingly.
3534 if (legacy_render_widget_host_HWND_) 3221 if (legacy_render_widget_host_HWND_)
(...skipping 11 matching lines...) Expand all
3546 3233
3547 void RenderWidgetHostViewAura::RemovingFromRootWindow() { 3234 void RenderWidgetHostViewAura::RemovingFromRootWindow() {
3548 aura::client::CursorClient* cursor_client = 3235 aura::client::CursorClient* cursor_client =
3549 aura::client::GetCursorClient(window_->GetRootWindow()); 3236 aura::client::GetCursorClient(window_->GetRootWindow());
3550 if (cursor_client) 3237 if (cursor_client)
3551 cursor_client->RemoveObserver(this); 3238 cursor_client->RemoveObserver(this);
3552 3239
3553 DetachFromInputMethod(); 3240 DetachFromInputMethod();
3554 3241
3555 window_->GetHost()->RemoveObserver(this); 3242 window_->GetHost()->RemoveObserver(this);
3556 ui::Compositor* compositor = GetCompositor();
3557 if (current_surface_.get()) {
3558 // We can't get notification for commits after this point, which would
3559 // guarantee that the compositor isn't using an old texture any more, so
3560 // instead we force the layer to stop using any external resources which
3561 // synchronizes with the compositor thread, and makes it safe to run the
3562 // callback.
3563 window_->layer()->SetShowPaintedContent();
3564 }
3565 RunOnCommitCallbacks(); 3243 RunOnCommitCallbacks();
3566 resize_lock_.reset(); 3244 resize_lock_.reset();
3567 host_->WasResized(); 3245 host_->WasResized();
3568 3246 ui::Compositor* compositor = GetCompositor();
3569 if (compositor && compositor->HasObserver(this)) 3247 if (compositor && compositor->HasObserver(this))
3570 compositor->RemoveObserver(this); 3248 compositor->RemoveObserver(this);
3571 3249
3572 #if defined(OS_WIN) 3250 #if defined(OS_WIN)
3573 // Update the legacy window's parent temporarily to the desktop window. It 3251 // Update the legacy window's parent temporarily to the desktop window. It
3574 // will eventually get reparented to the right root. 3252 // will eventually get reparented to the right root.
3575 if (legacy_render_widget_host_HWND_) 3253 if (legacy_render_widget_host_HWND_)
3576 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow()); 3254 legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow());
3577 #endif 3255 #endif
3578 3256
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3615 RenderWidgetHost* widget) { 3293 RenderWidgetHost* widget) {
3616 return new RenderWidgetHostViewAura(widget); 3294 return new RenderWidgetHostViewAura(widget);
3617 } 3295 }
3618 3296
3619 // static 3297 // static
3620 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 3298 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
3621 GetScreenInfoForWindow(results, NULL); 3299 GetScreenInfoForWindow(results, NULL);
3622 } 3300 }
3623 3301
3624 } // namespace content 3302 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698