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

Unified Diff: webrtc/modules/desktop_capture/desktop_frame_win.cc

Issue 1845113002: DirectX based screen capturer logic (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/desktop_capture/desktop_frame_win.cc
diff --git a/webrtc/modules/desktop_capture/desktop_frame_win.cc b/webrtc/modules/desktop_capture/desktop_frame_win.cc
index f139fb5cddf2bb7ea2b71a668fddb940b23441c0..ec0f198445c9cc9ebbc49f171971bb182ab8e2c8 100644
--- a/webrtc/modules/desktop_capture/desktop_frame_win.cc
+++ b/webrtc/modules/desktop_capture/desktop_frame_win.cc
@@ -16,6 +16,16 @@
namespace webrtc {
+using Microsoft::WRL::ComPtr;
+
+namespace {
+
+int CalculateStrideFromDesktopSize(DesktopSize size) {
+ return size.width() * DesktopFrame::kBytesPerPixel;
+}
+
+} // namespace
+
DesktopFrameWin::DesktopFrameWin(DesktopSize size,
int stride,
uint8_t* data,
@@ -34,7 +44,7 @@ DesktopFrameWin* DesktopFrameWin::Create(
DesktopSize size,
SharedMemoryFactory* shared_memory_factory,
HDC hdc) {
- int bytes_per_row = size.width() * kBytesPerPixel;
+ int bytes_per_row = CalculateStrideFromDesktopSize(size);
int buffer_size = bytes_per_row * size.height();
// Describe a device independent bitmap (DIB) that is the size of the desktop.
@@ -42,9 +52,9 @@ DesktopFrameWin* DesktopFrameWin::Create(
bmi.bmiHeader.biHeight = -size.height();
bmi.bmiHeader.biWidth = size.width();
bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = DesktopFrameWin::kBytesPerPixel * 8;
+ bmi.bmiHeader.biBitCount = DesktopFrame::kBytesPerPixel * 8;
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
- bmi.bmiHeader.biSizeImage = bytes_per_row * size.height();
+ bmi.bmiHeader.biSizeImage = buffer_size;
std::unique_ptr<SharedMemory> shared_memory;
HANDLE section_handle = nullptr;
@@ -67,4 +77,21 @@ DesktopFrameWin* DesktopFrameWin::Create(
std::move(shared_memory), bitmap);
}
+DesktopFrameWinDXGI::~DesktopFrameWinDXGI() {}
+
+DesktopFrameWinDXGI::DesktopFrameWinDXGI(DesktopSize size,
+ ComPtr<IDXGISurface> surface,
+ DXGI_MAPPED_RECT rect) :
Sergey Ulanov 2016/03/31 18:41:15 Do you really need to pass this parameter? It can
Hzj_jie 2016/04/05 23:15:17 Yes, I can move the logic in ScreenCapturerWinDire
+ DesktopFrame(size,
+ CalculateStrideFromDesktopSize(size),
Sergey Ulanov 2016/03/31 18:41:15 DXGI_MAPPED_RECT contains pitch field. Use it her
Hzj_jie 2016/04/05 23:15:17 Done.
+ rect.pBits,
+ nullptr),
+ surface_(surface) {}
+
+DesktopFrameWinDXGI::DesktopFrameWinDXGI(DesktopSize size) :
+ DesktopFrame(size,
+ 0,
+ nullptr,
+ nullptr) {}
+
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698