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 scoped_refptr<ui::Texture>& texture_to_produce) { | |
284 cc::CompositorFrameAck ack; | |
285 ack.gl_frame_data.reset(new cc::GLFrameData()); | |
286 // If we produced a texture, we have to synchronize with the consumer of | |
287 // that texture. | |
288 if (texture_to_produce) { | |
289 std::string mailbox_name = texture_to_produce->Produce(); | |
290 std::copy(mailbox_name.data(), | |
291 mailbox_name.data() + mailbox_name.length(), | |
292 reinterpret_cast<char*>(ack.gl_frame_data->mailbox.name)); | |
293 ack.gl_frame_data->size = texture_to_produce->size(); | |
294 ack.gl_frame_data->sync_point = | |
295 content::ImageTransportFactory::GetInstance()->InsertSyncPoint(); | |
296 } | |
297 | |
298 RenderWidgetHostImpl::SendSwapCompositorFrameAck( | |
299 route_id, renderer_host_id, ack); | |
300 } | |
301 | |
302 // Tells the producer to reuse the same buffer that it previously pushed | |
303 // into the mailbox, because we are skipping this frame. | |
304 void SkipAndSendCompositorFrameAck( | |
305 int32 route_id, | |
306 int renderer_host_id, | |
307 const cc::CompositorFrame& frame) { | |
308 DCHECK(!frame.gl_frame_data->mailbox.isZero()); | |
309 cc::CompositorFrameAck ack; | |
310 ack.gl_frame_data.reset(new cc::GLFrameData()); | |
311 ack.gl_frame_data->mailbox = frame.gl_frame_data->mailbox; | |
312 RenderWidgetHostImpl::SendSwapCompositorFrameAck( | |
313 route_id, renderer_host_id, ack); | |
314 } | |
315 | |
316 void AcknowledgeBufferForGpu( | |
317 int32 route_id, | |
318 int gpu_host_id, | |
319 const scoped_refptr<ui::Texture>& texture_to_produce) { | |
320 AcceleratedSurfaceMsg_BufferPresented_Params ack; | |
321 // If we produced a texture, we have to synchronize with the consumer of | |
322 // that texture. | |
323 uint32 sync_point = 0; | |
324 if (texture_to_produce) { | |
325 ack.mailbox_name = texture_to_produce->Produce(); | |
326 sync_point = | |
327 content::ImageTransportFactory::GetInstance()->InsertSyncPoint(); | |
328 } | |
329 | |
330 ack.sync_point = sync_point; | |
331 RenderWidgetHostImpl::AcknowledgeBufferPresent( | |
332 route_id, gpu_host_id, ack); | |
333 } | |
334 | |
335 void AcknowledgeSkippedBufferForGpu( | |
336 int32 route_id, | |
337 int gpu_host_id, | |
338 const std::string& mailbox_name) { | |
339 DCHECK(!mailbox_name.empty()); | |
340 AcceleratedSurfaceMsg_BufferPresented_Params ack; | |
341 ack.mailbox_name = mailbox_name; | |
342 ack.sync_point = 0; | |
343 RenderWidgetHostImpl::AcknowledgeBufferPresent( | |
344 route_id, gpu_host_id, ack); | |
345 } | |
piman
2013/02/27 01:07:13
I /think/ those 4 functions could be factored into
no sievers
2013/02/27 21:07:40
Done.
| |
346 | |
277 } // namespace | 347 } // namespace |
278 | 348 |
279 // We need to watch for mouse events outside a Web Popup or its parent | 349 // We need to watch for mouse events outside a Web Popup or its parent |
280 // and dismiss the popup for certain events. | 350 // and dismiss the popup for certain events. |
281 class RenderWidgetHostViewAura::EventFilterForPopupExit : | 351 class RenderWidgetHostViewAura::EventFilterForPopupExit : |
282 public ui::EventHandler { | 352 public ui::EventHandler { |
283 public: | 353 public: |
284 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) | 354 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) |
285 : rwhva_(rwhva) { | 355 : rwhva_(rwhva) { |
286 DCHECK(rwhva_); | 356 DCHECK(rwhva_); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 private: | 584 private: |
515 aura::RootWindow* root_window_; | 585 aura::RootWindow* root_window_; |
516 gfx::Size new_size_; | 586 gfx::Size new_size_; |
517 scoped_refptr<ui::CompositorLock> compositor_lock_; | 587 scoped_refptr<ui::CompositorLock> compositor_lock_; |
518 base::WeakPtrFactory<ResizeLock> weak_ptr_factory_; | 588 base::WeakPtrFactory<ResizeLock> weak_ptr_factory_; |
519 bool defer_compositor_lock_; | 589 bool defer_compositor_lock_; |
520 | 590 |
521 DISALLOW_COPY_AND_ASSIGN(ResizeLock); | 591 DISALLOW_COPY_AND_ASSIGN(ResizeLock); |
522 }; | 592 }; |
523 | 593 |
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 //////////////////////////////////////////////////////////////////////////////// | 594 //////////////////////////////////////////////////////////////////////////////// |
535 // RenderWidgetHostViewAura, public: | 595 // RenderWidgetHostViewAura, public: |
536 | 596 |
537 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) | 597 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) |
538 : host_(RenderWidgetHostImpl::From(host)), | 598 : host_(RenderWidgetHostImpl::From(host)), |
539 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), | 599 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
540 in_shutdown_(false), | 600 in_shutdown_(false), |
541 is_fullscreen_(false), | 601 is_fullscreen_(false), |
542 popup_parent_host_view_(NULL), | 602 popup_parent_host_view_(NULL), |
543 popup_child_host_view_(NULL), | 603 popup_child_host_view_(NULL), |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1110 } | 1170 } |
1111 } else { | 1171 } else { |
1112 window_->SetExternalTexture(NULL); | 1172 window_->SetExternalTexture(NULL); |
1113 resize_locks_.clear(); | 1173 resize_locks_.clear(); |
1114 } | 1174 } |
1115 } | 1175 } |
1116 | 1176 |
1117 bool RenderWidgetHostViewAura::SwapBuffersPrepare( | 1177 bool RenderWidgetHostViewAura::SwapBuffersPrepare( |
1118 const gfx::Rect& surface_rect, | 1178 const gfx::Rect& surface_rect, |
1119 const gfx::Rect& damage_rect, | 1179 const gfx::Rect& damage_rect, |
1120 const std::string& mailbox_name, | 1180 const std::string& mailbox_name) { |
1121 BufferPresentedParams* params) { | |
1122 DCHECK(!mailbox_name.empty()); | 1181 DCHECK(!mailbox_name.empty()); |
1123 DCHECK(!params->texture_to_produce); | |
1124 | 1182 |
1125 if (last_swapped_surface_size_ != surface_rect.size()) { | 1183 if (last_swapped_surface_size_ != surface_rect.size()) { |
1126 // The surface could have shrunk since we skipped an update, in which | 1184 // The surface could have shrunk since we skipped an update, in which |
1127 // case we can expect a full update. | 1185 // case we can expect a full update. |
1128 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; | 1186 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; |
1129 skipped_damage_.setEmpty(); | 1187 skipped_damage_.setEmpty(); |
1130 last_swapped_surface_size_ = surface_rect.size(); | 1188 last_swapped_surface_size_ = surface_rect.size(); |
1131 } | 1189 } |
1132 | 1190 |
1133 if (ShouldSkipFrame(surface_rect.size())) { | 1191 if (ShouldSkipFrame(surface_rect.size())) { |
1134 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); | 1192 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); |
1135 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | |
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; | 1193 return false; |
1141 } | 1194 } |
1142 | 1195 |
1143 params->texture_to_produce = current_surface_; | |
1144 | |
1145 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1196 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
1146 current_surface_ = factory->CreateTransportClient(device_scale_factor_); | 1197 current_surface_ = factory->CreateTransportClient(device_scale_factor_); |
1147 if (!current_surface_) { | 1198 if (!current_surface_) { |
1148 LOG(ERROR) << "Failed to create ImageTransport texture"; | 1199 LOG(ERROR) << "Failed to create ImageTransport texture"; |
1149 return false; | 1200 return false; |
1150 } | 1201 } |
1151 | 1202 |
1152 current_surface_->Consume(mailbox_name, surface_rect.size()); | 1203 current_surface_->Consume(mailbox_name, surface_rect.size()); |
1153 released_front_lock_ = NULL; | 1204 released_front_lock_ = NULL; |
1154 UpdateExternalTexture(); | 1205 UpdateExternalTexture(); |
1155 | 1206 |
1156 return true; | 1207 return true; |
1157 } | 1208 } |
1158 | 1209 |
1159 void RenderWidgetHostViewAura::SwapBuffersCompleted( | 1210 void RenderWidgetHostViewAura::SwapBuffersCompleted( |
1160 const BufferPresentedParams& params) { | 1211 const BufferPresentedCallback& ack_callback, |
1212 const scoped_refptr<ui::Texture>& texture_to_return) { | |
piman
2013/02/27 01:07:13
nit:indent
no sievers
2013/02/27 21:07:40
Done.
| |
1161 ui::Compositor* compositor = GetCompositor(); | 1213 ui::Compositor* compositor = GetCompositor(); |
1162 if (!compositor) { | 1214 if (!compositor) { |
1163 InsertSyncPointAndACK(params); | 1215 ack_callback.Run(texture_to_return); |
1164 } else { | 1216 } else { |
1165 // Add sending an ACK to the list of things to do OnCompositingDidCommit | 1217 // Add sending an ACK to the list of things to do OnCompositingDidCommit |
1166 can_lock_compositor_ = NO_PENDING_COMMIT; | 1218 can_lock_compositor_ = NO_PENDING_COMMIT; |
1167 on_compositing_did_commit_callbacks_.push_back( | 1219 on_compositing_did_commit_callbacks_.push_back( |
1168 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK, params)); | 1220 base::Bind(ack_callback, texture_to_return)); |
1169 if (!compositor->HasObserver(this)) | 1221 if (!compositor->HasObserver(this)) |
1170 compositor->AddObserver(this); | 1222 compositor->AddObserver(this); |
1171 } | 1223 } |
1172 } | 1224 } |
1173 | 1225 |
1174 #if defined(OS_WIN) | 1226 #if defined(OS_WIN) |
1175 void RenderWidgetHostViewAura::UpdateTransientRects( | 1227 void RenderWidgetHostViewAura::UpdateTransientRects( |
1176 const std::vector<gfx::Rect>& rects) { | 1228 const std::vector<gfx::Rect>& rects) { |
1177 transient_rects_ = rects; | 1229 transient_rects_ = rects; |
1178 UpdateCutoutRects(); | 1230 UpdateCutoutRects(); |
(...skipping 17 matching lines...) Expand all Loading... | |
1196 constrained_rects_.end()); | 1248 constrained_rects_.end()); |
1197 params.geometry = &plugin_window_moves_; | 1249 params.geometry = &plugin_window_moves_; |
1198 LPARAM lparam = reinterpret_cast<LPARAM>(¶ms); | 1250 LPARAM lparam = reinterpret_cast<LPARAM>(¶ms); |
1199 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); | 1251 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); |
1200 } | 1252 } |
1201 #endif | 1253 #endif |
1202 | 1254 |
1203 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( | 1255 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
1204 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, | 1256 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, |
1205 int gpu_host_id) { | 1257 int gpu_host_id) { |
1206 const gfx::Rect surface_rect = gfx::Rect(gfx::Point(), params_in_pixel.size); | 1258 BufferPresentedCallback ack_callback = base::Bind( |
1207 BufferPresentedParams ack_params(params_in_pixel.route_id, gpu_host_id); | 1259 &AcknowledgeBufferForGpu, params_in_pixel.route_id, gpu_host_id); |
1208 if (!SwapBuffersPrepare( | 1260 if (!BuffersSwapped(params_in_pixel.size, params_in_pixel.mailbox_name, |
1209 surface_rect, surface_rect, params_in_pixel.mailbox_name, &ack_params)) | 1261 ack_callback)) { |
1262 AcknowledgeSkippedBufferForGpu(params_in_pixel.route_id, | |
1263 gpu_host_id, | |
1264 params_in_pixel.mailbox_name); | |
1265 } | |
1266 } | |
1267 | |
1268 void RenderWidgetHostViewAura::OnSwapCompositorFrame( | |
1269 const cc::CompositorFrame& frame, int render_host_id, int route_id) { | |
1270 if (!frame.gl_frame_data) | |
1210 return; | 1271 return; |
1211 | 1272 |
1273 DCHECK(!frame.gl_frame_data->size.IsEmpty()); | |
1274 DCHECK(!frame.gl_frame_data->mailbox.isZero()); | |
1275 DCHECK(frame.gl_frame_data->sync_point); | |
piman
2013/02/27 01:07:13
note: all these DCHECKs are based on untrusted dat
no sievers
2013/02/27 21:07:40
Done.
| |
1276 | |
1277 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | |
1278 factory->WaitSyncPoint(frame.gl_frame_data->sync_point); | |
1279 | |
1280 BufferPresentedCallback ack_callback = base::Bind( | |
1281 &SendCompositorFrameAck, route_id, render_host_id); | |
1282 | |
1283 std::string mailbox_name( | |
1284 reinterpret_cast<const char*>(frame.gl_frame_data->mailbox.name), | |
1285 sizeof(frame.gl_frame_data->mailbox.name)); | |
1286 if (!BuffersSwapped(frame.gl_frame_data->size, | |
1287 mailbox_name, | |
1288 ack_callback)) { | |
1289 SkipAndSendCompositorFrameAck(route_id, render_host_id, frame); | |
1290 } | |
1291 } | |
1292 | |
1293 bool RenderWidgetHostViewAura::BuffersSwapped( | |
1294 const gfx::Size& size, | |
1295 const std::string& mailbox_name, | |
1296 const BufferPresentedCallback& ack_callback) { | |
1297 scoped_refptr<ui::Texture> texture_to_return(current_surface_); | |
1298 const gfx::Rect surface_rect = gfx::Rect(gfx::Point(), size); | |
1299 if (!SwapBuffersPrepare(surface_rect, surface_rect, mailbox_name)) | |
1300 return false; | |
1301 | |
1212 previous_damage_.setRect(RectToSkIRect(surface_rect)); | 1302 previous_damage_.setRect(RectToSkIRect(surface_rect)); |
1213 skipped_damage_.setEmpty(); | 1303 skipped_damage_.setEmpty(); |
1214 | 1304 |
1215 ui::Compositor* compositor = GetCompositor(); | 1305 ui::Compositor* compositor = GetCompositor(); |
1216 if (compositor) { | 1306 if (compositor) { |
1217 gfx::Size surface_size = ConvertSizeToDIP(this, params_in_pixel.size); | 1307 gfx::Size surface_size = ConvertSizeToDIP(this, size); |
1218 window_->SchedulePaintInRect(gfx::Rect(surface_size)); | 1308 window_->SchedulePaintInRect(gfx::Rect(surface_size)); |
1219 } | 1309 } |
1220 | 1310 |
1221 if (paint_observer_) | 1311 if (paint_observer_) |
1222 paint_observer_->OnUpdateCompositorContent(); | 1312 paint_observer_->OnUpdateCompositorContent(); |
1223 SwapBuffersCompleted(ack_params); | 1313 |
1314 SwapBuffersCompleted(ack_callback, texture_to_return); | |
1315 | |
1316 return true; | |
1224 } | 1317 } |
1225 | 1318 |
1226 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( | 1319 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
1227 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, | 1320 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, |
1228 int gpu_host_id) { | 1321 int gpu_host_id) { |
1322 scoped_refptr<ui::Texture> previous_texture(current_surface_); | |
1229 const gfx::Rect surface_rect = | 1323 const gfx::Rect surface_rect = |
1230 gfx::Rect(gfx::Point(), params_in_pixel.surface_size); | 1324 gfx::Rect(gfx::Point(), params_in_pixel.surface_size); |
1231 gfx::Rect damage_rect(params_in_pixel.x, | 1325 gfx::Rect damage_rect(params_in_pixel.x, |
1232 params_in_pixel.y, | 1326 params_in_pixel.y, |
1233 params_in_pixel.width, | 1327 params_in_pixel.width, |
1234 params_in_pixel.height); | 1328 params_in_pixel.height); |
1235 BufferPresentedParams ack_params(params_in_pixel.route_id, gpu_host_id); | |
1236 if (!SwapBuffersPrepare( | 1329 if (!SwapBuffersPrepare( |
1237 surface_rect, damage_rect, params_in_pixel.mailbox_name, &ack_params)) | 1330 surface_rect, damage_rect, params_in_pixel.mailbox_name)) { |
1331 AcknowledgeSkippedBufferForGpu(params_in_pixel.route_id, | |
1332 gpu_host_id, | |
1333 params_in_pixel.mailbox_name); | |
1238 return; | 1334 return; |
1335 } | |
1336 | |
1337 BufferPresentedCallback ack_callback = base::Bind( | |
1338 &AcknowledgeBufferForGpu, params_in_pixel.route_id, gpu_host_id); | |
1239 | 1339 |
1240 SkRegion damage(RectToSkIRect(damage_rect)); | 1340 SkRegion damage(RectToSkIRect(damage_rect)); |
1241 if (!skipped_damage_.isEmpty()) { | 1341 if (!skipped_damage_.isEmpty()) { |
1242 damage.op(skipped_damage_, SkRegion::kUnion_Op); | 1342 damage.op(skipped_damage_, SkRegion::kUnion_Op); |
1243 skipped_damage_.setEmpty(); | 1343 skipped_damage_.setEmpty(); |
1244 } | 1344 } |
1245 | 1345 |
1246 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds()))); | 1346 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds()))); |
1247 ui::Texture* current_texture = current_surface_.get(); | 1347 ui::Texture* current_texture = current_surface_.get(); |
1248 | 1348 |
1249 const gfx::Size surface_size_in_pixel = params_in_pixel.surface_size; | 1349 const gfx::Size surface_size_in_pixel = params_in_pixel.surface_size; |
1250 DLOG_IF(ERROR, ack_params.texture_to_produce && | 1350 DLOG_IF(ERROR, previous_texture && |
1251 ack_params.texture_to_produce->size() != current_texture->size() && | 1351 previous_texture->size() != current_texture->size() && |
1252 SkIRectToRect(damage.getBounds()) != surface_rect) << | 1352 SkIRectToRect(damage.getBounds()) != surface_rect) << |
1253 "Expected full damage rect after size change"; | 1353 "Expected full damage rect after size change"; |
1254 if (ack_params.texture_to_produce && !previous_damage_.isEmpty() && | 1354 if (previous_texture && !previous_damage_.isEmpty() && |
1255 ack_params.texture_to_produce->size() == current_texture->size()) { | 1355 previous_texture->size() == current_texture->size()) { |
1256 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1356 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
1257 GLHelper* gl_helper = factory->GetGLHelper(); | 1357 GLHelper* gl_helper = factory->GetGLHelper(); |
1258 gl_helper->CopySubBufferDamage( | 1358 gl_helper->CopySubBufferDamage( |
1259 current_texture->PrepareTexture(), | 1359 current_texture->PrepareTexture(), |
1260 ack_params.texture_to_produce->PrepareTexture(), | 1360 previous_texture->PrepareTexture(), |
1261 damage, | 1361 damage, |
1262 previous_damage_); | 1362 previous_damage_); |
1263 } | 1363 } |
1264 previous_damage_ = damage; | 1364 previous_damage_ = damage; |
1265 | 1365 |
1266 ui::Compositor* compositor = GetCompositor(); | 1366 ui::Compositor* compositor = GetCompositor(); |
1267 if (compositor) { | 1367 if (compositor) { |
1268 // Co-ordinates come in OpenGL co-ordinate space. | 1368 // Co-ordinates come in OpenGL co-ordinate space. |
1269 // We need to convert to layer space. | 1369 // We need to convert to layer space. |
1270 gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect( | 1370 gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect( |
1271 params_in_pixel.x, | 1371 params_in_pixel.x, |
1272 surface_size_in_pixel.height() - params_in_pixel.y - | 1372 surface_size_in_pixel.height() - params_in_pixel.y - |
1273 params_in_pixel.height, | 1373 params_in_pixel.height, |
1274 params_in_pixel.width, | 1374 params_in_pixel.width, |
1275 params_in_pixel.height)); | 1375 params_in_pixel.height)); |
1276 | 1376 |
1277 // Damage may not have been DIP aligned, so inflate damage to compensate | 1377 // Damage may not have been DIP aligned, so inflate damage to compensate |
1278 // for any round-off error. | 1378 // for any round-off error. |
1279 rect_to_paint.Inset(-1, -1); | 1379 rect_to_paint.Inset(-1, -1); |
1280 rect_to_paint.Intersect(window_->bounds()); | 1380 rect_to_paint.Intersect(window_->bounds()); |
1281 | 1381 |
1282 if (paint_observer_) | 1382 if (paint_observer_) |
1283 paint_observer_->OnUpdateCompositorContent(); | 1383 paint_observer_->OnUpdateCompositorContent(); |
1284 window_->SchedulePaintInRect(rect_to_paint); | 1384 window_->SchedulePaintInRect(rect_to_paint); |
1285 } | 1385 } |
1286 | 1386 |
1287 SwapBuffersCompleted(ack_params); | 1387 SwapBuffersCompleted(ack_callback, previous_texture); |
1288 } | 1388 } |
1289 | 1389 |
1290 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { | 1390 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { |
1291 } | 1391 } |
1292 | 1392 |
1293 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { | 1393 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { |
1294 // This really tells us to release the frontbuffer. | 1394 // This really tells us to release the frontbuffer. |
1295 if (current_surface_) { | 1395 if (current_surface_) { |
1296 ui::Compositor* compositor = GetCompositor(); | 1396 ui::Compositor* compositor = GetCompositor(); |
1297 if (compositor) { | 1397 if (compositor) { |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2301 | 2401 |
2302 void RenderWidgetHostViewAura::RunCompositingDidCommitCallbacks() { | 2402 void RenderWidgetHostViewAura::RunCompositingDidCommitCallbacks() { |
2303 for (std::vector<base::Closure>::const_iterator | 2403 for (std::vector<base::Closure>::const_iterator |
2304 it = on_compositing_did_commit_callbacks_.begin(); | 2404 it = on_compositing_did_commit_callbacks_.begin(); |
2305 it != on_compositing_did_commit_callbacks_.end(); ++it) { | 2405 it != on_compositing_did_commit_callbacks_.end(); ++it) { |
2306 it->Run(); | 2406 it->Run(); |
2307 } | 2407 } |
2308 on_compositing_did_commit_callbacks_.clear(); | 2408 on_compositing_did_commit_callbacks_.clear(); |
2309 } | 2409 } |
2310 | 2410 |
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() { | 2411 void RenderWidgetHostViewAura::AddedToRootWindow() { |
2330 window_->GetRootWindow()->AddRootWindowObserver(this); | 2412 window_->GetRootWindow()->AddRootWindowObserver(this); |
2331 host_->ParentChanged(GetNativeViewId()); | 2413 host_->ParentChanged(GetNativeViewId()); |
2332 UpdateScreenInfo(window_); | 2414 UpdateScreenInfo(window_); |
2333 if (popup_type_ != WebKit::WebPopupTypeNone) | 2415 if (popup_type_ != WebKit::WebPopupTypeNone) |
2334 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); | 2416 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); |
2335 } | 2417 } |
2336 | 2418 |
2337 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 2419 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
2338 event_filter_for_popup_exit_.reset(); | 2420 event_filter_for_popup_exit_.reset(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2371 RenderWidgetHost* widget) { | 2453 RenderWidgetHost* widget) { |
2372 return new RenderWidgetHostViewAura(widget); | 2454 return new RenderWidgetHostViewAura(widget); |
2373 } | 2455 } |
2374 | 2456 |
2375 // static | 2457 // static |
2376 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 2458 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
2377 GetScreenInfoForWindow(results, NULL); | 2459 GetScreenInfoForWindow(results, NULL); |
2378 } | 2460 } |
2379 | 2461 |
2380 } // namespace content | 2462 } // namespace content |
OLD | NEW |