| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_HOST_CAPTURER_GDI_H_ | |
| 6 #define REMOTING_HOST_CAPTURER_GDI_H_ | |
| 7 | |
| 8 #include <windows.h> | |
| 9 typedef HBITMAP BitmapRef; | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "remoting/host/capturer.h" | |
| 12 #include "remoting/host/capturer_helper.h" | |
| 13 | |
| 14 namespace remoting { | |
| 15 | |
| 16 class Differ; | |
| 17 | |
| 18 // CapturerGdi captures 32bit RGB using GDI. | |
| 19 // | |
| 20 // CapturerGdi is double-buffered as required by Capturer. See | |
| 21 // remoting/host/capturer.h. | |
| 22 class CapturerGdi : public Capturer { | |
| 23 public: | |
| 24 CapturerGdi(); | |
| 25 virtual ~CapturerGdi(); | |
| 26 | |
| 27 // Capturer interface. | |
| 28 virtual void ScreenConfigurationChanged(); | |
| 29 virtual media::VideoFrame::Format pixel_format() const; | |
| 30 virtual void ClearInvalidRects(); | |
| 31 virtual void InvalidateRects(const InvalidRects& inval_rects); | |
| 32 virtual void InvalidateScreen(const gfx::Size& size); | |
| 33 virtual void InvalidateFullScreen(); | |
| 34 virtual void CaptureInvalidRects(CaptureCompletedCallback* callback); | |
| 35 virtual const gfx::Size& size_most_recent() const; | |
| 36 | |
| 37 private: | |
| 38 struct VideoFrameBuffer { | |
| 39 VideoFrameBuffer(void* data, const gfx::Size& size, int bytes_per_pixel, | |
| 40 int bytes_per_row) | |
| 41 : data(data), size(size), bytes_per_pixel(bytes_per_pixel), | |
| 42 bytes_per_row(bytes_per_row) { | |
| 43 } | |
| 44 VideoFrameBuffer() { | |
| 45 data = 0; | |
| 46 size = gfx::Size(0, 0); | |
| 47 bytes_per_pixel = 0; | |
| 48 bytes_per_row = 0; | |
| 49 } | |
| 50 void* data; | |
| 51 gfx::Size size; | |
| 52 int bytes_per_pixel; | |
| 53 int bytes_per_row; | |
| 54 }; | |
| 55 | |
| 56 // Make sure that the current buffer has the same size as the screen. | |
| 57 void UpdateBufferCapture(const gfx::Size& size); | |
| 58 | |
| 59 // Allocate memory for a buffer of a given size, freeing any memory previously | |
| 60 // allocated for that buffer. | |
| 61 void ReallocateBuffer(int buffer_index, const gfx::Size& size); | |
| 62 | |
| 63 void CalculateInvalidRects(); | |
| 64 void CaptureRects(const InvalidRects& rects, | |
| 65 CaptureCompletedCallback* callback); | |
| 66 | |
| 67 void ReleaseBuffers(); | |
| 68 // Generates an image in the current buffer. | |
| 69 void CaptureImage(); | |
| 70 | |
| 71 // Gets the current screen size and calls ScreenConfigurationChanged | |
| 72 // if the screen size has changed. | |
| 73 void MaybeChangeScreenConfiguration(); | |
| 74 | |
| 75 // Gets the screen size. | |
| 76 gfx::Size GetScreenSize(); | |
| 77 | |
| 78 // A thread-safe list of invalid rectangles, and the size of the most | |
| 79 // recently captured screen. | |
| 80 CapturerHelper helper; | |
| 81 | |
| 82 // There are two buffers for the screen images, as required by Capturer. | |
| 83 static const int kNumBuffers = 2; | |
| 84 VideoFrameBuffer buffers_[kNumBuffers]; | |
| 85 | |
| 86 // Gdi specific information about screen. | |
| 87 HDC desktop_dc_; | |
| 88 HDC memory_dc_; | |
| 89 HBITMAP target_bitmap_[kNumBuffers]; | |
| 90 | |
| 91 // The screen size attached to the device contexts through which the screen | |
| 92 // is captured. | |
| 93 gfx::Size dc_size_; | |
| 94 | |
| 95 // The current buffer with valid data for reading. | |
| 96 int current_buffer_; | |
| 97 | |
| 98 // Format of pixels returned in buffer. | |
| 99 media::VideoFrame::Format pixel_format_; | |
| 100 | |
| 101 // Class to calculate the difference between two screen bitmaps. | |
| 102 scoped_ptr<Differ> differ_; | |
| 103 | |
| 104 // True if we should force a fullscreen capture. | |
| 105 bool capture_fullscreen_; | |
| 106 | |
| 107 DISALLOW_COPY_AND_ASSIGN(CapturerGdi); | |
| 108 }; | |
| 109 | |
| 110 } // namespace remoting | |
| 111 | |
| 112 #endif // REMOTING_HOST_CAPTURER_GDI_H_ | |
| OLD | NEW |