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

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

Issue 2862025: Canvas refactoring part 2.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/render_widget_host_view_win.h" 5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/l10n_util_win.h" 8 #include "app/l10n_util_win.h"
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/renderer_host/gpu_view_host.h" 24 #include "chrome/browser/renderer_host/gpu_view_host.h"
25 #include "chrome/browser/renderer_host/render_process_host.h" 25 #include "chrome/browser/renderer_host/render_process_host.h"
26 #include "chrome/browser/renderer_host/render_widget_host.h" 26 #include "chrome/browser/renderer_host/render_widget_host.h"
27 #include "chrome/common/chrome_constants.h" 27 #include "chrome/common/chrome_constants.h"
28 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/native_web_keyboard_event.h" 29 #include "chrome/common/native_web_keyboard_event.h"
30 #include "chrome/common/notification_service.h" 30 #include "chrome/common/notification_service.h"
31 #include "chrome/common/plugin_messages.h" 31 #include "chrome/common/plugin_messages.h"
32 #include "chrome/common/render_messages.h" 32 #include "chrome/common/render_messages.h"
33 #include "gfx/canvas.h" 33 #include "gfx/canvas.h"
34 #include "gfx/canvas_skia.h"
34 #include "gfx/gdi_util.h" 35 #include "gfx/gdi_util.h"
35 #include "gfx/rect.h" 36 #include "gfx/rect.h"
36 #include "grit/webkit_resources.h" 37 #include "grit/webkit_resources.h"
37 #include "skia/ext/skia_utils_win.h" 38 #include "skia/ext/skia_utils_win.h"
38 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" 39 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
39 #include "third_party/WebKit/WebKit/chromium/public/win/WebInputEventFactory.h" 40 #include "third_party/WebKit/WebKit/chromium/public/win/WebInputEventFactory.h"
40 #include "views/accessibility/view_accessibility.h" 41 #include "views/accessibility/view_accessibility.h"
41 #include "views/focus/focus_manager.h" 42 #include "views/focus/focus_manager.h"
42 #include "views/focus/focus_util_win.h" 43 #include "views/focus/focus_util_win.h"
43 // Included for views::kReflectedMessage - TODO(beng): move this to win_util.h! 44 // Included for views::kReflectedMessage - TODO(beng): move this to win_util.h!
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 SetParent(window, NULL); 229 SetParent(window, NULL);
229 } 230 }
230 return TRUE; 231 return TRUE;
231 } 232 }
232 233
233 // Draw the contents of |backing_store_dc| onto |paint_rect| with a 70% grey 234 // Draw the contents of |backing_store_dc| onto |paint_rect| with a 70% grey
234 // filter. 235 // filter.
235 void DrawDeemphasized(const gfx::Rect& paint_rect, 236 void DrawDeemphasized(const gfx::Rect& paint_rect,
236 HDC backing_store_dc, 237 HDC backing_store_dc,
237 HDC paint_dc) { 238 HDC paint_dc) {
238 gfx::Canvas canvas(paint_rect.width(), paint_rect.height(), true); 239 gfx::CanvasSkia canvas(paint_rect.width(), paint_rect.height(), true);
239 HDC dc = canvas.beginPlatformPaint(); 240 HDC dc = canvas.beginPlatformPaint();
240 BitBlt(dc, 241 BitBlt(dc,
241 0, 242 0,
242 0, 243 0,
243 paint_rect.width(), 244 paint_rect.width(),
244 paint_rect.height(), 245 paint_rect.height(),
245 backing_store_dc, 246 backing_store_dc,
246 paint_rect.x(), 247 paint_rect.x(),
247 paint_rect.y(), 248 paint_rect.y(),
248 SRCCOPY); 249 SRCCOPY);
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 EnumChildWindows(m_hWnd, EnumChildProc, lparam); 670 EnumChildWindows(m_hWnd, EnumChildProc, lparam);
670 } 671 }
671 672
672 void RenderWidgetHostViewWin::DrawResizeCorner(const gfx::Rect& paint_rect, 673 void RenderWidgetHostViewWin::DrawResizeCorner(const gfx::Rect& paint_rect,
673 HDC dc) { 674 HDC dc) {
674 gfx::Rect resize_corner_rect = 675 gfx::Rect resize_corner_rect =
675 render_widget_host_->GetRootWindowResizerRect(); 676 render_widget_host_->GetRootWindowResizerRect();
676 if (!paint_rect.Intersect(resize_corner_rect).IsEmpty()) { 677 if (!paint_rect.Intersect(resize_corner_rect).IsEmpty()) {
677 SkBitmap* bitmap = ResourceBundle::GetSharedInstance(). 678 SkBitmap* bitmap = ResourceBundle::GetSharedInstance().
678 GetBitmapNamed(IDR_TEXTAREA_RESIZER); 679 GetBitmapNamed(IDR_TEXTAREA_RESIZER);
679 gfx::Canvas canvas(bitmap->width(), bitmap->height(), false); 680 gfx::CanvasSkia canvas(bitmap->width(), bitmap->height(), false);
680 canvas.getDevice()->accessBitmap(true).eraseARGB(0, 0, 0, 0); 681 canvas.getDevice()->accessBitmap(true).eraseARGB(0, 0, 0, 0);
681 int x = resize_corner_rect.x() + resize_corner_rect.width() - 682 int x = resize_corner_rect.x() + resize_corner_rect.width() -
682 bitmap->width(); 683 bitmap->width();
683 bool rtl_dir = base::i18n::IsRTL(); 684 bool rtl_dir = base::i18n::IsRTL();
684 if (rtl_dir) { 685 if (rtl_dir) {
685 canvas.TranslateInt(bitmap->width(), 0); 686 canvas.TranslateInt(bitmap->width(), 0);
686 canvas.ScaleInt(-1, 1); 687 canvas.ScaleInt(-1, 1);
687 canvas.save(); 688 canvas.save();
688 x = 0; 689 x = 0;
689 } 690 }
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 } else { 984 } else {
984 DrawBackground(paint_dc.m_ps.rcPaint, &paint_dc); 985 DrawBackground(paint_dc.m_ps.rcPaint, &paint_dc);
985 if (whiteout_start_time_.is_null()) 986 if (whiteout_start_time_.is_null())
986 whiteout_start_time_ = TimeTicks::Now(); 987 whiteout_start_time_ = TimeTicks::Now();
987 } 988 }
988 } 989 }
989 990
990 void RenderWidgetHostViewWin::DrawBackground(const RECT& dirty_rect, 991 void RenderWidgetHostViewWin::DrawBackground(const RECT& dirty_rect,
991 CPaintDC* dc) { 992 CPaintDC* dc) {
992 if (!background_.empty()) { 993 if (!background_.empty()) {
993 gfx::Canvas canvas(dirty_rect.right - dirty_rect.left, 994 gfx::CanvasSkia canvas(dirty_rect.right - dirty_rect.left,
994 dirty_rect.bottom - dirty_rect.top, 995 dirty_rect.bottom - dirty_rect.top,
995 true); // opaque 996 true); // opaque
996 canvas.TranslateInt(-dirty_rect.left, -dirty_rect.top); 997 canvas.TranslateInt(-dirty_rect.left, -dirty_rect.top);
997 998
998 const RECT& dc_rect = dc->m_ps.rcPaint; 999 const RECT& dc_rect = dc->m_ps.rcPaint;
999 canvas.TileImageInt(background_, 0, 0, 1000 canvas.TileImageInt(background_, 0, 0,
1000 dc_rect.right - dc_rect.left, 1001 dc_rect.right - dc_rect.left,
1001 dc_rect.bottom - dc_rect.top); 1002 dc_rect.bottom - dc_rect.top);
1002 1003
1003 canvas.getTopPlatformDevice().drawToHDC(*dc, dirty_rect.left, 1004 canvas.getTopPlatformDevice().drawToHDC(*dc, dirty_rect.left,
1004 dirty_rect.top, NULL); 1005 dirty_rect.top, NULL);
1005 } else { 1006 } else {
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( 1714 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView(
1714 gfx::NativeView native_view) { 1715 gfx::NativeView native_view) {
1715 if (::IsWindow(native_view)) { 1716 if (::IsWindow(native_view)) {
1716 HANDLE raw_render_host_view = ::GetProp(native_view, 1717 HANDLE raw_render_host_view = ::GetProp(native_view,
1717 kRenderWidgetHostViewKey); 1718 kRenderWidgetHostViewKey);
1718 if (raw_render_host_view) 1719 if (raw_render_host_view)
1719 return reinterpret_cast<RenderWidgetHostView*>(raw_render_host_view); 1720 return reinterpret_cast<RenderWidgetHostView*>(raw_render_host_view);
1720 } 1721 }
1721 return NULL; 1722 return NULL;
1722 } 1723 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698