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

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

Issue 59973010: Android: Don't instantiate TextureImageTransportSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/image_transport_surface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/logging.h" 8 #include "base/logging.h"
9 #include "content/common/gpu/gpu_channel.h"
10 #include "content/common/gpu/gpu_channel_manager.h"
8 #include "content/common/gpu/gpu_command_buffer_stub.h" 11 #include "content/common/gpu/gpu_command_buffer_stub.h"
9 #include "content/common/gpu/gpu_surface_lookup.h" 12 #include "content/common/gpu/gpu_surface_lookup.h"
13 #include "content/common/gpu/image_transport_surface.h"
14 #include "content/public/common/content_switches.h"
10 #include "ui/gl/gl_surface_egl.h" 15 #include "ui/gl/gl_surface_egl.h"
11 16
12 namespace content { 17 namespace content {
13 18
19 namespace {
20
21 class ImageTransportSurfaceAndroid : public PassThroughImageTransportSurface {
22 public:
23 ImageTransportSurfaceAndroid(GpuChannelManager* manager,
24 GpuCommandBufferStub* stub,
25 gfx::GLSurface* surface,
26 uint32 parent_client_id);
27
28 // gfx::GLSurface implementation.
29 virtual bool Initialize() OVERRIDE;
30 virtual bool SwapBuffers() OVERRIDE;
31 virtual std::string GetExtensions() OVERRIDE;
32 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE;
33
34 protected:
35 virtual ~ImageTransportSurfaceAndroid();
36
37 private:
38 uint32 parent_client_id_;
39 bool frontbuffer_suggested_allocation_;
40 };
41
42 ImageTransportSurfaceAndroid::ImageTransportSurfaceAndroid(
43 GpuChannelManager* manager,
44 GpuCommandBufferStub* stub,
45 gfx::GLSurface* surface,
46 uint32 parent_client_id)
47 : PassThroughImageTransportSurface(manager, stub, surface, true),
48 parent_client_id_(parent_client_id),
49 frontbuffer_suggested_allocation_(true) {}
50
51 ImageTransportSurfaceAndroid::~ImageTransportSurfaceAndroid() {}
52
53 bool ImageTransportSurfaceAndroid::Initialize() {
54 if (!surface())
55 return false;
56
57 if (!PassThroughImageTransportSurface::Initialize())
58 return false;
59
60 GpuChannel* parent_channel =
61 GetHelper()->manager()->LookupChannel(parent_client_id_);
62 if (parent_channel) {
63 const CommandLine* command_line = CommandLine::ForCurrentProcess();
64 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess))
65 GetHelper()->SetPreemptByFlag(parent_channel->GetPreemptionFlag());
66 }
67
68 return true;
69 }
70
71 std::string ImageTransportSurfaceAndroid::GetExtensions() {
72 std::string extensions = gfx::GLSurface::GetExtensions();
73 extensions += extensions.empty() ? "" : " ";
74 extensions += "GL_CHROMIUM_front_buffer_cached ";
75 return extensions;
76 }
77
78 void ImageTransportSurfaceAndroid::SetFrontbufferAllocation(bool allocation) {
79 if (frontbuffer_suggested_allocation_ == allocation)
80 return;
81 frontbuffer_suggested_allocation_ = allocation;
82 // TODO(sievers): This races with CompositorFrame messages.
piman 2013/11/05 23:48:18 FYI, for Übercompositor on Aura, I wired it up wit
83 GetHelper()->SendAcceleratedSurfaceRelease();
84 }
85
86 bool ImageTransportSurfaceAndroid::SwapBuffers() {
87 NOTREACHED();
88 return false;
89 }
90
91 } // anonymous namespace
92
14 // static 93 // static
15 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface( 94 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface(
16 GpuChannelManager* manager, 95 GpuChannelManager* manager,
17 GpuCommandBufferStub* stub, 96 GpuCommandBufferStub* stub,
18 const gfx::GLSurfaceHandle& handle) { 97 const gfx::GLSurfaceHandle& handle) {
98 if (handle.transport_type == gfx::NATIVE_TRANSPORT) {
99 return scoped_refptr<gfx::GLSurface>(
100 new ImageTransportSurfaceAndroid(manager,
101 stub,
102 manager->GetDefaultOffscreenSurface(),
103 handle.parent_client_id));
104 }
105
19 DCHECK(GpuSurfaceLookup::GetInstance()); 106 DCHECK(GpuSurfaceLookup::GetInstance());
20 DCHECK_EQ(handle.transport_type, gfx::NATIVE_DIRECT); 107 DCHECK_EQ(handle.transport_type, gfx::NATIVE_DIRECT);
21 ANativeWindow* window = 108 ANativeWindow* window =
22 GpuSurfaceLookup::GetInstance()->AcquireNativeWidget( 109 GpuSurfaceLookup::GetInstance()->AcquireNativeWidget(
23 stub->surface_id()); 110 stub->surface_id());
24 scoped_refptr<gfx::GLSurface> surface = 111 scoped_refptr<gfx::GLSurface> surface =
25 new gfx::NativeViewGLSurfaceEGL(window); 112 new gfx::NativeViewGLSurfaceEGL(window);
26 bool initialize_success = surface->Initialize(); 113 bool initialize_success = surface->Initialize();
27 if (window) 114 if (window)
28 ANativeWindow_release(window); 115 ANativeWindow_release(window);
29 if (!initialize_success) 116 if (!initialize_success)
30 return scoped_refptr<gfx::GLSurface>(); 117 return scoped_refptr<gfx::GLSurface>();
31 118
32 return scoped_refptr<gfx::GLSurface>(new PassThroughImageTransportSurface( 119 return scoped_refptr<gfx::GLSurface>(new PassThroughImageTransportSurface(
33 manager, stub, surface.get(), false)); 120 manager, stub, surface.get(), false));
34 } 121 }
35 122
36 } // namespace content 123 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/image_transport_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698