OLD | NEW |
---|---|
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 namespace { | |
19 | |
20 class AndroidImageTransportSurface : public PassThroughImageTransportSurface { | |
21 public: | |
22 AndroidImageTransportSurface(GpuChannelManager* manager, | |
23 GpuCommandBufferStub* stub, | |
24 gfx::GLSurface* surface) | |
25 : PassThroughImageTransportSurface(manager, stub, surface) {} | |
26 | |
27 bool Resize(const gfx::Size& size, float scale_factor) override { | |
28 bool result = PassThroughImageTransportSurface::Resize(size, scale_factor); | |
29 manager_->gpu_memory_manager()->ScheduleManage( | |
30 GpuMemoryManager::kScheduleManageNow); | |
piman
2015/10/27 23:11:47
So, because of crbug.com/526196 , and after https:
| |
31 return result; | |
32 } | |
33 | |
34 private: | |
35 ~AndroidImageTransportSurface() override {} | |
36 }; | |
37 | |
38 } // namespace | |
39 | |
18 // static | 40 // static |
19 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface( | 41 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface( |
20 GpuChannelManager* manager, | 42 GpuChannelManager* manager, |
21 GpuCommandBufferStub* stub, | 43 GpuCommandBufferStub* stub, |
22 const gfx::GLSurfaceHandle& handle) { | 44 const gfx::GLSurfaceHandle& handle) { |
23 DCHECK(GpuSurfaceLookup::GetInstance()); | 45 DCHECK(GpuSurfaceLookup::GetInstance()); |
24 DCHECK_EQ(handle.transport_type, gfx::NATIVE_DIRECT); | 46 DCHECK_EQ(handle.transport_type, gfx::NATIVE_DIRECT); |
25 ANativeWindow* window = | 47 ANativeWindow* window = |
26 GpuSurfaceLookup::GetInstance()->AcquireNativeWidget(handle.handle); | 48 GpuSurfaceLookup::GetInstance()->AcquireNativeWidget(handle.handle); |
27 CHECK(window) << "Failed to retrieve window handle."; | 49 CHECK(window) << "Failed to retrieve window handle."; |
28 scoped_refptr<gfx::GLSurface> surface = | 50 scoped_refptr<gfx::GLSurface> surface = |
29 new gfx::NativeViewGLSurfaceEGL(window); | 51 new gfx::NativeViewGLSurfaceEGL(window); |
30 bool initialize_success = surface->Initialize(); | 52 bool initialize_success = surface->Initialize(); |
31 if (window) | 53 if (window) |
32 ANativeWindow_release(window); | 54 ANativeWindow_release(window); |
33 if (!initialize_success) | 55 if (!initialize_success) |
34 return scoped_refptr<gfx::GLSurface>(); | 56 return scoped_refptr<gfx::GLSurface>(); |
35 | 57 |
36 return scoped_refptr<gfx::GLSurface>( | 58 return scoped_refptr<gfx::GLSurface>( |
37 new PassThroughImageTransportSurface(manager, stub, surface.get())); | 59 new AndroidImageTransportSurface(manager, stub, surface.get())); |
38 } | 60 } |
39 | 61 |
40 } // namespace content | 62 } // namespace content |
OLD | NEW |