| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "cc/compositor_frame.h" |
| 15 #include "cc/compositor_frame_ack.h" |
| 14 #include "content/browser/renderer_host/backing_store_aura.h" | 16 #include "content/browser/renderer_host/backing_store_aura.h" |
| 15 #include "content/browser/renderer_host/dip_util.h" | 17 #include "content/browser/renderer_host/dip_util.h" |
| 16 #include "content/browser/renderer_host/overscroll_controller.h" | 18 #include "content/browser/renderer_host/overscroll_controller.h" |
| 17 #include "content/browser/renderer_host/render_view_host_delegate.h" | 19 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 18 #include "content/browser/renderer_host/render_widget_host_impl.h" | 20 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 19 #include "content/browser/renderer_host/ui_events_helper.h" | 21 #include "content/browser/renderer_host/ui_events_helper.h" |
| 20 #include "content/browser/renderer_host/web_input_event_aura.h" | 22 #include "content/browser/renderer_host/web_input_event_aura.h" |
| 21 #include "content/common/gpu/client/gl_helper.h" | 23 #include "content/common/gpu/client/gl_helper.h" |
| 22 #include "content/common/gpu/gpu_messages.h" | 24 #include "content/common/gpu/gpu_messages.h" |
| 23 #include "content/common/view_messages.h" | 25 #include "content/common/view_messages.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 269 |
| 268 if (event.type() == ui::ET_GESTURE_BEGIN) { | 270 if (event.type() == ui::ET_GESTURE_BEGIN) { |
| 269 const ui::GestureEvent& gesture = | 271 const ui::GestureEvent& gesture = |
| 270 static_cast<const ui::GestureEvent&>(event); | 272 static_cast<const ui::GestureEvent&>(event); |
| 271 return gesture.details().touch_points() == 1; | 273 return gesture.details().touch_points() == 1; |
| 272 } | 274 } |
| 273 | 275 |
| 274 return false; | 276 return false; |
| 275 } | 277 } |
| 276 | 278 |
| 279 // Swap ack for the renderer when kCompositeToMailbox is enabled. |
| 280 void SendCompositorFrameAck( |
| 281 int32 route_id, |
| 282 int renderer_host_id, |
| 283 const cc::Mailbox& received_mailbox, |
| 284 const gfx::Size& received_size, |
| 285 bool skip_frame, |
| 286 const scoped_refptr<ui::Texture>& texture_to_produce) { |
| 287 cc::CompositorFrameAck ack; |
| 288 ack.gl_frame_data.reset(new cc::GLFrameData()); |
| 289 DCHECK(!texture_to_produce || !skip_frame); |
| 290 if (texture_to_produce) { |
| 291 std::string mailbox_name = texture_to_produce->Produce(); |
| 292 std::copy(mailbox_name.data(), |
| 293 mailbox_name.data() + mailbox_name.length(), |
| 294 reinterpret_cast<char*>(ack.gl_frame_data->mailbox.name)); |
| 295 ack.gl_frame_data->size = texture_to_produce->size(); |
| 296 ack.gl_frame_data->sync_point = |
| 297 content::ImageTransportFactory::GetInstance()->InsertSyncPoint(); |
| 298 } else if (skip_frame) { |
| 299 // Skip the frame, i.e. tell the producer to reuse the same buffer that |
| 300 // we just received. |
| 301 ack.gl_frame_data->size = received_size; |
| 302 ack.gl_frame_data->mailbox = received_mailbox; |
| 303 } |
| 304 |
| 305 RenderWidgetHostImpl::SendSwapCompositorFrameAck( |
| 306 route_id, renderer_host_id, ack); |
| 307 } |
| 308 |
| 309 void AcknowledgeBufferForGpu( |
| 310 int32 route_id, |
| 311 int gpu_host_id, |
| 312 const std::string& received_mailbox, |
| 313 bool skip_frame, |
| 314 const scoped_refptr<ui::Texture>& texture_to_produce) { |
| 315 AcceleratedSurfaceMsg_BufferPresented_Params ack; |
| 316 uint32 sync_point = 0; |
| 317 DCHECK(!texture_to_produce || !skip_frame); |
| 318 if (texture_to_produce) { |
| 319 ack.mailbox_name = texture_to_produce->Produce(); |
| 320 sync_point = |
| 321 content::ImageTransportFactory::GetInstance()->InsertSyncPoint(); |
| 322 } else if (skip_frame) { |
| 323 ack.mailbox_name = received_mailbox; |
| 324 ack.sync_point = 0; |
| 325 } |
| 326 |
| 327 ack.sync_point = sync_point; |
| 328 RenderWidgetHostImpl::AcknowledgeBufferPresent( |
| 329 route_id, gpu_host_id, ack); |
| 330 } |
| 331 |
| 277 } // namespace | 332 } // namespace |
| 278 | 333 |
| 279 // We need to watch for mouse events outside a Web Popup or its parent | 334 // We need to watch for mouse events outside a Web Popup or its parent |
| 280 // and dismiss the popup for certain events. | 335 // and dismiss the popup for certain events. |
| 281 class RenderWidgetHostViewAura::EventFilterForPopupExit : | 336 class RenderWidgetHostViewAura::EventFilterForPopupExit : |
| 282 public ui::EventHandler { | 337 public ui::EventHandler { |
| 283 public: | 338 public: |
| 284 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) | 339 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) |
| 285 : rwhva_(rwhva) { | 340 : rwhva_(rwhva) { |
| 286 DCHECK(rwhva_); | 341 DCHECK(rwhva_); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 private: | 569 private: |
| 515 aura::RootWindow* root_window_; | 570 aura::RootWindow* root_window_; |
| 516 gfx::Size new_size_; | 571 gfx::Size new_size_; |
| 517 scoped_refptr<ui::CompositorLock> compositor_lock_; | 572 scoped_refptr<ui::CompositorLock> compositor_lock_; |
| 518 base::WeakPtrFactory<ResizeLock> weak_ptr_factory_; | 573 base::WeakPtrFactory<ResizeLock> weak_ptr_factory_; |
| 519 bool defer_compositor_lock_; | 574 bool defer_compositor_lock_; |
| 520 | 575 |
| 521 DISALLOW_COPY_AND_ASSIGN(ResizeLock); | 576 DISALLOW_COPY_AND_ASSIGN(ResizeLock); |
| 522 }; | 577 }; |
| 523 | 578 |
| 524 RenderWidgetHostViewAura::BufferPresentedParams::BufferPresentedParams( | |
| 525 int route_id, | |
| 526 int gpu_host_id) | |
| 527 : route_id(route_id), | |
| 528 gpu_host_id(gpu_host_id) { | |
| 529 } | |
| 530 | |
| 531 RenderWidgetHostViewAura::BufferPresentedParams::~BufferPresentedParams() { | |
| 532 } | |
| 533 | |
| 534 //////////////////////////////////////////////////////////////////////////////// | 579 //////////////////////////////////////////////////////////////////////////////// |
| 535 // RenderWidgetHostViewAura, public: | 580 // RenderWidgetHostViewAura, public: |
| 536 | 581 |
| 537 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) | 582 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) |
| 538 : host_(RenderWidgetHostImpl::From(host)), | 583 : host_(RenderWidgetHostImpl::From(host)), |
| 539 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), | 584 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
| 540 in_shutdown_(false), | 585 in_shutdown_(false), |
| 541 is_fullscreen_(false), | 586 is_fullscreen_(false), |
| 542 popup_parent_host_view_(NULL), | 587 popup_parent_host_view_(NULL), |
| 543 popup_child_host_view_(NULL), | 588 popup_child_host_view_(NULL), |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 } else { | 1156 } else { |
| 1112 window_->SetExternalTexture(NULL); | 1157 window_->SetExternalTexture(NULL); |
| 1113 resize_locks_.clear(); | 1158 resize_locks_.clear(); |
| 1114 } | 1159 } |
| 1115 } | 1160 } |
| 1116 | 1161 |
| 1117 bool RenderWidgetHostViewAura::SwapBuffersPrepare( | 1162 bool RenderWidgetHostViewAura::SwapBuffersPrepare( |
| 1118 const gfx::Rect& surface_rect, | 1163 const gfx::Rect& surface_rect, |
| 1119 const gfx::Rect& damage_rect, | 1164 const gfx::Rect& damage_rect, |
| 1120 const std::string& mailbox_name, | 1165 const std::string& mailbox_name, |
| 1121 BufferPresentedParams* params) { | 1166 const BufferPresentedCallback& ack_callback) { |
| 1122 DCHECK(!mailbox_name.empty()); | |
| 1123 DCHECK(!params->texture_to_produce); | |
| 1124 | |
| 1125 if (last_swapped_surface_size_ != surface_rect.size()) { | 1167 if (last_swapped_surface_size_ != surface_rect.size()) { |
| 1126 // The surface could have shrunk since we skipped an update, in which | 1168 // The surface could have shrunk since we skipped an update, in which |
| 1127 // case we can expect a full update. | 1169 // case we can expect a full update. |
| 1128 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; | 1170 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; |
| 1129 skipped_damage_.setEmpty(); | 1171 skipped_damage_.setEmpty(); |
| 1130 last_swapped_surface_size_ = surface_rect.size(); | 1172 last_swapped_surface_size_ = surface_rect.size(); |
| 1131 } | 1173 } |
| 1132 | 1174 |
| 1133 if (ShouldSkipFrame(surface_rect.size())) { | 1175 if (ShouldSkipFrame(surface_rect.size()) || mailbox_name.empty()) { |
| 1134 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); | 1176 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); |
| 1135 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 1177 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
| 1136 ack_params.mailbox_name = mailbox_name; | |
| 1137 ack_params.sync_point = 0; | |
| 1138 RenderWidgetHostImpl::AcknowledgeBufferPresent( | |
| 1139 params->route_id, params->gpu_host_id, ack_params); | |
| 1140 return false; | 1178 return false; |
| 1141 } | 1179 } |
| 1142 | 1180 |
| 1143 params->texture_to_produce = current_surface_; | |
| 1144 | |
| 1145 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1181 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 1146 current_surface_ = factory->CreateTransportClient(device_scale_factor_); | 1182 current_surface_ = factory->CreateTransportClient(device_scale_factor_); |
| 1147 if (!current_surface_) { | 1183 if (!current_surface_) { |
| 1148 LOG(ERROR) << "Failed to create ImageTransport texture"; | 1184 LOG(ERROR) << "Failed to create ImageTransport texture"; |
| 1185 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
| 1149 return false; | 1186 return false; |
| 1150 } | 1187 } |
| 1151 | 1188 |
| 1152 current_surface_->Consume(mailbox_name, surface_rect.size()); | 1189 current_surface_->Consume(mailbox_name, surface_rect.size()); |
| 1153 released_front_lock_ = NULL; | 1190 released_front_lock_ = NULL; |
| 1154 UpdateExternalTexture(); | 1191 UpdateExternalTexture(); |
| 1155 | 1192 |
| 1156 return true; | 1193 return true; |
| 1157 } | 1194 } |
| 1158 | 1195 |
| 1159 void RenderWidgetHostViewAura::SwapBuffersCompleted( | 1196 void RenderWidgetHostViewAura::SwapBuffersCompleted( |
| 1160 const BufferPresentedParams& params) { | 1197 const BufferPresentedCallback& ack_callback, |
| 1198 const scoped_refptr<ui::Texture>& texture_to_return) { |
| 1161 ui::Compositor* compositor = GetCompositor(); | 1199 ui::Compositor* compositor = GetCompositor(); |
| 1162 if (!compositor) { | 1200 if (!compositor) { |
| 1163 InsertSyncPointAndACK(params); | 1201 ack_callback.Run(false, texture_to_return); |
| 1164 } else { | 1202 } else { |
| 1165 // Add sending an ACK to the list of things to do OnCompositingDidCommit | 1203 // Add sending an ACK to the list of things to do OnCompositingDidCommit |
| 1166 can_lock_compositor_ = NO_PENDING_COMMIT; | 1204 can_lock_compositor_ = NO_PENDING_COMMIT; |
| 1167 on_compositing_did_commit_callbacks_.push_back( | 1205 on_compositing_did_commit_callbacks_.push_back( |
| 1168 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK, params)); | 1206 base::Bind(ack_callback, false, texture_to_return)); |
| 1169 if (!compositor->HasObserver(this)) | 1207 if (!compositor->HasObserver(this)) |
| 1170 compositor->AddObserver(this); | 1208 compositor->AddObserver(this); |
| 1171 } | 1209 } |
| 1172 } | 1210 } |
| 1173 | 1211 |
| 1174 #if defined(OS_WIN) | 1212 #if defined(OS_WIN) |
| 1175 void RenderWidgetHostViewAura::UpdateTransientRects( | 1213 void RenderWidgetHostViewAura::UpdateTransientRects( |
| 1176 const std::vector<gfx::Rect>& rects) { | 1214 const std::vector<gfx::Rect>& rects) { |
| 1177 transient_rects_ = rects; | 1215 transient_rects_ = rects; |
| 1178 UpdateCutoutRects(); | 1216 UpdateCutoutRects(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1196 constrained_rects_.end()); | 1234 constrained_rects_.end()); |
| 1197 params.geometry = &plugin_window_moves_; | 1235 params.geometry = &plugin_window_moves_; |
| 1198 LPARAM lparam = reinterpret_cast<LPARAM>(¶ms); | 1236 LPARAM lparam = reinterpret_cast<LPARAM>(¶ms); |
| 1199 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); | 1237 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); |
| 1200 } | 1238 } |
| 1201 #endif | 1239 #endif |
| 1202 | 1240 |
| 1203 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | 1241 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
| 1204 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, | 1242 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, |
| 1205 int gpu_host_id) { | 1243 int gpu_host_id) { |
| 1206 const gfx::Rect surface_rect = gfx::Rect(gfx::Point(), params_in_pixel.size); | 1244 BufferPresentedCallback ack_callback = base::Bind( |
| 1207 BufferPresentedParams ack_params(params_in_pixel.route_id, gpu_host_id); | 1245 &AcknowledgeBufferForGpu, |
| 1246 params_in_pixel.route_id, |
| 1247 gpu_host_id, |
| 1248 params_in_pixel.mailbox_name); |
| 1249 BuffersSwapped( |
| 1250 params_in_pixel.size, params_in_pixel.mailbox_name, ack_callback); |
| 1251 } |
| 1252 |
| 1253 void RenderWidgetHostViewAura::OnSwapCompositorFrame( |
| 1254 const cc::CompositorFrame& frame, int render_host_id, int route_id) { |
| 1255 if (!frame.gl_frame_data || frame.gl_frame_data->mailbox.isZero()) |
| 1256 return; |
| 1257 |
| 1258 BufferPresentedCallback ack_callback = base::Bind( |
| 1259 &SendCompositorFrameAck, route_id, render_host_id, |
| 1260 frame.gl_frame_data->mailbox, frame.gl_frame_data->size); |
| 1261 |
| 1262 if (!frame.gl_frame_data->sync_point) { |
| 1263 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; |
| 1264 ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
| 1265 return; |
| 1266 } |
| 1267 |
| 1268 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 1269 factory->WaitSyncPoint(frame.gl_frame_data->sync_point); |
| 1270 |
| 1271 std::string mailbox_name( |
| 1272 reinterpret_cast<const char*>(frame.gl_frame_data->mailbox.name), |
| 1273 sizeof(frame.gl_frame_data->mailbox.name)); |
| 1274 BuffersSwapped( |
| 1275 frame.gl_frame_data->size, mailbox_name, ack_callback); |
| 1276 } |
| 1277 |
| 1278 void RenderWidgetHostViewAura::BuffersSwapped( |
| 1279 const gfx::Size& size, |
| 1280 const std::string& mailbox_name, |
| 1281 const BufferPresentedCallback& ack_callback) { |
| 1282 scoped_refptr<ui::Texture> texture_to_return(current_surface_); |
| 1283 const gfx::Rect surface_rect = gfx::Rect(gfx::Point(), size); |
| 1208 if (!SwapBuffersPrepare( | 1284 if (!SwapBuffersPrepare( |
| 1209 surface_rect, surface_rect, params_in_pixel.mailbox_name, &ack_params)) | 1285 surface_rect, surface_rect, mailbox_name, ack_callback)) { |
| 1210 return; | 1286 return; |
| 1287 } |
| 1211 | 1288 |
| 1212 previous_damage_.setRect(RectToSkIRect(surface_rect)); | 1289 previous_damage_.setRect(RectToSkIRect(surface_rect)); |
| 1213 skipped_damage_.setEmpty(); | 1290 skipped_damage_.setEmpty(); |
| 1214 | 1291 |
| 1215 ui::Compositor* compositor = GetCompositor(); | 1292 ui::Compositor* compositor = GetCompositor(); |
| 1216 if (compositor) { | 1293 if (compositor) { |
| 1217 gfx::Size surface_size = ConvertSizeToDIP(this, params_in_pixel.size); | 1294 gfx::Size surface_size = ConvertSizeToDIP(this, size); |
| 1218 window_->SchedulePaintInRect(gfx::Rect(surface_size)); | 1295 window_->SchedulePaintInRect(gfx::Rect(surface_size)); |
| 1219 } | 1296 } |
| 1220 | 1297 |
| 1221 if (paint_observer_) | 1298 if (paint_observer_) |
| 1222 paint_observer_->OnUpdateCompositorContent(); | 1299 paint_observer_->OnUpdateCompositorContent(); |
| 1223 SwapBuffersCompleted(ack_params); | 1300 |
| 1301 SwapBuffersCompleted(ack_callback, texture_to_return); |
| 1224 } | 1302 } |
| 1225 | 1303 |
| 1226 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | 1304 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
| 1227 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | 1305 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
| 1228 int gpu_host_id) { | 1306 int gpu_host_id) { |
| 1307 scoped_refptr<ui::Texture> previous_texture(current_surface_); |
| 1229 const gfx::Rect surface_rect = | 1308 const gfx::Rect surface_rect = |
| 1230 gfx::Rect(gfx::Point(), params_in_pixel.surface_size); | 1309 gfx::Rect(gfx::Point(), params_in_pixel.surface_size); |
| 1231 gfx::Rect damage_rect(params_in_pixel.x, | 1310 gfx::Rect damage_rect(params_in_pixel.x, |
| 1232 params_in_pixel.y, | 1311 params_in_pixel.y, |
| 1233 params_in_pixel.width, | 1312 params_in_pixel.width, |
| 1234 params_in_pixel.height); | 1313 params_in_pixel.height); |
| 1235 BufferPresentedParams ack_params(params_in_pixel.route_id, gpu_host_id); | 1314 BufferPresentedCallback ack_callback = base::Bind( |
| 1315 &AcknowledgeBufferForGpu, params_in_pixel.route_id, gpu_host_id, |
| 1316 params_in_pixel.mailbox_name); |
| 1317 |
| 1236 if (!SwapBuffersPrepare( | 1318 if (!SwapBuffersPrepare( |
| 1237 surface_rect, damage_rect, params_in_pixel.mailbox_name, &ack_params)) | 1319 surface_rect, damage_rect, params_in_pixel.mailbox_name, ack_callback)) { |
| 1238 return; | 1320 return; |
| 1321 } |
| 1239 | 1322 |
| 1240 SkRegion damage(RectToSkIRect(damage_rect)); | 1323 SkRegion damage(RectToSkIRect(damage_rect)); |
| 1241 if (!skipped_damage_.isEmpty()) { | 1324 if (!skipped_damage_.isEmpty()) { |
| 1242 damage.op(skipped_damage_, SkRegion::kUnion_Op); | 1325 damage.op(skipped_damage_, SkRegion::kUnion_Op); |
| 1243 skipped_damage_.setEmpty(); | 1326 skipped_damage_.setEmpty(); |
| 1244 } | 1327 } |
| 1245 | 1328 |
| 1246 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds()))); | 1329 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds()))); |
| 1247 ui::Texture* current_texture = current_surface_.get(); | 1330 ui::Texture* current_texture = current_surface_.get(); |
| 1248 | 1331 |
| 1249 const gfx::Size surface_size_in_pixel = params_in_pixel.surface_size; | 1332 const gfx::Size surface_size_in_pixel = params_in_pixel.surface_size; |
| 1250 DLOG_IF(ERROR, ack_params.texture_to_produce && | 1333 DLOG_IF(ERROR, previous_texture && |
| 1251 ack_params.texture_to_produce->size() != current_texture->size() && | 1334 previous_texture->size() != current_texture->size() && |
| 1252 SkIRectToRect(damage.getBounds()) != surface_rect) << | 1335 SkIRectToRect(damage.getBounds()) != surface_rect) << |
| 1253 "Expected full damage rect after size change"; | 1336 "Expected full damage rect after size change"; |
| 1254 if (ack_params.texture_to_produce && !previous_damage_.isEmpty() && | 1337 if (previous_texture && !previous_damage_.isEmpty() && |
| 1255 ack_params.texture_to_produce->size() == current_texture->size()) { | 1338 previous_texture->size() == current_texture->size()) { |
| 1256 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1339 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 1257 GLHelper* gl_helper = factory->GetGLHelper(); | 1340 GLHelper* gl_helper = factory->GetGLHelper(); |
| 1258 gl_helper->CopySubBufferDamage( | 1341 gl_helper->CopySubBufferDamage( |
| 1259 current_texture->PrepareTexture(), | 1342 current_texture->PrepareTexture(), |
| 1260 ack_params.texture_to_produce->PrepareTexture(), | 1343 previous_texture->PrepareTexture(), |
| 1261 damage, | 1344 damage, |
| 1262 previous_damage_); | 1345 previous_damage_); |
| 1263 } | 1346 } |
| 1264 previous_damage_ = damage; | 1347 previous_damage_ = damage; |
| 1265 | 1348 |
| 1266 ui::Compositor* compositor = GetCompositor(); | 1349 ui::Compositor* compositor = GetCompositor(); |
| 1267 if (compositor) { | 1350 if (compositor) { |
| 1268 // Co-ordinates come in OpenGL co-ordinate space. | 1351 // Co-ordinates come in OpenGL co-ordinate space. |
| 1269 // We need to convert to layer space. | 1352 // We need to convert to layer space. |
| 1270 gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect( | 1353 gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect( |
| 1271 params_in_pixel.x, | 1354 params_in_pixel.x, |
| 1272 surface_size_in_pixel.height() - params_in_pixel.y - | 1355 surface_size_in_pixel.height() - params_in_pixel.y - |
| 1273 params_in_pixel.height, | 1356 params_in_pixel.height, |
| 1274 params_in_pixel.width, | 1357 params_in_pixel.width, |
| 1275 params_in_pixel.height)); | 1358 params_in_pixel.height)); |
| 1276 | 1359 |
| 1277 // Damage may not have been DIP aligned, so inflate damage to compensate | 1360 // Damage may not have been DIP aligned, so inflate damage to compensate |
| 1278 // for any round-off error. | 1361 // for any round-off error. |
| 1279 rect_to_paint.Inset(-1, -1); | 1362 rect_to_paint.Inset(-1, -1); |
| 1280 rect_to_paint.Intersect(window_->bounds()); | 1363 rect_to_paint.Intersect(window_->bounds()); |
| 1281 | 1364 |
| 1282 if (paint_observer_) | 1365 if (paint_observer_) |
| 1283 paint_observer_->OnUpdateCompositorContent(); | 1366 paint_observer_->OnUpdateCompositorContent(); |
| 1284 window_->SchedulePaintInRect(rect_to_paint); | 1367 window_->SchedulePaintInRect(rect_to_paint); |
| 1285 } | 1368 } |
| 1286 | 1369 |
| 1287 SwapBuffersCompleted(ack_params); | 1370 SwapBuffersCompleted(ack_callback, previous_texture); |
| 1288 } | 1371 } |
| 1289 | 1372 |
| 1290 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { | 1373 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { |
| 1291 } | 1374 } |
| 1292 | 1375 |
| 1293 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { | 1376 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { |
| 1294 // This really tells us to release the frontbuffer. | 1377 // This really tells us to release the frontbuffer. |
| 1295 if (current_surface_) { | 1378 if (current_surface_) { |
| 1296 ui::Compositor* compositor = GetCompositor(); | 1379 ui::Compositor* compositor = GetCompositor(); |
| 1297 if (compositor) { | 1380 if (compositor) { |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2301 | 2384 |
| 2302 void RenderWidgetHostViewAura::RunCompositingDidCommitCallbacks() { | 2385 void RenderWidgetHostViewAura::RunCompositingDidCommitCallbacks() { |
| 2303 for (std::vector<base::Closure>::const_iterator | 2386 for (std::vector<base::Closure>::const_iterator |
| 2304 it = on_compositing_did_commit_callbacks_.begin(); | 2387 it = on_compositing_did_commit_callbacks_.begin(); |
| 2305 it != on_compositing_did_commit_callbacks_.end(); ++it) { | 2388 it != on_compositing_did_commit_callbacks_.end(); ++it) { |
| 2306 it->Run(); | 2389 it->Run(); |
| 2307 } | 2390 } |
| 2308 on_compositing_did_commit_callbacks_.clear(); | 2391 on_compositing_did_commit_callbacks_.clear(); |
| 2309 } | 2392 } |
| 2310 | 2393 |
| 2311 // static | |
| 2312 void RenderWidgetHostViewAura::InsertSyncPointAndACK( | |
| 2313 const BufferPresentedParams& params) { | |
| 2314 uint32 sync_point = 0; | |
| 2315 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | |
| 2316 | |
| 2317 // If we produced a texture, we have to synchronize with the consumer of | |
| 2318 // that texture. | |
| 2319 if (params.texture_to_produce) { | |
| 2320 ack_params.mailbox_name = params.texture_to_produce->Produce(); | |
| 2321 sync_point = ImageTransportFactory::GetInstance()->InsertSyncPoint(); | |
| 2322 } | |
| 2323 | |
| 2324 ack_params.sync_point = sync_point; | |
| 2325 RenderWidgetHostImpl::AcknowledgeBufferPresent( | |
| 2326 params.route_id, params.gpu_host_id, ack_params); | |
| 2327 } | |
| 2328 | |
| 2329 void RenderWidgetHostViewAura::AddedToRootWindow() { | 2394 void RenderWidgetHostViewAura::AddedToRootWindow() { |
| 2330 window_->GetRootWindow()->AddRootWindowObserver(this); | 2395 window_->GetRootWindow()->AddRootWindowObserver(this); |
| 2331 host_->ParentChanged(GetNativeViewId()); | 2396 host_->ParentChanged(GetNativeViewId()); |
| 2332 UpdateScreenInfo(window_); | 2397 UpdateScreenInfo(window_); |
| 2333 if (popup_type_ != WebKit::WebPopupTypeNone) | 2398 if (popup_type_ != WebKit::WebPopupTypeNone) |
| 2334 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); | 2399 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); |
| 2335 } | 2400 } |
| 2336 | 2401 |
| 2337 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 2402 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
| 2338 event_filter_for_popup_exit_.reset(); | 2403 event_filter_for_popup_exit_.reset(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2371 RenderWidgetHost* widget) { | 2436 RenderWidgetHost* widget) { |
| 2372 return new RenderWidgetHostViewAura(widget); | 2437 return new RenderWidgetHostViewAura(widget); |
| 2373 } | 2438 } |
| 2374 | 2439 |
| 2375 // static | 2440 // static |
| 2376 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 2441 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2377 GetScreenInfoForWindow(results, NULL); | 2442 GetScreenInfoForWindow(results, NULL); |
| 2378 } | 2443 } |
| 2379 | 2444 |
| 2380 } // namespace content | 2445 } // namespace content |
| OLD | NEW |