| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/views/tabs/native_view_photobooth_win.h" | 5 #include "chrome/browser/ui/views/tabs/native_view_photobooth_win.h" |
| 6 | 6 |
| 7 #include "content/browser/tab_contents/tab_contents.h" | 7 #include "content/browser/tab_contents/tab_contents.h" |
| 8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
| 9 #include "ui/gfx/canvas_skia.h" | 9 #include "ui/gfx/canvas_skia.h" |
| 10 #include "ui/gfx/point.h" | 10 #include "ui/gfx/point.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // canvas' DIB. | 103 // canvas' DIB. |
| 104 HDC target_dc = canvas->BeginPlatformPaint(); | 104 HDC target_dc = canvas->BeginPlatformPaint(); |
| 105 HDC source_dc = GetDC(current_hwnd_); | 105 HDC source_dc = GetDC(current_hwnd_); |
| 106 RECT window_rect = {0}; | 106 RECT window_rect = {0}; |
| 107 GetWindowRect(current_hwnd_, &window_rect); | 107 GetWindowRect(current_hwnd_, &window_rect); |
| 108 BitBlt(target_dc, target_bounds.x(), target_bounds.y(), | 108 BitBlt(target_dc, target_bounds.x(), target_bounds.y(), |
| 109 target_bounds.width(), target_bounds.height(), source_dc, 0, 0, | 109 target_bounds.width(), target_bounds.height(), source_dc, 0, 0, |
| 110 SRCCOPY); | 110 SRCCOPY); |
| 111 // Windows screws up the alpha channel on all text it draws, and so we need | 111 // Windows screws up the alpha channel on all text it draws, and so we need |
| 112 // to call makeOpaque _after_ the blit to correct for this. | 112 // to call makeOpaque _after_ the blit to correct for this. |
| 113 canvas->AsCanvasSkia()->getTopPlatformDevice().makeOpaque( | 113 skia::MakeOpaque(canvas->AsCanvasSkia(), target_bounds.x(), |
| 114 target_bounds.x(), target_bounds.y(), target_bounds.width(), | 114 target_bounds.y(), target_bounds.width(), |
| 115 target_bounds.height()); | 115 target_bounds.height()); |
| 116 ReleaseDC(current_hwnd_, source_dc); | 116 ReleaseDC(current_hwnd_, source_dc); |
| 117 canvas->EndPlatformPaint(); | 117 canvas->EndPlatformPaint(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 /////////////////////////////////////////////////////////////////////////////// | 120 /////////////////////////////////////////////////////////////////////////////// |
| 121 // NativeViewPhotoboothWin, private: | 121 // NativeViewPhotoboothWin, private: |
| 122 | 122 |
| 123 void NativeViewPhotoboothWin::CreateCaptureWindow(HWND initial_hwnd) { | 123 void NativeViewPhotoboothWin::CreateCaptureWindow(HWND initial_hwnd) { |
| 124 // 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 |
| 125 // 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 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 params.bounds = capture_bounds; | 157 params.bounds = capture_bounds; |
| 158 capture_window_->Init(params); | 158 capture_window_->Init(params); |
| 159 // If the capture window isn't visible, blitting from the TabContents' | 159 // If the capture window isn't visible, blitting from the TabContents' |
| 160 // HWND's DC to the capture bitmap produces blankness. | 160 // HWND's DC to the capture bitmap produces blankness. |
| 161 capture_window_->Show(); | 161 capture_window_->Show(); |
| 162 SetLayeredWindowAttributes( | 162 SetLayeredWindowAttributes( |
| 163 capture_window_->GetNativeView(), RGB(0xFF, 0xFF, 0xFF), 0xFF, LWA_ALPHA); | 163 capture_window_->GetNativeView(), RGB(0xFF, 0xFF, 0xFF), 0xFF, LWA_ALPHA); |
| 164 | 164 |
| 165 Replace(initial_hwnd); | 165 Replace(initial_hwnd); |
| 166 } | 166 } |
| OLD | NEW |