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_win.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <peninputpanel_i.c> | 9 #include <peninputpanel_i.c> |
10 #include <stack> | 10 #include <stack> |
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1299 } | 1299 } |
1300 | 1300 |
1301 CleanupCompositorWindow(); | 1301 CleanupCompositorWindow(); |
1302 | 1302 |
1303 ResetTooltip(); | 1303 ResetTooltip(); |
1304 TrackMouseLeave(false); | 1304 TrackMouseLeave(false); |
1305 } | 1305 } |
1306 | 1306 |
1307 void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { | 1307 void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { |
1308 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnPaint"); | 1308 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnPaint"); |
1309 if (!render_widget_host_) | 1309 if (!render_widget_host_) |
apatrick_chromium
2012/09/20 22:14:17
This is is a bit suspicious and I can fix it if yo
sky
2012/09/20 22:39:52
Agreed.
apatrick_chromium
2012/09/20 22:52:31
Done.
| |
1310 return; | 1310 return; |
1311 | 1311 |
1312 DCHECK(render_widget_host_->GetProcess()->HasConnection()); | 1312 DCHECK(render_widget_host_->GetProcess()->HasConnection()); |
1313 | 1313 |
1314 // Grab the region to paint before creation of paint_dc since it clears the | |
1315 // damage region. | |
1316 base::win::ScopedGDIObject<HRGN> damage_region(CreateRectRgn(0, 0, 0, 0)); | |
apatrick_chromium
2012/09/20 22:14:17
This has to be above the definition of paint_dc as
| |
1317 GetUpdateRgn(damage_region, FALSE); | |
1318 | |
1319 CPaintDC paint_dc(m_hWnd); | |
apatrick_chromium
2012/09/20 22:14:17
This moved up so everything uses a single definiti
| |
1320 | |
1314 // If the GPU process is rendering to a child window, compositing is | 1321 // If the GPU process is rendering to a child window, compositing is |
1315 // already triggered by damage to compositor_host_window_, so all we need to | 1322 // already triggered by damage to compositor_host_window_, so all we need to |
1316 // do here is clear borders during resize. | 1323 // do here is clear borders during resize. |
1317 if (compositor_host_window_ && | 1324 if (compositor_host_window_ && |
1318 render_widget_host_->is_accelerated_compositing_active()) { | 1325 render_widget_host_->is_accelerated_compositing_active()) { |
1319 // We initialize paint_dc here so that BeginPaint()/EndPaint() | |
1320 // get called to validate the region. | |
1321 CPaintDC paint_dc(m_hWnd); | |
1322 RECT host_rect, child_rect; | 1326 RECT host_rect, child_rect; |
1323 GetClientRect(&host_rect); | 1327 GetClientRect(&host_rect); |
1324 if (::GetClientRect(compositor_host_window_, &child_rect) && | 1328 if (::GetClientRect(compositor_host_window_, &child_rect) && |
1325 (child_rect.right < host_rect.right || | 1329 (child_rect.right < host_rect.right || |
1326 child_rect.bottom < host_rect.bottom)) { | 1330 child_rect.bottom < host_rect.bottom)) { |
1327 paint_dc.FillRect(&host_rect, | 1331 paint_dc.FillRect(&host_rect, |
1328 reinterpret_cast<HBRUSH>(GetStockObject(WHITE_BRUSH))); | 1332 reinterpret_cast<HBRUSH>(GetStockObject(WHITE_BRUSH))); |
1329 } | 1333 } |
1330 return; | 1334 return; |
1331 } | 1335 } |
1332 | 1336 |
1337 if (accelerated_surface_.get() && | |
apatrick_chromium
2012/09/20 22:14:17
And this moved above the call to GetBackingStore.
| |
1338 render_widget_host_->is_accelerated_compositing_active()) { | |
1339 AcceleratedPaint(paint_dc.m_hDC); | |
1340 return; | |
1341 } | |
1342 | |
1333 about_to_validate_and_paint_ = true; | 1343 about_to_validate_and_paint_ = true; |
1334 BackingStoreWin* backing_store = static_cast<BackingStoreWin*>( | 1344 BackingStoreWin* backing_store = static_cast<BackingStoreWin*>( |
1335 render_widget_host_->GetBackingStore(true)); | 1345 render_widget_host_->GetBackingStore(true)); |
1336 | 1346 |
1337 // We initialize |paint_dc| (and thus call BeginPaint()) after calling | 1347 // We initialize |paint_dc| (and thus call BeginPaint()) after calling |
1338 // GetBackingStore(), so that if it updates the invalid rect we'll catch the | 1348 // GetBackingStore(), so that if it updates the invalid rect we'll catch the |
1339 // changes and repaint them. | 1349 // changes and repaint them. |
1340 about_to_validate_and_paint_ = false; | 1350 about_to_validate_and_paint_ = false; |
1341 | 1351 |
1342 // Grab the region to paint before creation of paint_dc since it clears the | |
1343 // damage region. | |
1344 base::win::ScopedGDIObject<HRGN> damage_region(CreateRectRgn(0, 0, 0, 0)); | |
1345 GetUpdateRgn(damage_region, FALSE); | |
1346 | |
1347 if (compositor_host_window_ && hide_compositor_window_at_next_paint_) { | 1352 if (compositor_host_window_ && hide_compositor_window_at_next_paint_) { |
1348 ::ShowWindow(compositor_host_window_, SW_HIDE); | 1353 ::ShowWindow(compositor_host_window_, SW_HIDE); |
1349 hide_compositor_window_at_next_paint_ = false; | 1354 hide_compositor_window_at_next_paint_ = false; |
1350 } | 1355 } |
1351 | 1356 |
1352 CPaintDC paint_dc(m_hWnd); | |
1353 | |
1354 gfx::Rect damaged_rect(paint_dc.m_ps.rcPaint); | 1357 gfx::Rect damaged_rect(paint_dc.m_ps.rcPaint); |
1355 if (damaged_rect.IsEmpty()) | 1358 if (damaged_rect.IsEmpty()) |
1356 return; | 1359 return; |
1357 | 1360 |
1358 if (accelerated_surface_.get() && | |
1359 render_widget_host_->is_accelerated_compositing_active()) { | |
1360 AcceleratedPaint(paint_dc.m_hDC); | |
1361 return; | |
1362 } | |
1363 | |
1364 if (backing_store) { | 1361 if (backing_store) { |
1365 gfx::Rect bitmap_rect(gfx::Point(), backing_store->size()); | 1362 gfx::Rect bitmap_rect(gfx::Point(), backing_store->size()); |
1366 | 1363 |
1367 bool manage_colors = BackingStoreWin::ColorManagementEnabled(); | 1364 bool manage_colors = BackingStoreWin::ColorManagementEnabled(); |
1368 if (manage_colors) | 1365 if (manage_colors) |
1369 SetICMMode(paint_dc.m_hDC, ICM_ON); | 1366 SetICMMode(paint_dc.m_hDC, ICM_ON); |
1370 | 1367 |
1371 // Blit only the damaged regions from the backing store. | 1368 // Blit only the damaged regions from the backing store. |
1372 DWORD data_size = GetRegionData(damage_region, 0, NULL); | 1369 DWORD data_size = GetRegionData(damage_region, 0, NULL); |
1373 scoped_array<char> region_data_buf; | 1370 scoped_array<char> region_data_buf; |
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3102 // receive a focus change in the context of a pointer down message, it means | 3099 // receive a focus change in the context of a pointer down message, it means |
3103 // that the pointer down message occurred on the edit field and we should | 3100 // that the pointer down message occurred on the edit field and we should |
3104 // display the on screen keyboard | 3101 // display the on screen keyboard |
3105 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) | 3102 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) |
3106 DisplayOnScreenKeyboardIfNeeded(); | 3103 DisplayOnScreenKeyboardIfNeeded(); |
3107 received_focus_change_after_pointer_down_ = false; | 3104 received_focus_change_after_pointer_down_ = false; |
3108 pointer_down_context_ = false; | 3105 pointer_down_context_ = false; |
3109 } | 3106 } |
3110 | 3107 |
3111 } // namespace content | 3108 } // namespace content |
OLD | NEW |