| OLD | NEW |
| 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 "gpu/ipc/service/stream_texture_android.h" | 5 #include "gpu/ipc/service/stream_texture_android.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/strings/stringize_macros.h" | 10 #include "base/strings/stringize_macros.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 void StreamTexture::GetTextureMatrix(float xform[16]) { | 93 void StreamTexture::GetTextureMatrix(float xform[16]) { |
| 94 UpdateTexImage(); | 94 UpdateTexImage(); |
| 95 surface_texture_->GetTransformMatrix(xform); | 95 surface_texture_->GetTransformMatrix(xform); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void StreamTexture::OnWillDestroyStub() { | 98 void StreamTexture::OnWillDestroyStub() { |
| 99 owner_stub_->RemoveDestructionObserver(this); | 99 owner_stub_->RemoveDestructionObserver(this); |
| 100 owner_stub_->channel()->RemoveRoute(route_id_); | 100 owner_stub_->channel()->RemoveRoute(route_id_); |
| 101 | 101 |
| 102 if (framebuffer_) { | 102 if (framebuffer_) { |
| 103 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current(MakeStubCurrent()); | 103 std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current( |
| 104 MakeStubCurrent()); |
| 104 | 105 |
| 105 glDeleteProgram(program_); | 106 glDeleteProgram(program_); |
| 106 glDeleteShader(vertex_shader_); | 107 glDeleteShader(vertex_shader_); |
| 107 glDeleteShader(fragment_shader_); | 108 glDeleteShader(fragment_shader_); |
| 108 glDeleteBuffersARB(1, &vertex_buffer_); | 109 glDeleteBuffersARB(1, &vertex_buffer_); |
| 109 glDeleteFramebuffersEXT(1, &framebuffer_); | 110 glDeleteFramebuffersEXT(1, &framebuffer_); |
| 110 program_ = 0; | 111 program_ = 0; |
| 111 vertex_shader_ = 0; | 112 vertex_shader_ = 0; |
| 112 fragment_shader_ = 0; | 113 fragment_shader_ = 0; |
| 113 vertex_buffer_ = 0; | 114 vertex_buffer_ = 0; |
| 114 framebuffer_ = 0; | 115 framebuffer_ = 0; |
| 115 u_xform_location_ = -1; | 116 u_xform_location_ = -1; |
| 116 } | 117 } |
| 117 | 118 |
| 118 owner_stub_ = NULL; | 119 owner_stub_ = NULL; |
| 119 | 120 |
| 120 // If the owner goes away, there is no need to keep the SurfaceTexture around. | 121 // If the owner goes away, there is no need to keep the SurfaceTexture around. |
| 121 // The GL texture will keep working regardless with the currently bound frame. | 122 // The GL texture will keep working regardless with the currently bound frame. |
| 122 surface_texture_ = NULL; | 123 surface_texture_ = NULL; |
| 123 } | 124 } |
| 124 | 125 |
| 125 void StreamTexture::Destroy(bool have_context) { | 126 void StreamTexture::Destroy(bool have_context) { |
| 126 NOTREACHED(); | 127 NOTREACHED(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 scoped_ptr<ui::ScopedMakeCurrent> StreamTexture::MakeStubCurrent() { | 130 std::unique_ptr<ui::ScopedMakeCurrent> StreamTexture::MakeStubCurrent() { |
| 130 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current; | 131 std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current; |
| 131 bool needs_make_current = | 132 bool needs_make_current = |
| 132 !owner_stub_->decoder()->GetGLContext()->IsCurrent(NULL); | 133 !owner_stub_->decoder()->GetGLContext()->IsCurrent(NULL); |
| 133 if (needs_make_current) { | 134 if (needs_make_current) { |
| 134 scoped_make_current.reset(new ui::ScopedMakeCurrent( | 135 scoped_make_current.reset(new ui::ScopedMakeCurrent( |
| 135 owner_stub_->decoder()->GetGLContext(), owner_stub_->surface())); | 136 owner_stub_->decoder()->GetGLContext(), owner_stub_->surface())); |
| 136 } | 137 } |
| 137 return scoped_make_current; | 138 return scoped_make_current; |
| 138 } | 139 } |
| 139 | 140 |
| 140 void StreamTexture::UpdateTexImage() { | 141 void StreamTexture::UpdateTexImage() { |
| 141 DCHECK(surface_texture_.get()); | 142 DCHECK(surface_texture_.get()); |
| 142 DCHECK(owner_stub_); | 143 DCHECK(owner_stub_); |
| 143 | 144 |
| 144 if (!has_pending_frame_) return; | 145 if (!has_pending_frame_) return; |
| 145 | 146 |
| 146 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current(MakeStubCurrent()); | 147 std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current(MakeStubCurrent()); |
| 147 | 148 |
| 148 surface_texture_->UpdateTexImage(); | 149 surface_texture_->UpdateTexImage(); |
| 149 | 150 |
| 150 has_pending_frame_ = false; | 151 has_pending_frame_ = false; |
| 151 | 152 |
| 152 if (scoped_make_current.get()) { | 153 if (scoped_make_current.get()) { |
| 153 // UpdateTexImage() implies glBindTexture(). | 154 // UpdateTexImage() implies glBindTexture(). |
| 154 // The cmd decoder takes care of restoring the binding for this GLImage as | 155 // The cmd decoder takes care of restoring the binding for this GLImage as |
| 155 // far as the current context is concerned, but if we temporarily change | 156 // far as the current context is concerned, but if we temporarily change |
| 156 // it, we have to keep the state intact in *that* context also. | 157 // it, we have to keep the state intact in *that* context also. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 return false; | 269 return false; |
| 269 } | 270 } |
| 270 | 271 |
| 271 void StreamTexture::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 272 void StreamTexture::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
| 272 uint64_t process_tracing_id, | 273 uint64_t process_tracing_id, |
| 273 const std::string& dump_name) { | 274 const std::string& dump_name) { |
| 274 // TODO(ericrk): Add OnMemoryDump for GLImages. crbug.com/514914 | 275 // TODO(ericrk): Add OnMemoryDump for GLImages. crbug.com/514914 |
| 275 } | 276 } |
| 276 | 277 |
| 277 } // namespace gpu | 278 } // namespace gpu |
| OLD | NEW |