| 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
|
|
|