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

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

Issue 1436533003: android: Handle getViewSurface() failure gracefully. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/image_transport_surface.h" 5 #include "content/common/gpu/image_transport_surface.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "content/common/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 #include "content/common/gpu/gpu_channel_manager.h" 10 #include "content/common/gpu/gpu_channel_manager.h"
11 #include "content/common/gpu/gpu_command_buffer_stub.h" 11 #include "content/common/gpu/gpu_command_buffer_stub.h"
12 #include "content/common/gpu/gpu_surface_lookup.h" 12 #include "content/common/gpu/gpu_surface_lookup.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "ui/gl/gl_surface_egl.h" 14 #include "ui/gl/gl_surface_egl.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 // static 18 // static
19 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface( 19 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface(
20 GpuChannelManager* manager, 20 GpuChannelManager* manager,
21 GpuCommandBufferStub* stub, 21 GpuCommandBufferStub* stub,
22 const gfx::GLSurfaceHandle& handle) { 22 const gfx::GLSurfaceHandle& handle) {
23 DCHECK(GpuSurfaceLookup::GetInstance()); 23 DCHECK(GpuSurfaceLookup::GetInstance());
24 DCHECK_EQ(handle.transport_type, gfx::NATIVE_DIRECT); 24 DCHECK_EQ(handle.transport_type, gfx::NATIVE_DIRECT);
25 ANativeWindow* window = 25 ANativeWindow* window =
26 GpuSurfaceLookup::GetInstance()->AcquireNativeWidget(handle.handle); 26 GpuSurfaceLookup::GetInstance()->AcquireNativeWidget(handle.handle);
27 CHECK(window) << "Failed to retrieve window handle."; 27 if (!window) {
28 LOG(WARNING) << "Failed to acquire native widget.";
29 return scoped_refptr<gfx::GLSurface>();
30 }
28 scoped_refptr<gfx::GLSurface> surface = 31 scoped_refptr<gfx::GLSurface> surface =
29 new gfx::NativeViewGLSurfaceEGL(window); 32 new gfx::NativeViewGLSurfaceEGL(window);
30 bool initialize_success = surface->Initialize(); 33 bool initialize_success = surface->Initialize();
31 if (window) 34 ANativeWindow_release(window);
32 ANativeWindow_release(window);
33 if (!initialize_success) 35 if (!initialize_success)
34 return scoped_refptr<gfx::GLSurface>(); 36 return scoped_refptr<gfx::GLSurface>();
35 37
36 return scoped_refptr<gfx::GLSurface>( 38 return scoped_refptr<gfx::GLSurface>(
37 new PassThroughImageTransportSurface(manager, stub, surface.get())); 39 new PassThroughImageTransportSurface(manager, stub, surface.get()));
38 } 40 }
39 41
40 } // namespace content 42 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698