| Index: content/common/gpu/image_transport_surface_android.cc
|
| diff --git a/content/common/gpu/image_transport_surface_android.cc b/content/common/gpu/image_transport_surface_android.cc
|
| index 1d3ac9cc471b19cdb22357601c815fb07bf7c427..321f3ea8f3fbcdf72c3cf29ebe16ed9c229b20a9 100644
|
| --- a/content/common/gpu/image_transport_surface_android.cc
|
| +++ b/content/common/gpu/image_transport_surface_android.cc
|
| @@ -10,135 +10,10 @@
|
| #include "content/common/gpu/gpu_channel_manager.h"
|
| #include "content/common/gpu/gpu_command_buffer_stub.h"
|
| #include "content/common/gpu/gpu_surface_lookup.h"
|
| -#include "content/common/gpu/null_transport_surface.h"
|
| #include "content/public/common/content_switches.h"
|
| #include "ui/gl/gl_surface_egl.h"
|
|
|
| namespace content {
|
| -namespace {
|
| -
|
| -// Amount of time the GPU is allowed to idle before it powers down.
|
| -const int kMaxGpuIdleTimeMs = 40;
|
| -// Maximum amount of time we keep pinging the GPU waiting for the client to
|
| -// draw.
|
| -const int kMaxKeepAliveTimeMs = 200;
|
| -// Last time we know the GPU was powered on. Global for tracking across all
|
| -// transport surfaces.
|
| -int64 g_last_gpu_access_ticks;
|
| -
|
| -void DidAccessGpu() {
|
| - g_last_gpu_access_ticks = base::TimeTicks::Now().ToInternalValue();
|
| -}
|
| -
|
| -class ImageTransportSurfaceAndroid
|
| - : public NullTransportSurface,
|
| - public base::SupportsWeakPtr<ImageTransportSurfaceAndroid> {
|
| - public:
|
| - ImageTransportSurfaceAndroid(GpuChannelManager* manager,
|
| - GpuCommandBufferStub* stub,
|
| - const gfx::GLSurfaceHandle& handle);
|
| -
|
| - // gfx::GLSurface implementation.
|
| - bool OnMakeCurrent(gfx::GLContext* context) override;
|
| - void WakeUpGpu() override;
|
| -
|
| - protected:
|
| - ~ImageTransportSurfaceAndroid() override;
|
| -
|
| - private:
|
| - void ScheduleWakeUp();
|
| - void DoWakeUpGpu();
|
| -
|
| - base::TimeTicks begin_wake_up_time_;
|
| -};
|
| -
|
| -class DirectSurfaceAndroid : public PassThroughImageTransportSurface {
|
| - public:
|
| - DirectSurfaceAndroid(GpuChannelManager* manager,
|
| - GpuCommandBufferStub* stub,
|
| - gfx::GLSurface* surface);
|
| -
|
| - // gfx::GLSurface implementation.
|
| - gfx::SwapResult SwapBuffers() override;
|
| -
|
| - protected:
|
| - ~DirectSurfaceAndroid() override;
|
| -
|
| - private:
|
| - DISALLOW_COPY_AND_ASSIGN(DirectSurfaceAndroid);
|
| -};
|
| -
|
| -ImageTransportSurfaceAndroid::ImageTransportSurfaceAndroid(
|
| - GpuChannelManager* manager,
|
| - GpuCommandBufferStub* stub,
|
| - const gfx::GLSurfaceHandle& handle)
|
| - : NullTransportSurface(manager, stub, handle) {}
|
| -
|
| -ImageTransportSurfaceAndroid::~ImageTransportSurfaceAndroid() {}
|
| -
|
| -bool ImageTransportSurfaceAndroid::OnMakeCurrent(gfx::GLContext* context) {
|
| - DidAccessGpu();
|
| - return true;
|
| -}
|
| -
|
| -void ImageTransportSurfaceAndroid::WakeUpGpu() {
|
| - begin_wake_up_time_ = base::TimeTicks::Now();
|
| - ScheduleWakeUp();
|
| -}
|
| -
|
| -void ImageTransportSurfaceAndroid::ScheduleWakeUp() {
|
| - base::TimeTicks now = base::TimeTicks::Now();
|
| - base::TimeTicks last_access_time =
|
| - base::TimeTicks::FromInternalValue(g_last_gpu_access_ticks);
|
| - TRACE_EVENT2("gpu", "ImageTransportSurfaceAndroid::ScheduleWakeUp",
|
| - "idle_time", (now - last_access_time).InMilliseconds(),
|
| - "keep_awake_time", (now - begin_wake_up_time_).InMilliseconds());
|
| - if (now - last_access_time <
|
| - base::TimeDelta::FromMilliseconds(kMaxGpuIdleTimeMs))
|
| - return;
|
| - if (now - begin_wake_up_time_ >
|
| - base::TimeDelta::FromMilliseconds(kMaxKeepAliveTimeMs))
|
| - return;
|
| -
|
| - DoWakeUpGpu();
|
| -
|
| - base::MessageLoop::current()->PostDelayedTask(
|
| - FROM_HERE,
|
| - base::Bind(&ImageTransportSurfaceAndroid::ScheduleWakeUp, AsWeakPtr()),
|
| - base::TimeDelta::FromMilliseconds(kMaxGpuIdleTimeMs));
|
| -}
|
| -
|
| -void ImageTransportSurfaceAndroid::DoWakeUpGpu() {
|
| - if (!GetHelper()->stub()->decoder() ||
|
| - !GetHelper()->stub()->decoder()->MakeCurrent())
|
| - return;
|
| - glFinish();
|
| - DidAccessGpu();
|
| -}
|
| -
|
| -DirectSurfaceAndroid::DirectSurfaceAndroid(GpuChannelManager* manager,
|
| - GpuCommandBufferStub* stub,
|
| - gfx::GLSurface* surface)
|
| - : PassThroughImageTransportSurface(manager, stub, surface) {}
|
| -
|
| -DirectSurfaceAndroid::~DirectSurfaceAndroid() {}
|
| -
|
| -gfx::SwapResult DirectSurfaceAndroid::SwapBuffers() {
|
| - DidAccessGpu();
|
| - return PassThroughImageTransportSurface::SwapBuffers();
|
| -}
|
| -
|
| -} // anonymous namespace
|
| -
|
| -// static
|
| -scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateTransportSurface(
|
| - GpuChannelManager* manager,
|
| - GpuCommandBufferStub* stub,
|
| - const gfx::GLSurfaceHandle& handle) {
|
| - DCHECK_EQ(gfx::NULL_TRANSPORT, handle.transport_type);
|
| - return scoped_refptr<gfx::GLSurface>(
|
| - new ImageTransportSurfaceAndroid(manager, stub, handle));
|
| -}
|
|
|
| // static
|
| scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface(
|
| @@ -160,7 +35,7 @@ scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface(
|
| return scoped_refptr<gfx::GLSurface>();
|
|
|
| return scoped_refptr<gfx::GLSurface>(
|
| - new DirectSurfaceAndroid(manager, stub, surface.get()));
|
| + new PassThroughImageTransportSurface(manager, stub, surface.get()));
|
| }
|
|
|
| } // namespace content
|
|
|