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

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

Issue 2268093002: [WebRTC] A real ScreenCapturer test (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 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/screen_drawer_linux.cc
diff --git a/webrtc/modules/desktop_capture/screen_drawer_linux.cc b/webrtc/modules/desktop_capture/screen_drawer_linux.cc
index 2aff80b6c7ce1259f48f32ef94b12121f0256ac5..0493b652313e7b938e3229198ca4408d7513ea4e 100644
--- a/webrtc/modules/desktop_capture/screen_drawer_linux.cc
+++ b/webrtc/modules/desktop_capture/screen_drawer_linux.cc
@@ -13,6 +13,7 @@
#include "webrtc/base/checks.h"
#include "webrtc/modules/desktop_capture/screen_drawer.h"
#include "webrtc/modules/desktop_capture/x11/shared_x_display.h"
+#include "webrtc/system_wrappers/include/sleep.h"
namespace webrtc {
@@ -26,8 +27,8 @@ class ScreenDrawerLinux : public ScreenDrawer {
// ScreenDrawer interface.
DesktopRect DrawableRegion() override;
- void DrawRectangle(DesktopRect rect, uint32_t rgba) override;
- void Clear() override;
+ void DrawRectangle(DesktopRect rect, uint32_t bgra) override;
+ void WaitForPendingPaintings() override;
private:
rtc::scoped_refptr<SharedXDisplay> display_;
@@ -74,16 +75,16 @@ DesktopRect ScreenDrawerLinux::DrawableRegion() {
return rect_;
}
-void ScreenDrawerLinux::DrawRectangle(DesktopRect rect, uint32_t rgba) {
- int r = (rgba & 0xff00) >> 8;
- int g = (rgba & 0xff0000) >> 16;
- int b = (rgba & 0xff000000) >> 24;
+void ScreenDrawerLinux::DrawRectangle(DesktopRect rect, uint32_t bgra) {
+ int b = (bgra & 0xff000000) >> 24;
+ int g = (bgra & 0xff0000) >> 16;
+ int r = (bgra & 0xff00) >> 8;
// X11 does not support Alpha.
XColor color;
// X11 uses 16 bits for each primary color.
- color.red = r * 256;
- color.green = g * 256;
- color.blue = b * 256;
+ color.red = r * 256 + r;
+ color.green = g * 256 + g;
+ color.blue = b * 256 + b;
color.flags = DoRed | DoGreen | DoBlue;
XAllocColor(display_->display(), colormap_, &color);
XSetForeground(display_->display(), context_, color.pixel);
@@ -92,15 +93,21 @@ void ScreenDrawerLinux::DrawRectangle(DesktopRect rect, uint32_t rgba) {
XFlush(display_->display());
}
-void ScreenDrawerLinux::Clear() {
- DrawRectangle(DrawableRegion(), 0);
+// TODO(zijiehe): Find the right signal from X11 to indicate the finish of all
+// pending paintings.
+void ScreenDrawerLinux::WaitForPendingPaintings() {
+ SleepMs(500);
}
} // namespace
// static
std::unique_ptr<ScreenDrawer> ScreenDrawer::Create() {
- return std::unique_ptr<ScreenDrawer>(new ScreenDrawerLinux());
+ if (SharedXDisplay::CreateDefault().get()) {
+ return std::unique_ptr<ScreenDrawer>(new ScreenDrawerLinux());
+ } else {
+ return nullptr;
+ }
}
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698