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

Side by Side Diff: remoting/client/gl_desktop.cc

Issue 2156713002: [Chromoting] Implement DualBufferFrameConsumer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's Feedback Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « remoting/client/gl_desktop.h ('k') | remoting/client/software_video_renderer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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/gl_desktop.h" 5 #include "remoting/client/gl_desktop.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "remoting/client/gl_canvas.h" 8 #include "remoting/client/gl_canvas.h"
9 #include "remoting/client/gl_render_layer.h" 9 #include "remoting/client/gl_render_layer.h"
10 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" 10 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
11 11
12 namespace { 12 namespace {
13 13
14 const int kTextureId = 0; 14 const int kTextureId = 0;
15 15
16 } // namespace 16 } // namespace
17 17
18 namespace remoting { 18 namespace remoting {
19 19
20 GlDesktop::GlDesktop() {} 20 GlDesktop::GlDesktop() {}
21 21
22 GlDesktop::~GlDesktop() {} 22 GlDesktop::~GlDesktop() {}
23 23
24 void GlDesktop::SetCanvas(GlCanvas* canvas) { 24 void GlDesktop::SetCanvas(GlCanvas* canvas) {
25 if (!canvas) { 25 if (!canvas) {
26 layer_.reset(); 26 layer_.reset();
27 return; 27 return;
28 } 28 }
29 layer_.reset(new GlRenderLayer(kTextureId, canvas)); 29 layer_.reset(new GlRenderLayer(kTextureId, canvas));
30 if (last_frame_) { 30 last_desktop_size_.set(0, 0);
31 layer_->SetTexture(last_frame_->data(), last_frame_->size().width(), 31 }
32 last_frame_->size().height()); 32
33 void GlDesktop::SetVideoFrame(std::unique_ptr<webrtc::DesktopFrame> frame) {
34 if (!layer_) {
35 return;
36 }
37 if (!frame->size().equals(last_desktop_size_)) {
38 layer_->SetTexture(frame->data(), frame->size().width(),
39 frame->size().height());
40 last_desktop_size_.set(frame->size().width(), frame->size().height());
41 } else {
42 for (webrtc::DesktopRegion::Iterator i(frame->updated_region());
43 !i.IsAtEnd(); i.Advance()) {
44 const uint8_t* rect_start =
45 frame->GetFrameDataAtPos(i.rect().top_left());
46 layer_->UpdateTexture(
47 rect_start, i.rect().left(), i.rect().top(), i.rect().width(),
48 i.rect().height(), frame->stride());
49 }
33 } 50 }
34 } 51 }
35 52
36 void GlDesktop::SetVideoFrame(std::unique_ptr<webrtc::DesktopFrame> frame) {
37 if (layer_) {
38 if (!last_frame_ || !frame->size().equals(last_frame_->size())) {
39 layer_->SetTexture(frame->data(), frame->size().width(),
40 frame->size().height());
41 } else {
42 for (webrtc::DesktopRegion::Iterator i(frame->updated_region());
43 !i.IsAtEnd(); i.Advance()) {
44 const uint8_t* rect_start =
45 frame->GetFrameDataAtPos(i.rect().top_left());
46 layer_->UpdateTexture(
47 rect_start, i.rect().left(), i.rect().top(), i.rect().width(),
48 i.rect().height(), frame->stride());
49 }
50 }
51 }
52 last_frame_ = std::move(frame);
53 }
54
55 void GlDesktop::Draw() { 53 void GlDesktop::Draw() {
56 if (layer_ && last_frame_) { 54 if (layer_ && !last_desktop_size_.is_empty()) {
57 layer_->Draw(1.f); 55 layer_->Draw(1.f);
58 } 56 }
59 } 57 }
60 58
61 } // namespace remoting 59 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/gl_desktop.h ('k') | remoting/client/software_video_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698