| OLD | NEW |
| 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 "remoting/host/capturer_gdi.h" | 5 #include "remoting/host/capturer_gdi.h" |
| 6 | 6 |
| 7 #include "gfx/rect.h" | 7 #include "gfx/rect.h" |
| 8 | 8 |
| 9 namespace remoting { | 9 namespace remoting { |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 planes[1] = planes[2] = NULL; | 59 planes[1] = planes[2] = NULL; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void CapturerGdi::GetDataStride(int strides[]) const { | 62 void CapturerGdi::GetDataStride(int strides[]) const { |
| 63 // Only the first plane has data. | 63 // Only the first plane has data. |
| 64 strides[0] = bytes_per_row_; | 64 strides[0] = bytes_per_row_; |
| 65 strides[1] = strides[2] = 0; | 65 strides[1] = strides[2] = 0; |
| 66 } | 66 } |
| 67 | 67 |
| 68 int CapturerGdi::GetWidth() const { | 68 int CapturerGdi::GetWidth() const { |
| 69 if (!width_) | 69 return GetSystemMetrics(SM_CXSCREEN); |
| 70 width_ = GetSystemMetrics(SM_CXSCREEN); | |
| 71 return width_; | |
| 72 } | 70 } |
| 73 | 71 |
| 74 int CapturerGdi::GetHeight() const { | 72 int CapturerGdi::GetHeight() const { |
| 75 if (!height_) | 73 return GetSystemMetrics(SM_CYSCREEN); |
| 76 height_ = GetSystemMetrics(SM_CYSCREEN); | |
| 77 return height_; | |
| 78 } | 74 } |
| 79 | 75 |
| 80 // TODO(fbarchard): handle error cases. | 76 // TODO(fbarchard): handle error cases. |
| 81 void CapturerGdi::InitializeBuffers() { | 77 void CapturerGdi::InitializeBuffers() { |
| 82 desktop_dc_ = GetDC(GetDesktopWindow()); | 78 desktop_dc_ = GetDC(GetDesktopWindow()); |
| 83 memory_dc_ = CreateCompatibleDC(desktop_dc_); | 79 memory_dc_ = CreateCompatibleDC(desktop_dc_); |
| 84 | 80 |
| 85 // Create a bitmap to keep the desktop image. | 81 // Create a bitmap to keep the desktop image. |
| 86 width_ = GetSystemMetrics(SM_CXSCREEN); | 82 width_ = GetSystemMetrics(SM_CXSCREEN); |
| 87 height_ = GetSystemMetrics(SM_CYSCREEN); | 83 height_ = GetSystemMetrics(SM_CYSCREEN); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 115 } |
| 120 // Selection the target bitmap into the memory dc. | 116 // Selection the target bitmap into the memory dc. |
| 121 SelectObject(memory_dc_, target_bitmap_[current_buffer_]); | 117 SelectObject(memory_dc_, target_bitmap_[current_buffer_]); |
| 122 | 118 |
| 123 // And then copy the rect from desktop to memory. | 119 // And then copy the rect from desktop to memory. |
| 124 BitBlt(memory_dc_, 0, 0, width_, height_, desktop_dc_, 0, 0, | 120 BitBlt(memory_dc_, 0, 0, width_, height_, desktop_dc_, 0, 0, |
| 125 SRCCOPY | CAPTUREBLT); | 121 SRCCOPY | CAPTUREBLT); |
| 126 } | 122 } |
| 127 | 123 |
| 128 } // namespace remoting | 124 } // namespace remoting |
| OLD | NEW |