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

Unified 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: restore bindings for all targets Created 6 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/stream_texture_android.cc
diff --git a/content/common/gpu/stream_texture_android.cc b/content/common/gpu/stream_texture_android.cc
index 1d510e6c43c621e84ff80138c66c83fa1660f5f3..714125878ac44c8812fd2c7c5ed27f7497d91d3b 100644
--- a/content/common/gpu/stream_texture_android.cc
+++ b/content/common/gpu/stream_texture_android.cc
@@ -12,6 +12,7 @@
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/texture_manager.h"
#include "ui/gfx/size.h"
+#include "ui/gl/scoped_make_current.h"
namespace content {
@@ -65,7 +66,8 @@ StreamTexture::StreamTexture(GpuCommandBufferStub* owner_stub,
uint32 texture_id)
: surface_texture_(new gfx::SurfaceTexture(texture_id)),
size_(0, 0),
- has_updated_(false),
+ has_valid_frame_(false),
+ has_pending_frame_(false),
owner_stub_(owner_stub),
route_id_(route_id),
has_listener_(false),
@@ -100,19 +102,32 @@ void StreamTexture::WillUseTexImage() {
if (!owner_stub_)
return;
- // TODO(sievers): Update also when used in a different context.
- // Also see crbug.com/309162.
- if (surface_texture_.get() &&
- owner_stub_->decoder()->GetGLContext()->IsCurrent(NULL)) {
+ if (surface_texture_.get() && has_pending_frame_) {
+ scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current;
+ bool needs_make_current =
+ owner_stub_->decoder()->GetGLContext()->IsCurrent(NULL);
+ // On Android we should not have to perform a real context switch here when
+ // using virtual contexts.
+ DCHECK(!needs_make_current || !owner_stub_->decoder()
+ ->GetContextGroup()
+ ->feature_info()
+ ->workarounds()
+ .use_virtualized_gl_contexts);
+ if (needs_make_current) {
reveman 2014/01/28 00:33:42 is ui::ScopedMakeCurrent not smart enough that you
no sievers 2014/01/28 00:43:45 Unfortunately it's not. But the virtual context cu
+ scoped_make_current.reset(new ui::ScopedMakeCurrent(
+ owner_stub_->decoder()->GetGLContext(), owner_stub_->surface()));
+ }
surface_texture_->UpdateTexImage();
+ has_valid_frame_ = true;
+ has_pending_frame_ = false;
}
- if (has_listener_) {
+ if (has_listener_ && has_valid_frame_) {
float mtx[16];
surface_texture_->GetTransformMatrix(mtx);
// Only query the matrix once we have bound a valid frame.
- if (has_updated_ && memcmp(current_matrix_, mtx, sizeof(mtx)) != 0) {
+ if (memcmp(current_matrix_, mtx, sizeof(mtx)) != 0) {
memcpy(current_matrix_, mtx, sizeof(mtx));
GpuStreamTextureMsg_MatrixChanged_Params params;
@@ -124,7 +139,7 @@ void StreamTexture::WillUseTexImage() {
}
void StreamTexture::OnFrameAvailable() {
- has_updated_ = true;
+ has_pending_frame_ = true;
DCHECK(has_listener_);
if (owner_stub_) {
owner_stub_->channel()->Send(
« 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