| 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 | |
| 1310 // Grab the region to paint before creation of paint_dc since it clears the | |
| 1311 // damage region. | |
| 1312 base::win::ScopedGDIObject<HRGN> damage_region(CreateRectRgn(0, 0, 0, 0)); | |
| 1313 GetUpdateRgn(damage_region, FALSE); | |
| 1314 | |
| 1315 CPaintDC paint_dc(m_hWnd); | |
| 1316 | |
| 1317 if (!render_widget_host_) | 1309 if (!render_widget_host_) |
| 1318 return; | 1310 return; |
| 1319 | 1311 |
| 1320 DCHECK(render_widget_host_->GetProcess()->HasConnection()); | 1312 DCHECK(render_widget_host_->GetProcess()->HasConnection()); |
| 1321 | 1313 |
| 1322 // If the GPU process is rendering to a child window, compositing is | 1314 // If the GPU process is rendering to a child window, compositing is |
| 1323 // already triggered by damage to compositor_host_window_, so all we need to | 1315 // already triggered by damage to compositor_host_window_, so all we need to |
| 1324 // do here is clear borders during resize. | 1316 // do here is clear borders during resize. |
| 1325 if (compositor_host_window_ && | 1317 if (compositor_host_window_ && |
| 1326 render_widget_host_->is_accelerated_compositing_active()) { | 1318 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); |
| 1327 RECT host_rect, child_rect; | 1322 RECT host_rect, child_rect; |
| 1328 GetClientRect(&host_rect); | 1323 GetClientRect(&host_rect); |
| 1329 if (::GetClientRect(compositor_host_window_, &child_rect) && | 1324 if (::GetClientRect(compositor_host_window_, &child_rect) && |
| 1330 (child_rect.right < host_rect.right || | 1325 (child_rect.right < host_rect.right || |
| 1331 child_rect.bottom < host_rect.bottom)) { | 1326 child_rect.bottom < host_rect.bottom)) { |
| 1332 paint_dc.FillRect(&host_rect, | 1327 paint_dc.FillRect(&host_rect, |
| 1333 reinterpret_cast<HBRUSH>(GetStockObject(WHITE_BRUSH))); | 1328 reinterpret_cast<HBRUSH>(GetStockObject(WHITE_BRUSH))); |
| 1334 } | 1329 } |
| 1335 return; | 1330 return; |
| 1336 } | 1331 } |
| 1337 | 1332 |
| 1338 if (accelerated_surface_.get() && | |
| 1339 render_widget_host_->is_accelerated_compositing_active()) { | |
| 1340 AcceleratedPaint(paint_dc.m_hDC); | |
| 1341 return; | |
| 1342 } | |
| 1343 | |
| 1344 about_to_validate_and_paint_ = true; | 1333 about_to_validate_and_paint_ = true; |
| 1345 BackingStoreWin* backing_store = static_cast<BackingStoreWin*>( | 1334 BackingStoreWin* backing_store = static_cast<BackingStoreWin*>( |
| 1346 render_widget_host_->GetBackingStore(true)); | 1335 render_widget_host_->GetBackingStore(true)); |
| 1347 | 1336 |
| 1348 // We initialize |paint_dc| (and thus call BeginPaint()) after calling | 1337 // We initialize |paint_dc| (and thus call BeginPaint()) after calling |
| 1349 // GetBackingStore(), so that if it updates the invalid rect we'll catch the | 1338 // GetBackingStore(), so that if it updates the invalid rect we'll catch the |
| 1350 // changes and repaint them. | 1339 // changes and repaint them. |
| 1351 about_to_validate_and_paint_ = false; | 1340 about_to_validate_and_paint_ = false; |
| 1352 | 1341 |
| 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 |
| 1353 if (compositor_host_window_ && hide_compositor_window_at_next_paint_) { | 1347 if (compositor_host_window_ && hide_compositor_window_at_next_paint_) { |
| 1354 ::ShowWindow(compositor_host_window_, SW_HIDE); | 1348 ::ShowWindow(compositor_host_window_, SW_HIDE); |
| 1355 hide_compositor_window_at_next_paint_ = false; | 1349 hide_compositor_window_at_next_paint_ = false; |
| 1356 } | 1350 } |
| 1357 | 1351 |
| 1352 CPaintDC paint_dc(m_hWnd); |
| 1353 |
| 1358 gfx::Rect damaged_rect(paint_dc.m_ps.rcPaint); | 1354 gfx::Rect damaged_rect(paint_dc.m_ps.rcPaint); |
| 1359 if (damaged_rect.IsEmpty()) | 1355 if (damaged_rect.IsEmpty()) |
| 1360 return; | 1356 return; |
| 1361 | 1357 |
| 1358 if (accelerated_surface_.get() && |
| 1359 render_widget_host_->is_accelerated_compositing_active()) { |
| 1360 AcceleratedPaint(paint_dc.m_hDC); |
| 1361 return; |
| 1362 } |
| 1363 |
| 1362 if (backing_store) { | 1364 if (backing_store) { |
| 1363 gfx::Rect bitmap_rect(gfx::Point(), backing_store->size()); | 1365 gfx::Rect bitmap_rect(gfx::Point(), backing_store->size()); |
| 1364 | 1366 |
| 1365 bool manage_colors = BackingStoreWin::ColorManagementEnabled(); | 1367 bool manage_colors = BackingStoreWin::ColorManagementEnabled(); |
| 1366 if (manage_colors) | 1368 if (manage_colors) |
| 1367 SetICMMode(paint_dc.m_hDC, ICM_ON); | 1369 SetICMMode(paint_dc.m_hDC, ICM_ON); |
| 1368 | 1370 |
| 1369 // Blit only the damaged regions from the backing store. | 1371 // Blit only the damaged regions from the backing store. |
| 1370 DWORD data_size = GetRegionData(damage_region, 0, NULL); | 1372 DWORD data_size = GetRegionData(damage_region, 0, NULL); |
| 1371 scoped_array<char> region_data_buf; | 1373 scoped_array<char> region_data_buf; |
| (...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3083 // receive a focus change in the context of a pointer down message, it means | 3085 // receive a focus change in the context of a pointer down message, it means |
| 3084 // that the pointer down message occurred on the edit field and we should | 3086 // that the pointer down message occurred on the edit field and we should |
| 3085 // display the on screen keyboard | 3087 // display the on screen keyboard |
| 3086 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) | 3088 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) |
| 3087 DisplayOnScreenKeyboardIfNeeded(); | 3089 DisplayOnScreenKeyboardIfNeeded(); |
| 3088 received_focus_change_after_pointer_down_ = false; | 3090 received_focus_change_after_pointer_down_ = false; |
| 3089 pointer_down_context_ = false; | 3091 pointer_down_context_ = false; |
| 3090 } | 3092 } |
| 3091 | 3093 |
| 3092 } // namespace content | 3094 } // namespace content |
| OLD | NEW |