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

Side by Side Diff: remoting/client/plugin/pepper_video_renderer_3d.cc

Issue 2150833002: [Chromoting] Fallback to use software renderer if desktop image size is larger than GPU limitaiton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve review comments 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/plugin/pepper_video_renderer_3d.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/plugin/pepper_video_renderer_3d.h" 5 #include "remoting/client/plugin/pepper_video_renderer_3d.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (shader_program_) 84 if (shader_program_)
85 gles2_if_->DeleteProgram(graphics_.pp_resource(), shader_program_); 85 gles2_if_->DeleteProgram(graphics_.pp_resource(), shader_program_);
86 } 86 }
87 87
88 void PepperVideoRenderer3D::SetPepperContext( 88 void PepperVideoRenderer3D::SetPepperContext(
89 pp::Instance* instance, 89 pp::Instance* instance,
90 EventHandler* event_handler) { 90 EventHandler* event_handler) {
91 DCHECK(event_handler); 91 DCHECK(event_handler);
92 DCHECK(!event_handler_); 92 DCHECK(!event_handler_);
93 93
94 fallback_renderer_.SetPepperContext(instance, event_handler);
95
94 event_handler_ = event_handler; 96 event_handler_ = event_handler;
95 pp_instance_ = instance; 97 pp_instance_ = instance;
96 } 98 }
97 99
98 void PepperVideoRenderer3D::OnViewChanged(const pp::View& view) { 100 void PepperVideoRenderer3D::OnViewChanged(const pp::View& view) {
101 fallback_renderer_.OnViewChanged(view);
102
99 pp::Size size = view.GetRect().size(); 103 pp::Size size = view.GetRect().size();
100 float scale = view.GetDeviceScale(); 104 float scale = view.GetDeviceScale();
101 view_size_.set(ceilf(size.width() * scale), ceilf(size.height() * scale)); 105 view_size_.set(ceilf(size.width() * scale), ceilf(size.height() * scale));
102 graphics_.ResizeBuffers(view_size_.width(), view_size_.height()); 106 graphics_.ResizeBuffers(view_size_.width(), view_size_.height());
103 107
104 force_repaint_ = true; 108 force_repaint_ = true;
105 PaintIfNeeded(); 109 PaintIfNeeded();
106 } 110 }
107 111
108 void PepperVideoRenderer3D::EnableDebugDirtyRegion(bool enable) { 112 void PepperVideoRenderer3D::EnableDebugDirtyRegion(bool enable) {
113 fallback_renderer_.EnableDebugDirtyRegion(enable);
109 debug_dirty_region_ = enable; 114 debug_dirty_region_ = enable;
110 } 115 }
111 116
112 bool PepperVideoRenderer3D::Initialize( 117 bool PepperVideoRenderer3D::Initialize(
113 const ClientContext& context, 118 const ClientContext& context,
114 protocol::FrameStatsConsumer* stats_consumer) { 119 protocol::FrameStatsConsumer* stats_consumer) {
120 bool fallback_renderer_initialize_result =
121 fallback_renderer_.Initialize(context, stats_consumer);
122 DCHECK(fallback_renderer_initialize_result);
123
115 stats_consumer_ = stats_consumer; 124 stats_consumer_ = stats_consumer;
116 125
117 const int32_t context_attributes[] = { 126 const int32_t context_attributes[] = {
118 PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8, 127 PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
119 PP_GRAPHICS3DATTRIB_BLUE_SIZE, 8, 128 PP_GRAPHICS3DATTRIB_BLUE_SIZE, 8,
120 PP_GRAPHICS3DATTRIB_GREEN_SIZE, 8, 129 PP_GRAPHICS3DATTRIB_GREEN_SIZE, 8,
121 PP_GRAPHICS3DATTRIB_RED_SIZE, 8, 130 PP_GRAPHICS3DATTRIB_RED_SIZE, 8,
122 PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 0, 131 PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 0,
123 PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 0, 132 PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 0,
124 PP_GRAPHICS3DATTRIB_SAMPLES, 0, 133 PP_GRAPHICS3DATTRIB_SAMPLES, 0,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 static const float kVertices[] = { 168 static const float kVertices[] = {
160 -1, -1, -1, 1, 1, -1, 1, 1, // Position coordinates. 169 -1, -1, -1, 1, 1, -1, 1, 1, // Position coordinates.
161 0, 1, 0, 0, 1, 1, 1, 0, // Texture coordinates. 170 0, 1, 0, 0, 1, 1, 1, 0, // Texture coordinates.
162 }; 171 };
163 172
164 GLuint buffer; 173 GLuint buffer;
165 gles2_if_->GenBuffers(graphics_3d, 1, &buffer); 174 gles2_if_->GenBuffers(graphics_3d, 1, &buffer);
166 gles2_if_->BindBuffer(graphics_3d, GL_ARRAY_BUFFER, buffer); 175 gles2_if_->BindBuffer(graphics_3d, GL_ARRAY_BUFFER, buffer);
167 gles2_if_->BufferData(graphics_3d, GL_ARRAY_BUFFER, sizeof(kVertices), 176 gles2_if_->BufferData(graphics_3d, GL_ARRAY_BUFFER, sizeof(kVertices),
168 kVertices, GL_STATIC_DRAW); 177 kVertices, GL_STATIC_DRAW);
178 gles2_if_->GetIntegerv(
179 graphics_3d, GL_MAX_TEXTURE_SIZE, &gl_max_texture_size_);
169 180
170 CheckGLError(); 181 CheckGLError();
171 182
172 return true; 183 return true;
173 } 184 }
174 185
175 void PepperVideoRenderer3D::OnSessionConfig( 186 void PepperVideoRenderer3D::OnSessionConfig(
176 const protocol::SessionConfig& config) { 187 const protocol::SessionConfig& config) {
188 fallback_renderer_.OnSessionConfig(config);
189
177 PP_VideoProfile video_profile = PP_VIDEOPROFILE_VP8_ANY; 190 PP_VideoProfile video_profile = PP_VIDEOPROFILE_VP8_ANY;
178 switch (config.video_config().codec) { 191 switch (config.video_config().codec) {
179 case protocol::ChannelConfig::CODEC_VP8: 192 case protocol::ChannelConfig::CODEC_VP8:
180 video_profile = PP_VIDEOPROFILE_VP8_ANY; 193 video_profile = PP_VIDEOPROFILE_VP8_ANY;
181 break; 194 break;
182 case protocol::ChannelConfig::CODEC_VP9: 195 case protocol::ChannelConfig::CODEC_VP9:
183 video_profile = PP_VIDEOPROFILE_VP9_ANY; 196 video_profile = PP_VIDEOPROFILE_VP9_ANY;
184 break; 197 break;
185 default: 198 default:
186 NOTREACHED(); 199 NOTREACHED();
(...skipping 18 matching lines...) Expand all
205 return nullptr; 218 return nullptr;
206 } 219 }
207 220
208 protocol::FrameStatsConsumer* PepperVideoRenderer3D::GetFrameStatsConsumer() { 221 protocol::FrameStatsConsumer* PepperVideoRenderer3D::GetFrameStatsConsumer() {
209 return stats_consumer_; 222 return stats_consumer_;
210 } 223 }
211 224
212 void PepperVideoRenderer3D::ProcessVideoPacket( 225 void PepperVideoRenderer3D::ProcessVideoPacket(
213 std::unique_ptr<VideoPacket> packet, 226 std::unique_ptr<VideoPacket> packet,
214 const base::Closure& done) { 227 const base::Closure& done) {
228 if (!use_fallback_renderer_) {
229 use_fallback_renderer_ =
230 packet->format().screen_width() > gl_max_texture_size_ ||
231 packet->format().screen_height() > gl_max_texture_size_;
Hzj_jie 2016/07/15 02:30:50 AFAICT, this check won't work for debug build. gle
Sergey Ulanov 2016/07/15 23:39:56 This is concerning. Is it in debug builds of the w
Hzj_jie 2016/07/16 01:19:21 Sorry, I have made a wrong assumption. Actually we
232 if (use_fallback_renderer_) {
233 // Clear current instance and use fallback_renderer_.
234 current_picture_frames_.clear();
235 current_picture_.reset();
236 next_picture_frames_.clear();
237 next_picture_.reset();
238 decoded_frames_.clear();
239 pending_frames_.clear();
240 graphics_ = pp::Graphics3D();
241 video_decoder_ = pp::VideoDecoder();
242 }
243 }
244
245 if (use_fallback_renderer_) {
246 fallback_renderer_.GetVideoStub()->ProcessVideoPacket(
247 std::move(packet), done);
248 return;
249 }
250
215 VideoPacket* packet_ptr = packet.get(); 251 VideoPacket* packet_ptr = packet.get();
216 std::unique_ptr<FrameTracker> frame_tracker( 252 std::unique_ptr<FrameTracker> frame_tracker(
217 new FrameTracker(std::move(packet), stats_consumer_, done)); 253 new FrameTracker(std::move(packet), stats_consumer_, done));
218 254
219 // Don't need to do anything if the packet is empty. Host sends empty video 255 // Don't need to do anything if the packet is empty. Host sends empty video
220 // packets when the screen is not changing. 256 // packets when the screen is not changing.
221 if (packet_ptr->data().empty()) 257 if (packet_ptr->data().empty())
222 return; 258 return;
223 259
224 if (!frame_received_) { 260 if (!frame_received_) {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 gles2_if_->AttachShader(graphics_.pp_resource(), shader_program_, shader); 566 gles2_if_->AttachShader(graphics_.pp_resource(), shader_program_, shader);
531 gles2_if_->DeleteShader(graphics_.pp_resource(), shader); 567 gles2_if_->DeleteShader(graphics_.pp_resource(), shader);
532 } 568 }
533 569
534 void PepperVideoRenderer3D::CheckGLError() { 570 void PepperVideoRenderer3D::CheckGLError() {
535 GLenum error = gles2_if_->GetError(graphics_.pp_resource()); 571 GLenum error = gles2_if_->GetError(graphics_.pp_resource());
536 CHECK_EQ(error, static_cast<GLenum>(GL_NO_ERROR)) << "GL error: " << error; 572 CHECK_EQ(error, static_cast<GLenum>(GL_NO_ERROR)) << "GL error: " << error;
537 } 573 }
538 574
539 } // namespace remoting 575 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/pepper_video_renderer_3d.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698