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

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

Issue 2623413004: [Remoting Android] Fix thread issue with OpenGL drawable (Closed)
Patch Set: PTAL Point Created 3 years, 11 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
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/display/gl_desktop.h" 5 #include "remoting/client/display/gl_desktop.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "remoting/client/display/canvas.h" 9 #include "remoting/client/display/canvas.h"
10 #include "remoting/client/display/gl_math.h" 10 #include "remoting/client/display/gl_math.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 } 51 }
52 52
53 } // namespace 53 } // namespace
54 54
55 struct GlDesktop::GlDesktopTextureContainer { 55 struct GlDesktop::GlDesktopTextureContainer {
56 std::unique_ptr<GlRenderLayer> layer; 56 std::unique_ptr<GlRenderLayer> layer;
57 webrtc::DesktopRect rect; 57 webrtc::DesktopRect rect;
58 }; 58 };
59 59
60 GlDesktop::GlDesktop() : weak_factory_(this) {} 60 GlDesktop::GlDesktop() : weak_factory_(this) {
61 weak_ptr_ = weak_factory_.GetWeakPtr();
62 }
61 63
62 GlDesktop::~GlDesktop() {} 64 GlDesktop::~GlDesktop() {}
63 65
64 void GlDesktop::SetCanvas(base::WeakPtr<Canvas> canvas) { 66 void GlDesktop::SetCanvas(base::WeakPtr<Canvas> canvas) {
65 last_desktop_size_.set(0, 0); 67 last_desktop_size_.set(0, 0);
66 textures_.clear(); 68 textures_.clear();
67 canvas_ = canvas; 69 canvas_ = canvas;
68 if (canvas) { 70 if (canvas) {
69 max_texture_size_ = canvas->GetMaxTextureSize(); 71 max_texture_size_ = canvas->GetMaxTextureSize();
70 } 72 }
71 } 73 }
72 74
73 void GlDesktop::SetVideoFrame(const webrtc::DesktopFrame& frame) { 75 void GlDesktop::SetVideoFrame(const webrtc::DesktopFrame& frame) {
74 if (!canvas_) { 76 if (!canvas_) {
75 return; 77 return;
76 } 78 }
77 if (!frame.size().equals(last_desktop_size_)) { 79 if (!frame.size().equals(last_desktop_size_)) {
78 last_desktop_size_.set(frame.size().width(), frame.size().height()); 80 last_desktop_size_.set(frame.size().width(), frame.size().height());
79 ReallocateTextures(last_desktop_size_); 81 ReallocateTextures(last_desktop_size_);
80 } 82 }
81 for (std::unique_ptr<GlDesktopTextureContainer>& texture : textures_) { 83 for (std::unique_ptr<GlDesktopTextureContainer>& texture : textures_) {
82 SetFrameForTexture(frame, texture->layer.get(), texture->rect); 84 SetFrameForTexture(frame, texture->layer.get(), texture->rect);
83 } 85 }
84 } 86 }
85 87
86 bool GlDesktop::Draw() { 88 bool GlDesktop::Draw() {
87 DCHECK(thread_checker_.CalledOnValidThread());
88 if (!textures_.empty() && !last_desktop_size_.is_empty()) { 89 if (!textures_.empty() && !last_desktop_size_.is_empty()) {
89 for (std::unique_ptr<GlDesktopTextureContainer>& texture : textures_) { 90 for (std::unique_ptr<GlDesktopTextureContainer>& texture : textures_) {
90 texture->layer->Draw(1.0f); 91 texture->layer->Draw(1.0f);
91 } 92 }
92 } 93 }
93 return false; 94 return false;
94 } 95 }
95 96
96 int GlDesktop::GetZIndex() { 97 int GlDesktop::GetZIndex() {
97 return Drawable::ZIndex::DESKTOP; 98 return Drawable::ZIndex::DESKTOP;
(...skipping 27 matching lines...) Expand all
125 FillRectangleVertexPositions(rect.left(), rect.top(), rect.width(), 126 FillRectangleVertexPositions(rect.left(), rect.top(), rect.width(),
126 rect.height(), &positions); 127 rect.height(), &positions);
127 container->layer->SetVertexPositions(positions); 128 container->layer->SetVertexPositions(positions);
128 textures_.push_back(std::move(container)); 129 textures_.push_back(std::move(container));
129 texture_id++; 130 texture_id++;
130 } 131 }
131 } 132 }
132 } 133 }
133 134
134 base::WeakPtr<Drawable> GlDesktop::GetWeakPtr() { 135 base::WeakPtr<Drawable> GlDesktop::GetWeakPtr() {
135 DCHECK(thread_checker_.CalledOnValidThread()); 136 return weak_ptr_;
136 return weak_factory_.GetWeakPtr();
137 } 137 }
138 138
139 } // namespace remoting 139 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698