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

Unified Diff: ui/gl/android/gl_image_stream.cc

Issue 22824009: Remove StreamTextureManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 4 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 | « ui/gl/android/gl_image_stream.h ('k') | ui/gl/gl.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/android/gl_image_stream.cc
diff --git a/ui/gl/android/gl_image_stream.cc b/ui/gl/android/gl_image_stream.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f57b1bedfd055f6b9e67dd3a66dbd0ee6e5e43e5
--- /dev/null
+++ b/ui/gl/android/gl_image_stream.cc
@@ -0,0 +1,88 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/gl/android/gl_image_stream.h"
+
+#include "base/bind.h"
+#include "ui/gfx/size.h"
+#include "ui/gl/android/surface_texture_bridge.h"
+#include "ui/gl/gl_bindings.h"
+
+namespace gfx {
+
+GLImageStream::GLImageStream()
+ : has_updated_(false),
+ weak_factory_(this) {
+ memset(&current_matrix_, 0, sizeof(current_matrix_));
+}
+
+GLImageStream::~GLImageStream() {}
+
+void GLImageStream::Destroy() {
+}
+
+gfx::Size GLImageStream::GetSize() {
+ return size_;
+}
+
+void GLImageStream::WillUseTexImage() {
+ GLint texture_id = 0;
+ glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texture_id);
+ surface_texture_bridge_->UpdateTexImage();
+ glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id);
+ if (matrix_callback_.is_null())
+ return;
+
+ Matrix new_matrix;
+ surface_texture_bridge_->GetTransformMatrix(new_matrix.components);
+
+ // Only query the matrix once we have bound a valid frame.
+ if (has_updated_ &&
+ memcmp(&current_matrix_, &new_matrix, sizeof(new_matrix)) != 0) {
+ memcpy(&current_matrix_, &new_matrix, sizeof(new_matrix));
+ matrix_callback_.Run(new_matrix);
+ }
+}
+
+GLImageStream* GLImageStream::AsGLImageStream() {
+ return this;
+}
+
+SurfaceTextureBridge* GLImageStream::GetSurfaceTexture() {
+ return surface_texture_bridge_;
+}
+
+void GLImageStream::SetFrameAvailableCallback(const base::Closure& callback) {
+ frame_callback_ = callback;
+ // Use a weak pointer here to avoid a circular reference between
+ // |this| and surface_texture_bridge_.
+ base::Closure frame_cb =
+ base::Bind(&GLImageStream::OnFrameAvailable, weak_factory_.GetWeakPtr());
+ surface_texture_bridge_->SetFrameAvailableCallback(frame_cb);
+}
+
+void GLImageStream::OnFrameAvailable() {
+ has_updated_ = true;
+ frame_callback_.Run();
+}
+
+bool GLImageStream::BindTexImage() {
+ if (!surface_texture_bridge_) {
+ GLint texture_id = 0;
+ glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texture_id);
+ if (!texture_id)
+ return false;
+
+ surface_texture_bridge_(new gfx::SurfaceTextureBridge(texture_id));
+ return true;
+ }
+ surface_texture_bridge_->AttachToGLContext();
+ return true;
+}
+
+void GLImageStream::ReleaseTexImage() {
+ surface_texture_bridge_->DetachFromGLContext();
+}
+
+} // namespace gfx
« no previous file with comments | « ui/gl/android/gl_image_stream.h ('k') | ui/gl/gl.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698