OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "remoting/client/gl_desktop.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "remoting/client/gl_canvas.h" | |
9 #include "remoting/client/gl_render_layer.h" | |
10 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | |
11 | |
12 namespace { | |
13 | |
14 const int kTextureId = 0; | |
15 const int kBytesPerPixel = 4; | |
Sergey Ulanov
2016/07/09 01:01:20
use webrtc::DesktopFrame::kBytesPerPixel
Yuwei
2016/07/11 22:38:23
Done.
| |
16 | |
17 } | |
Sergey Ulanov
2016/07/09 01:01:20
// namespace
Yuwei
2016/07/11 22:38:23
Done.
| |
18 | |
19 namespace remoting { | |
20 | |
21 GlDesktop::GlDesktop() {} | |
22 | |
23 GlDesktop::~GlDesktop() {} | |
24 | |
25 void GlDesktop::SetCanvas(GlCanvas* canvas) { | |
26 if (!canvas) { | |
27 layer_.reset(); | |
28 return; | |
29 } | |
30 layer_.reset(new GlRenderLayer(kTextureId, canvas)); | |
31 if (last_frame_) { | |
32 layer_->SetTexture(last_frame_->data(), last_frame_->size().width(), | |
33 last_frame_->size().height()); | |
34 } | |
35 } | |
36 | |
37 void GlDesktop::SetVideoFrame(std::unique_ptr<webrtc::DesktopFrame> frame) { | |
38 if (layer_) { | |
39 if (!last_frame_ || frame->size().width() != last_frame_->size().width() || | |
Sergey Ulanov
2016/07/09 01:01:20
!frame->size().equal(last_frame_->size())
to avoid
Yuwei
2016/07/11 22:38:23
Done.
| |
40 frame->size().height() != last_frame_->size().height()) { | |
41 layer_->SetTexture(frame->data(), frame->size().width(), | |
42 frame->size().height()); | |
43 } else { | |
44 for (webrtc::DesktopRegion::Iterator i(frame->updated_region()); | |
45 !i.IsAtEnd(); i.Advance()) { | |
46 const uint8_t* rect_start = | |
47 reinterpret_cast<const uint8_t*>(frame->data()) + | |
Sergey Ulanov
2016/07/09 01:01:20
Don't need this cast.
Yuwei
2016/07/11 22:38:23
Done.
| |
48 frame->stride() * i.rect().top() + i.rect().left() * kBytesPerPixel; | |
Sergey Ulanov
2016/07/09 01:01:20
Use DesktopFrame::GetFrameDataAtPos(i.rect().top_l
| |
49 layer_->UpdateTexture(rect_start, i.rect().left(), i.rect().top(), | |
50 i.rect().width(), i.rect().height(), | |
51 frame->stride() / kBytesPerPixel); | |
Sergey Ulanov
2016/07/09 01:01:20
stride() may not be multiple of kBytesPerPixel. Pa
Yuwei
2016/07/09 01:21:24
Hmm... The problem is GL_UNPACK_ROW_LENGTH expects
Sergey Ulanov
2016/07/13 04:42:11
hm, yeah. I don't know of any real world scenario
Yuwei
2016/07/13 18:14:16
Done. Acknowledged.
| |
52 } | |
53 } | |
54 } | |
55 last_frame_ = std::move(frame); | |
56 } | |
57 | |
58 void GlDesktop::Draw() { | |
59 if (layer_ && last_frame_) { | |
60 layer_->Draw(); | |
61 } | |
62 } | |
63 | |
64 } // namespace remoting | |
OLD | NEW |