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

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

Issue 2045963004: [Remoting] OpenGL Rendering Layer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sort of fix build error 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
OLDNEW
(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
16 } // namespace
17
18 namespace remoting {
19
20 GlDesktop::GlDesktop() {}
21
22 GlDesktop::~GlDesktop() {}
23
24 void GlDesktop::SetCanvas(GlCanvas* canvas) {
25 if (!canvas) {
26 layer_.reset();
27 return;
28 }
29 layer_.reset(new GlRenderLayer(kTextureId, canvas));
30 if (last_frame_) {
31 layer_->SetTexture(last_frame_->data(), last_frame_->size().width(),
32 last_frame_->size().height());
33 }
34 }
35
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() {
56 if (layer_ && last_frame_) {
57 layer_->Draw();
58 }
59 }
60
61 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698