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

Side by Side Diff: chrome/browser/views/tabs/native_view_photobooth_win.cc

Issue 2811032: Revert 50784 - Canvas refactoring part 3.... (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
« no previous file with comments | « chrome/browser/views/tabs/dragged_tab_view.cc ('k') | chrome/browser/views/tabs/side_tab.cc » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/views/tabs/native_view_photobooth_win.h" 5 #include "chrome/browser/views/tabs/native_view_photobooth_win.h"
6 6
7 #include "chrome/browser/tab_contents/tab_contents.h" 7 #include "chrome/browser/tab_contents/tab_contents.h"
8 #include "gfx/canvas_skia.h" 8 #include "gfx/canvas.h"
9 #include "gfx/point.h" 9 #include "gfx/point.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
11 #include "views/widget/widget_win.h" 11 #include "views/widget/widget_win.h"
12 12
13 namespace { 13 namespace {
14 14
15 static BOOL CALLBACK MonitorEnumProc(HMONITOR monitor, HDC monitor_dc, 15 static BOOL CALLBACK MonitorEnumProc(HMONITOR monitor, HDC monitor_dc,
16 RECT* monitor_rect, LPARAM data) { 16 RECT* monitor_rect, LPARAM data) {
17 gfx::Point* point = reinterpret_cast<gfx::Point*>(data); 17 gfx::Point* point = reinterpret_cast<gfx::Point*>(data);
18 if (monitor_rect->right > point->x() && monitor_rect->bottom > point->y()) { 18 if (monitor_rect->right > point->x() && monitor_rect->bottom > point->y()) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 GetParent(current_hwnd_) != capture_window_->GetNativeView()) { 93 GetParent(current_hwnd_) != capture_window_->GetNativeView()) {
94 Replace(current_hwnd_); 94 Replace(current_hwnd_);
95 } 95 }
96 96
97 // We compel the contained HWND to paint now, synchronously. We do this to 97 // We compel the contained HWND to paint now, synchronously. We do this to
98 // populate the device context with valid and current data. 98 // populate the device context with valid and current data.
99 RedrawWindow(current_hwnd_, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); 99 RedrawWindow(current_hwnd_, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
100 100
101 // Transfer the contents of the layered capture window to the screen-shot 101 // Transfer the contents of the layered capture window to the screen-shot
102 // canvas' DIB. 102 // canvas' DIB.
103 HDC target_dc = canvas->AsCanvasSkia()->beginPlatformPaint(); 103 HDC target_dc = canvas->beginPlatformPaint();
104 HDC source_dc = GetDC(current_hwnd_); 104 HDC source_dc = GetDC(current_hwnd_);
105 RECT window_rect = {0}; 105 RECT window_rect = {0};
106 GetWindowRect(current_hwnd_, &window_rect); 106 GetWindowRect(current_hwnd_, &window_rect);
107 BitBlt(target_dc, target_bounds.x(), target_bounds.y(), 107 BitBlt(target_dc, target_bounds.x(), target_bounds.y(),
108 target_bounds.width(), target_bounds.height(), source_dc, 0, 0, 108 target_bounds.width(), target_bounds.height(), source_dc, 0, 0,
109 SRCCOPY); 109 SRCCOPY);
110 // Windows screws up the alpha channel on all text it draws, and so we need 110 // Windows screws up the alpha channel on all text it draws, and so we need
111 // to call makeOpaque _after_ the blit to correct for this. 111 // to call makeOpaque _after_ the blit to correct for this.
112 canvas->AsCanvasSkia()->getTopPlatformDevice().makeOpaque( 112 canvas->getTopPlatformDevice().makeOpaque(target_bounds.x(),
113 target_bounds.x(), target_bounds.y(), target_bounds.width(), 113 target_bounds.y(),
114 target_bounds.height()); 114 target_bounds.width(),
115 target_bounds.height());
115 ReleaseDC(current_hwnd_, source_dc); 116 ReleaseDC(current_hwnd_, source_dc);
116 canvas->AsCanvasSkia()->endPlatformPaint(); 117 canvas->endPlatformPaint();
117 } 118 }
118 119
119 /////////////////////////////////////////////////////////////////////////////// 120 ///////////////////////////////////////////////////////////////////////////////
120 // NativeViewPhotoboothWin, private: 121 // NativeViewPhotoboothWin, private:
121 122
122 void NativeViewPhotoboothWin::CreateCaptureWindow(HWND initial_hwnd) { 123 void NativeViewPhotoboothWin::CreateCaptureWindow(HWND initial_hwnd) {
123 // Snapshotting a HWND is tricky - if the HWND is clipped (e.g. positioned 124 // Snapshotting a HWND is tricky - if the HWND is clipped (e.g. positioned
124 // partially off-screen) then just blitting from the HWND' DC to the capture 125 // partially off-screen) then just blitting from the HWND' DC to the capture
125 // bitmap would be incorrect, since the capture bitmap would show only the 126 // bitmap would be incorrect, since the capture bitmap would show only the
126 // visible area of the HWND. 127 // visible area of the HWND.
(...skipping 29 matching lines...) Expand all
156 capture_window_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW); 157 capture_window_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW);
157 capture_window_->Init(NULL, capture_bounds); 158 capture_window_->Init(NULL, capture_bounds);
158 // If the capture window isn't visible, blitting from the TabContents' 159 // If the capture window isn't visible, blitting from the TabContents'
159 // HWND's DC to the capture bitmap produces blankness. 160 // HWND's DC to the capture bitmap produces blankness.
160 capture_window_->Show(); 161 capture_window_->Show();
161 SetLayeredWindowAttributes( 162 SetLayeredWindowAttributes(
162 capture_window_->GetNativeView(), RGB(0xFF, 0xFF, 0xFF), 0xFF, LWA_ALPHA); 163 capture_window_->GetNativeView(), RGB(0xFF, 0xFF, 0xFF), 0xFF, LWA_ALPHA);
163 164
164 Replace(initial_hwnd); 165 Replace(initial_hwnd);
165 } 166 }
OLDNEW
« no previous file with comments | « chrome/browser/views/tabs/dragged_tab_view.cc ('k') | chrome/browser/views/tabs/side_tab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698