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

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

Issue 10967027: Avoid calling RWHVWin::GetBackingStore when accelerated compositing is enabled. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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
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
1309 if (!render_widget_host_) 1317 if (!render_widget_host_)
1310 return; 1318 return;
1311 1319
1312 DCHECK(render_widget_host_->GetProcess()->HasConnection()); 1320 DCHECK(render_widget_host_->GetProcess()->HasConnection());
1313 1321
1314 // If the GPU process is rendering to a child window, compositing is 1322 // 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 1323 // already triggered by damage to compositor_host_window_, so all we need to
1316 // do here is clear borders during resize. 1324 // do here is clear borders during resize.
1317 if (compositor_host_window_ && 1325 if (compositor_host_window_ &&
1318 render_widget_host_->is_accelerated_compositing_active()) { 1326 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; 1327 RECT host_rect, child_rect;
1323 GetClientRect(&host_rect); 1328 GetClientRect(&host_rect);
1324 if (::GetClientRect(compositor_host_window_, &child_rect) && 1329 if (::GetClientRect(compositor_host_window_, &child_rect) &&
1325 (child_rect.right < host_rect.right || 1330 (child_rect.right < host_rect.right ||
1326 child_rect.bottom < host_rect.bottom)) { 1331 child_rect.bottom < host_rect.bottom)) {
1327 paint_dc.FillRect(&host_rect, 1332 paint_dc.FillRect(&host_rect,
1328 reinterpret_cast<HBRUSH>(GetStockObject(WHITE_BRUSH))); 1333 reinterpret_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)));
1329 } 1334 }
1330 return; 1335 return;
1331 } 1336 }
1332 1337
1338 if (accelerated_surface_.get() &&
1339 render_widget_host_->is_accelerated_compositing_active()) {
1340 AcceleratedPaint(paint_dc.m_hDC);
1341 return;
1342 }
1343
1333 about_to_validate_and_paint_ = true; 1344 about_to_validate_and_paint_ = true;
1334 BackingStoreWin* backing_store = static_cast<BackingStoreWin*>( 1345 BackingStoreWin* backing_store = static_cast<BackingStoreWin*>(
1335 render_widget_host_->GetBackingStore(true)); 1346 render_widget_host_->GetBackingStore(true));
1336 1347
1337 // We initialize |paint_dc| (and thus call BeginPaint()) after calling 1348 // We initialize |paint_dc| (and thus call BeginPaint()) after calling
1338 // GetBackingStore(), so that if it updates the invalid rect we'll catch the 1349 // GetBackingStore(), so that if it updates the invalid rect we'll catch the
1339 // changes and repaint them. 1350 // changes and repaint them.
1340 about_to_validate_and_paint_ = false; 1351 about_to_validate_and_paint_ = false;
1341 1352
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_) { 1353 if (compositor_host_window_ && hide_compositor_window_at_next_paint_) {
1348 ::ShowWindow(compositor_host_window_, SW_HIDE); 1354 ::ShowWindow(compositor_host_window_, SW_HIDE);
1349 hide_compositor_window_at_next_paint_ = false; 1355 hide_compositor_window_at_next_paint_ = false;
1350 } 1356 }
1351 1357
1352 CPaintDC paint_dc(m_hWnd);
1353
1354 gfx::Rect damaged_rect(paint_dc.m_ps.rcPaint); 1358 gfx::Rect damaged_rect(paint_dc.m_ps.rcPaint);
1355 if (damaged_rect.IsEmpty()) 1359 if (damaged_rect.IsEmpty())
1356 return; 1360 return;
1357 1361
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) { 1362 if (backing_store) {
1365 gfx::Rect bitmap_rect(gfx::Point(), backing_store->size()); 1363 gfx::Rect bitmap_rect(gfx::Point(), backing_store->size());
1366 1364
1367 bool manage_colors = BackingStoreWin::ColorManagementEnabled(); 1365 bool manage_colors = BackingStoreWin::ColorManagementEnabled();
1368 if (manage_colors) 1366 if (manage_colors)
1369 SetICMMode(paint_dc.m_hDC, ICM_ON); 1367 SetICMMode(paint_dc.m_hDC, ICM_ON);
1370 1368
1371 // Blit only the damaged regions from the backing store. 1369 // Blit only the damaged regions from the backing store.
1372 DWORD data_size = GetRegionData(damage_region, 0, NULL); 1370 DWORD data_size = GetRegionData(damage_region, 0, NULL);
1373 scoped_array<char> region_data_buf; 1371 scoped_array<char> region_data_buf;
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after
3102 // receive a focus change in the context of a pointer down message, it means 3100 // 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 3101 // that the pointer down message occurred on the edit field and we should
3104 // display the on screen keyboard 3102 // display the on screen keyboard
3105 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) 3103 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_)
3106 DisplayOnScreenKeyboardIfNeeded(); 3104 DisplayOnScreenKeyboardIfNeeded();
3107 received_focus_change_after_pointer_down_ = false; 3105 received_focus_change_after_pointer_down_ = false;
3108 pointer_down_context_ = false; 3106 pointer_down_context_ = false;
3109 } 3107 }
3110 3108
3111 } // namespace content 3109 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698