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

Side by Side Diff: chrome/browser/android/vr_shell/mailbox_to_surface_bridge.cc

Issue 2791723003: Update GpuSurfaceTracker to include Android surfaces. (Closed)
Patch Set: updated comment Created 3 years, 7 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 | « no previous file | content/browser/compositor/gpu_process_transport_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/android/vr_shell/mailbox_to_surface_bridge.h" 5 #include "chrome/browser/android/vr_shell/mailbox_to_surface_bridge.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } // namespace 134 } // namespace
135 135
136 namespace vr_shell { 136 namespace vr_shell {
137 137
138 MailboxToSurfaceBridge::MailboxToSurfaceBridge() : weak_ptr_factory_(this) {} 138 MailboxToSurfaceBridge::MailboxToSurfaceBridge() : weak_ptr_factory_(this) {}
139 139
140 MailboxToSurfaceBridge::~MailboxToSurfaceBridge() { 140 MailboxToSurfaceBridge::~MailboxToSurfaceBridge() {
141 if (surface_handle_) { 141 if (surface_handle_) {
142 // Unregister from the surface tracker to avoid a resource leak. 142 // Unregister from the surface tracker to avoid a resource leak.
143 gpu::GpuSurfaceTracker* tracker = gpu::GpuSurfaceTracker::Get(); 143 gpu::GpuSurfaceTracker* tracker = gpu::GpuSurfaceTracker::Get();
144 tracker->UnregisterViewSurface(surface_handle_); 144 tracker->RemoveSurface(surface_handle_);
145 } 145 }
146 DestroyContext(); 146 DestroyContext();
147 } 147 }
148 148
149 void MailboxToSurfaceBridge::OnContextAvailable( 149 void MailboxToSurfaceBridge::OnContextAvailable(
150 scoped_refptr<cc::ContextProvider> provider) { 150 scoped_refptr<cc::ContextProvider> provider) {
151 // Must save a reference to the ContextProvider to keep it alive, 151 // Must save a reference to the ContextProvider to keep it alive,
152 // otherwise the GL context created from it becomes invalid. 152 // otherwise the GL context created from it becomes invalid.
153 context_provider_ = std::move(provider); 153 context_provider_ = std::move(provider);
154 154
(...skipping 10 matching lines...) Expand all
165 } 165 }
166 InitializeRenderer(); 166 InitializeRenderer();
167 } 167 }
168 168
169 void MailboxToSurfaceBridge::CreateSurface( 169 void MailboxToSurfaceBridge::CreateSurface(
170 gl::SurfaceTexture* surface_texture) { 170 gl::SurfaceTexture* surface_texture) {
171 ANativeWindow* window = surface_texture->CreateSurface(); 171 ANativeWindow* window = surface_texture->CreateSurface();
172 gpu::GpuSurfaceTracker* tracker = gpu::GpuSurfaceTracker::Get(); 172 gpu::GpuSurfaceTracker* tracker = gpu::GpuSurfaceTracker::Get();
173 ANativeWindow_acquire(window); 173 ANativeWindow_acquire(window);
174 // Skip ANativeWindow_setBuffersGeometry, the default size appears to work. 174 // Skip ANativeWindow_setBuffersGeometry, the default size appears to work.
175 surface_handle_ = tracker->AddSurfaceForNativeWidget(window);
176
177 auto surface = base::MakeUnique<gl::ScopedJavaSurface>(surface_texture); 175 auto surface = base::MakeUnique<gl::ScopedJavaSurface>(surface_texture);
178 tracker->RegisterViewSurface(surface_handle_, surface->j_surface().obj()); 176 surface_handle_ =
177 tracker->AddSurfaceForNativeWidget(gpu::GpuSurfaceTracker::SurfaceRecord(
178 window, surface->j_surface().obj()));
179 // Unregistering happens in the destructor. 179 // Unregistering happens in the destructor.
180 ANativeWindow_release(window); 180 ANativeWindow_release(window);
181 181
182 // Our attributes must be compatible with the shared offscreen 182 // Our attributes must be compatible with the shared offscreen
183 // surface used by virtualized contexts, otherwise mailbox 183 // surface used by virtualized contexts, otherwise mailbox
184 // synchronization doesn't work properly - it assumes a shared 184 // synchronization doesn't work properly - it assumes a shared
185 // underlying GL context. See GetCompositorContextAttributes 185 // underlying GL context. See GetCompositorContextAttributes
186 // in content/browser/renderer_host/compositor_impl_android.cc 186 // in content/browser/renderer_host/compositor_impl_android.cc
187 // and crbug.com/699330. 187 // and crbug.com/699330.
188 188
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // GL_NEAREST. 337 // GL_NEAREST.
338 gl_->BindTexture(GL_TEXTURE_2D, texture_handle); 338 gl_->BindTexture(GL_TEXTURE_2D, texture_handle);
339 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 339 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
340 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 340 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
341 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 341 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
342 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 342 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
343 gl_->DrawArrays(GL_TRIANGLE_FAN, 0, 4); 343 gl_->DrawArrays(GL_TRIANGLE_FAN, 0, 4);
344 } 344 }
345 345
346 } // namespace vr_shell 346 } // namespace vr_shell
OLDNEW
« no previous file with comments | « no previous file | content/browser/compositor/gpu_process_transport_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698