Index: webrtc/modules/desktop_capture/screen_drawer_win.cc |
diff --git a/webrtc/modules/desktop_capture/screen_drawer_win.cc b/webrtc/modules/desktop_capture/screen_drawer_win.cc |
index 6ef414dda99f271f0d11030f4a25adc1ae7706c7..061a40539e1cb72091347bf1b743b2315982e99c 100644 |
--- a/webrtc/modules/desktop_capture/screen_drawer_win.cc |
+++ b/webrtc/modules/desktop_capture/screen_drawer_win.cc |
@@ -13,7 +13,6 @@ |
#include <memory> |
#include "webrtc/modules/desktop_capture/screen_drawer.h" |
-#include "webrtc/system_wrappers/include/sleep.h" |
namespace webrtc { |
@@ -35,11 +34,6 @@ |
return hwnd; |
} |
-COLORREF ColorToRef(RgbaColor color) { |
- // Windows device context does not support alpha. |
- return RGB(color.red, color.green, color.blue); |
-} |
- |
// A ScreenDrawer implementation for Windows. |
class ScreenDrawerWin : public ScreenDrawer { |
public: |
@@ -48,17 +42,10 @@ |
// ScreenDrawer interface. |
DesktopRect DrawableRegion() override; |
- void DrawRectangle(DesktopRect rect, RgbaColor color) override; |
+ void DrawRectangle(DesktopRect rect, uint32_t rgba) override; |
void Clear() override; |
- void WaitForPendingDraws() override; |
private: |
- // Draw a line with |color|. |
- void DrawLine(DesktopVector start, DesktopVector end, RgbaColor color); |
- |
- // Draw a dot with |color|. |
- void DrawDot(DesktopVector vect, RgbaColor color); |
- |
const DesktopRect rect_; |
HWND window_; |
HDC hdc_; |
@@ -70,12 +57,8 @@ |
window_(CreateDrawerWindow(rect_)), |
hdc_(GetWindowDC(window_)) { |
// We do not need to handle any messages for the |window_|, so disable Windows |
- // from processing windows ghosting feature. |
+ // process windows ghosting feature. |
DisableProcessWindowsGhosting(); |
- |
- // Always use stock pen (DC_PEN) and brush (DC_BRUSH). |
- SelectObject(hdc_, GetStockObject(DC_PEN)); |
- SelectObject(hdc_, GetStockObject(DC_BRUSH)); |
} |
ScreenDrawerWin::~ScreenDrawerWin() { |
@@ -88,51 +71,20 @@ |
return rect_; |
} |
-void ScreenDrawerWin::DrawRectangle(DesktopRect rect, RgbaColor color) { |
- if (rect.width() == 1 && rect.height() == 1) { |
- // Rectangle function cannot draw a 1 pixel rectangle. |
- DrawDot(rect.top_left(), color); |
- return; |
- } |
- |
- if (rect.width() == 1 || rect.height() == 1) { |
- // Rectangle function cannot draw a 1 pixel rectangle. |
- DrawLine(rect.top_left(), DesktopVector(rect.right(), rect.bottom()), |
- color); |
- return; |
- } |
- |
- SetDCBrushColor(hdc_, ColorToRef(color)); |
- SetDCPenColor(hdc_, ColorToRef(color)); |
+void ScreenDrawerWin::DrawRectangle(DesktopRect rect, uint32_t rgba) { |
+ int r = (rgba & 0xff00) >> 8; |
+ int g = (rgba & 0xff0000) >> 16; |
+ int b = (rgba & 0xff000000) >> 24; |
+ // Windows device context does not support Alpha. |
+ SelectObject(hdc_, GetStockObject(DC_PEN)); |
+ SelectObject(hdc_, GetStockObject(DC_BRUSH)); |
+ SetDCBrushColor(hdc_, RGB(r, g, b)); |
+ SetDCPenColor(hdc_, RGB(r, g, b)); |
Rectangle(hdc_, rect.left(), rect.top(), rect.right(), rect.bottom()); |
} |
void ScreenDrawerWin::Clear() { |
- DrawRectangle(rect_, RgbaColor(0, 0, 0)); |
-} |
- |
-// TODO(zijiehe): Find the right signal to indicate the finish of all pending |
-// paintings. |
-void ScreenDrawerWin::WaitForPendingDraws() { |
- // DirectX capturer reads data from GPU, so there is a certain delay before |
- // Windows sends the data to GPU. |
- SleepMs(100); |
-} |
- |
-void ScreenDrawerWin::DrawLine(DesktopVector start, |
- DesktopVector end, |
- RgbaColor color) { |
- POINT points[2]; |
- points[0].x = start.x(); |
- points[0].y = start.y(); |
- points[1].x = end.x(); |
- points[1].y = end.y(); |
- SetDCPenColor(hdc_, ColorToRef(color)); |
- Polyline(hdc_, points, 2); |
-} |
- |
-void ScreenDrawerWin::DrawDot(DesktopVector vect, RgbaColor color) { |
- SetPixel(hdc_, vect.x(), vect.y(), ColorToRef(color)); |
+ DrawRectangle(DrawableRegion(), 0); |
} |
} // namespace |