| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/client/x11_view.h" | 5 #include "remoting/client/x11_view.h" |
| 6 | 6 |
| 7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 #include <X11/Xutil.h> | 8 #include <X11/Xutil.h> |
| 9 #include <X11/extensions/Xrender.h> | 9 #include <X11/extensions/Xrender.h> |
| 10 #include <X11/extensions/Xcomposite.h> | 10 #include <X11/extensions/Xcomposite.h> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "remoting/client/decoder_verbatim.h" | 13 #include "remoting/client/decoder_verbatim.h" |
| 14 | 14 |
| 15 namespace remoting { | 15 namespace remoting { |
| 16 | 16 |
| 17 X11View::X11View(Display* display, XID window, int width, int height) | 17 X11View::X11View(Display* display, XID window, int width, int height) |
| 18 : display_(display), | 18 : display_(display), |
| 19 window_(window), | 19 window_(window), |
| 20 width_(width), | 20 width_(width), |
| 21 height_(height), | 21 height_(height), |
| 22 picture_(0) { | 22 picture_(0) { |
| 23 media::VideoFrame::CreateFrame(media::VideoFrame::RGB32, width_, height_, |
| 24 base::TimeDelta(), base::TimeDelta(), &frame_); |
| 25 DCHECK(frame_); |
| 23 } | 26 } |
| 24 | 27 |
| 25 X11View::~X11View() { | 28 X11View::~X11View() { |
| 26 } | 29 } |
| 27 | 30 |
| 28 void X11View::Paint() { | 31 void X11View::Paint() { |
| 29 // TODO(hclam): Paint only the updated regions. | 32 // TODO(hclam): Paint only the updated regions. |
| 30 all_update_rects_.clear(); | 33 all_update_rects_.clear(); |
| 31 | 34 |
| 32 // If we have not initialized the render target then do it now. | 35 // If we have not initialized the render target then do it now. |
| 33 if (!frame_) | 36 if (!picture_) |
| 34 InitPaintTarget(); | 37 InitPaintTarget(); |
| 35 | 38 |
| 36 // Upload the image to a pixmap. And then create a picture from the pixmap | 39 // Upload the image to a pixmap. And then create a picture from the pixmap |
| 37 // and composite the picture over the picture representing the window. | 40 // and composite the picture over the picture representing the window. |
| 38 | 41 |
| 39 // Creates a XImage. | 42 // Creates a XImage. |
| 40 XImage image; | 43 XImage image; |
| 41 memset(&image, 0, sizeof(image)); | 44 memset(&image, 0, sizeof(image)); |
| 42 image.width = width_; | 45 image.width = width_; |
| 43 image.height = height_; | 46 image.height = height_; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 XWindowAttributes attr; | 108 XWindowAttributes attr; |
| 106 XGetWindowAttributes(display_, window_, &attr); | 109 XGetWindowAttributes(display_, window_, &attr); |
| 107 | 110 |
| 108 XRenderPictFormat* pictformat = XRenderFindVisualFormat( | 111 XRenderPictFormat* pictformat = XRenderFindVisualFormat( |
| 109 display_, | 112 display_, |
| 110 attr.visual); | 113 attr.visual); |
| 111 CHECK(pictformat) << "XRENDER does not support default visual"; | 114 CHECK(pictformat) << "XRENDER does not support default visual"; |
| 112 | 115 |
| 113 picture_ = XRenderCreatePicture(display_, window_, pictformat, 0, NULL); | 116 picture_ = XRenderCreatePicture(display_, window_, pictformat, 0, NULL); |
| 114 CHECK(picture_) << "Backing picture not created"; | 117 CHECK(picture_) << "Backing picture not created"; |
| 115 | |
| 116 // Create the video frame to carry the decoded image. | |
| 117 media::VideoFrame::CreateFrame(media::VideoFrame::RGB32, width_, height_, | |
| 118 base::TimeDelta(), base::TimeDelta(), &frame_); | |
| 119 DCHECK(frame_); | |
| 120 } | 118 } |
| 121 | 119 |
| 122 void X11View::HandleBeginUpdateStream(HostMessage* msg) { | 120 void X11View::HandleBeginUpdateStream(HostMessage* msg) { |
| 123 scoped_ptr<HostMessage> deleter(msg); | 121 scoped_ptr<HostMessage> deleter(msg); |
| 124 | 122 |
| 125 // TODO(hclam): Use the information from the message to create the decoder. | 123 // TODO(hclam): Use the information from the message to create the decoder. |
| 126 // We lazily construct the decoder. | 124 // We lazily construct the decoder. |
| 127 if (!decoder_.get()) { | 125 if (!decoder_.get()) { |
| 128 decoder_.reset(new DecoderVerbatim()); | 126 decoder_.reset(new DecoderVerbatim()); |
| 129 } | 127 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 XEvent event; | 162 XEvent event; |
| 165 event.type = Expose; | 163 event.type = Expose; |
| 166 XSendEvent(display_, static_cast<int>(window_), true, ExposureMask, &event); | 164 XSendEvent(display_, static_cast<int>(window_), true, ExposureMask, &event); |
| 167 } | 165 } |
| 168 | 166 |
| 169 void X11View::OnDecodeDone() { | 167 void X11View::OnDecodeDone() { |
| 170 // Since we do synchronous decoding here there's nothing in this method. | 168 // Since we do synchronous decoding here there's nothing in this method. |
| 171 } | 169 } |
| 172 | 170 |
| 173 } // namespace remoting | 171 } // namespace remoting |
| OLD | NEW |