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

Side by Side Diff: content/common/gpu/stream_texture_android.cc

Issue 148513004: Android: Always update SurfaceTexture when used for draw (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/common/gpu/stream_texture_android.h" 5 #include "content/common/gpu/stream_texture_android.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/common/android/surface_texture_peer.h" 8 #include "content/common/android/surface_texture_peer.h"
9 #include "content/common/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 #include "content/common/gpu/gpu_messages.h" 10 #include "content/common/gpu/gpu_messages.h"
11 #include "gpu/command_buffer/service/context_group.h" 11 #include "gpu/command_buffer/service/context_group.h"
12 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 12 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
13 #include "gpu/command_buffer/service/texture_manager.h" 13 #include "gpu/command_buffer/service/texture_manager.h"
14 #include "ui/gfx/size.h" 14 #include "ui/gfx/size.h"
15 #include "ui/gl/scoped_make_current.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 using gpu::gles2::ContextGroup; 19 using gpu::gles2::ContextGroup;
19 using gpu::gles2::GLES2Decoder; 20 using gpu::gles2::GLES2Decoder;
20 using gpu::gles2::TextureManager; 21 using gpu::gles2::TextureManager;
21 using gpu::gles2::TextureRef; 22 using gpu::gles2::TextureRef;
22 23
23 // static 24 // static
24 int32 StreamTexture::Create( 25 int32 StreamTexture::Create(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 59 }
59 60
60 return 0; 61 return 0;
61 } 62 }
62 63
63 StreamTexture::StreamTexture(GpuCommandBufferStub* owner_stub, 64 StreamTexture::StreamTexture(GpuCommandBufferStub* owner_stub,
64 int32 route_id, 65 int32 route_id,
65 uint32 texture_id) 66 uint32 texture_id)
66 : surface_texture_(new gfx::SurfaceTexture(texture_id)), 67 : surface_texture_(new gfx::SurfaceTexture(texture_id)),
67 size_(0, 0), 68 size_(0, 0),
68 has_updated_(false), 69 has_valid_frame_(false),
70 has_pending_frame_(false),
69 owner_stub_(owner_stub), 71 owner_stub_(owner_stub),
70 route_id_(route_id), 72 route_id_(route_id),
71 has_listener_(false), 73 has_listener_(false),
72 weak_factory_(this) { 74 weak_factory_(this) {
73 owner_stub->AddDestructionObserver(this); 75 owner_stub->AddDestructionObserver(this);
74 memset(current_matrix_, 0, sizeof(current_matrix_)); 76 memset(current_matrix_, 0, sizeof(current_matrix_));
75 owner_stub->channel()->AddRoute(route_id, this); 77 owner_stub->channel()->AddRoute(route_id, this);
76 } 78 }
77 79
78 StreamTexture::~StreamTexture() { 80 StreamTexture::~StreamTexture() {
(...skipping 14 matching lines...) Expand all
93 } 95 }
94 96
95 void StreamTexture::Destroy() { 97 void StreamTexture::Destroy() {
96 NOTREACHED(); 98 NOTREACHED();
97 } 99 }
98 100
99 void StreamTexture::WillUseTexImage() { 101 void StreamTexture::WillUseTexImage() {
100 if (!owner_stub_) 102 if (!owner_stub_)
101 return; 103 return;
102 104
103 // TODO(sievers): Update also when used in a different context. 105 if (surface_texture_.get() && has_pending_frame_) {
104 // Also see crbug.com/309162. 106 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current;
105 if (surface_texture_.get() && 107 bool needs_make_current =
106 owner_stub_->decoder()->GetGLContext()->IsCurrent(NULL)) { 108 owner_stub_->decoder()->GetGLContext()->IsCurrent(NULL);
109 // On Android we should not have to perform a real context switch here when
110 // using virtual contexts.
111 DCHECK(!needs_make_current || !owner_stub_->decoder()
112 ->GetContextGroup()
113 ->feature_info()
114 ->workarounds()
115 .use_virtualized_gl_contexts);
116 if (needs_make_current) {
117 scoped_make_current.reset(new ui::ScopedMakeCurrent(
118 owner_stub_->decoder()->GetGLContext(), owner_stub_->surface()));
119 }
107 surface_texture_->UpdateTexImage(); 120 surface_texture_->UpdateTexImage();
121 has_valid_frame_ = true;
122 has_pending_frame_ = false;
no sievers 2014/01/28 00:03:08 Argh, there is a problem. UpdateTexImage() has th
108 } 123 }
109 124
110 if (has_listener_) { 125 if (has_listener_ && has_valid_frame_) {
111 float mtx[16]; 126 float mtx[16];
112 surface_texture_->GetTransformMatrix(mtx); 127 surface_texture_->GetTransformMatrix(mtx);
113 128
114 // Only query the matrix once we have bound a valid frame. 129 // Only query the matrix once we have bound a valid frame.
115 if (has_updated_ && memcmp(current_matrix_, mtx, sizeof(mtx)) != 0) { 130 if (memcmp(current_matrix_, mtx, sizeof(mtx)) != 0) {
116 memcpy(current_matrix_, mtx, sizeof(mtx)); 131 memcpy(current_matrix_, mtx, sizeof(mtx));
117 132
118 GpuStreamTextureMsg_MatrixChanged_Params params; 133 GpuStreamTextureMsg_MatrixChanged_Params params;
119 memcpy(&params.m00, mtx, sizeof(mtx)); 134 memcpy(&params.m00, mtx, sizeof(mtx));
120 owner_stub_->channel()->Send( 135 owner_stub_->channel()->Send(
121 new GpuStreamTextureMsg_MatrixChanged(route_id_, params)); 136 new GpuStreamTextureMsg_MatrixChanged(route_id_, params));
122 } 137 }
123 } 138 }
124 } 139 }
125 140
126 void StreamTexture::OnFrameAvailable() { 141 void StreamTexture::OnFrameAvailable() {
127 has_updated_ = true; 142 has_pending_frame_ = true;
128 DCHECK(has_listener_); 143 DCHECK(has_listener_);
129 if (owner_stub_) { 144 if (owner_stub_) {
130 owner_stub_->channel()->Send( 145 owner_stub_->channel()->Send(
131 new GpuStreamTextureMsg_FrameAvailable(route_id_)); 146 new GpuStreamTextureMsg_FrameAvailable(route_id_));
132 } 147 }
133 } 148 }
134 149
135 gfx::Size StreamTexture::GetSize() { 150 gfx::Size StreamTexture::GetSize() {
136 return size_; 151 return size_;
137 } 152 }
(...skipping 22 matching lines...) Expand all
160 if (!owner_stub_) 175 if (!owner_stub_)
161 return; 176 return;
162 177
163 base::ProcessHandle process = owner_stub_->channel()->renderer_pid(); 178 base::ProcessHandle process = owner_stub_->channel()->renderer_pid();
164 179
165 SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer( 180 SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer(
166 process, surface_texture_, primary_id, secondary_id); 181 process, surface_texture_, primary_id, secondary_id);
167 } 182 }
168 183
169 } // namespace content 184 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/stream_texture_android.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698