| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef GPU_IPC_SERVICE_PASS_THROUGH_IMAGE_TRANSPORT_SURFACE_H_ | 5 #ifndef GPU_IPC_SERVICE_PASS_THROUGH_IMAGE_TRANSPORT_SURFACE_H_ |
| 6 #define GPU_IPC_SERVICE_PASS_THROUGH_IMAGE_TRANSPORT_SURFACE_H_ | 6 #define GPU_IPC_SERVICE_PASS_THROUGH_IMAGE_TRANSPORT_SURFACE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "gpu/ipc/service/image_transport_surface.h" | 15 #include "gpu/ipc/service/image_transport_surface.h" |
| 16 #include "ui/events/latency_info.h" | 16 #include "ui/events/latency_info.h" |
| 17 #include "ui/gl/gl_surface.h" | 17 #include "ui/gl/gl_surface.h" |
| 18 | 18 |
| 19 namespace gpu { | 19 namespace gpu { |
| 20 class GpuChannelManager; | 20 class GpuChannelManager; |
| 21 class GpuCommandBufferStub; | 21 class GpuCommandBufferStub; |
| 22 | 22 |
| 23 // An implementation of ImageTransportSurface that implements GLSurface through | 23 // An implementation of ImageTransportSurface that implements GLSurface through |
| 24 // GLSurfaceAdapter, thereby forwarding GLSurface methods through to it. | 24 // GLSurfaceAdapter, thereby forwarding GLSurface methods through to it. |
| 25 class PassThroughImageTransportSurface : public gfx::GLSurfaceAdapter { | 25 class PassThroughImageTransportSurface : public gl::GLSurfaceAdapter { |
| 26 public: | 26 public: |
| 27 PassThroughImageTransportSurface(GpuChannelManager* manager, | 27 PassThroughImageTransportSurface(GpuChannelManager* manager, |
| 28 GpuCommandBufferStub* stub, | 28 GpuCommandBufferStub* stub, |
| 29 gfx::GLSurface* surface); | 29 gl::GLSurface* surface); |
| 30 | 30 |
| 31 // GLSurface implementation. | 31 // GLSurface implementation. |
| 32 bool Initialize(gfx::GLSurface::Format format) override; | 32 bool Initialize(gl::GLSurface::Format format) override; |
| 33 void Destroy() override; | 33 void Destroy() override; |
| 34 gfx::SwapResult SwapBuffers() override; | 34 gfx::SwapResult SwapBuffers() override; |
| 35 void SwapBuffersAsync(const SwapCompletionCallback& callback) override; | 35 void SwapBuffersAsync(const SwapCompletionCallback& callback) override; |
| 36 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; | 36 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; |
| 37 void PostSubBufferAsync(int x, | 37 void PostSubBufferAsync(int x, |
| 38 int y, | 38 int y, |
| 39 int width, | 39 int width, |
| 40 int height, | 40 int height, |
| 41 const SwapCompletionCallback& callback) override; | 41 const SwapCompletionCallback& callback) override; |
| 42 gfx::SwapResult CommitOverlayPlanes() override; | 42 gfx::SwapResult CommitOverlayPlanes() override; |
| 43 void CommitOverlayPlanesAsync( | 43 void CommitOverlayPlanesAsync( |
| 44 const SwapCompletionCallback& callback) override; | 44 const SwapCompletionCallback& callback) override; |
| 45 bool OnMakeCurrent(gfx::GLContext* context) override; | 45 bool OnMakeCurrent(gl::GLContext* context) override; |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 ~PassThroughImageTransportSurface() override; | 48 ~PassThroughImageTransportSurface() override; |
| 49 | 49 |
| 50 // If updated vsync parameters can be determined, send this information to | 50 // If updated vsync parameters can be determined, send this information to |
| 51 // the browser. | 51 // the browser. |
| 52 void SendVSyncUpdateIfAvailable(); | 52 void SendVSyncUpdateIfAvailable(); |
| 53 | 53 |
| 54 void SetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); | 54 void SetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info); |
| 55 std::unique_ptr<std::vector<ui::LatencyInfo>> StartSwapBuffers(); | 55 std::unique_ptr<std::vector<ui::LatencyInfo>> StartSwapBuffers(); |
| 56 void FinishSwapBuffers( | 56 void FinishSwapBuffers( |
| 57 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info, | 57 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info, |
| 58 gfx::SwapResult result); | 58 gfx::SwapResult result); |
| 59 void FinishSwapBuffersAsync( | 59 void FinishSwapBuffersAsync( |
| 60 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info, | 60 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info, |
| 61 GLSurface::SwapCompletionCallback callback, | 61 GLSurface::SwapCompletionCallback callback, |
| 62 gfx::SwapResult result); | 62 gfx::SwapResult result); |
| 63 | 63 |
| 64 base::WeakPtr<GpuCommandBufferStub> stub_; | 64 base::WeakPtr<GpuCommandBufferStub> stub_; |
| 65 bool did_set_swap_interval_; | 65 bool did_set_swap_interval_; |
| 66 std::vector<ui::LatencyInfo> latency_info_; | 66 std::vector<ui::LatencyInfo> latency_info_; |
| 67 base::WeakPtrFactory<PassThroughImageTransportSurface> weak_ptr_factory_; | 67 base::WeakPtrFactory<PassThroughImageTransportSurface> weak_ptr_factory_; |
| 68 | 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(PassThroughImageTransportSurface); | 69 DISALLOW_COPY_AND_ASSIGN(PassThroughImageTransportSurface); |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 } // namespace gpu | 72 } // namespace gpu |
| 73 | 73 |
| 74 #endif // GPU_IPC_SERVICE_PASS_THROUGH_IMAGE_TRANSPORT_SURFACE_H_ | 74 #endif // GPU_IPC_SERVICE_PASS_THROUGH_IMAGE_TRANSPORT_SURFACE_H_ |
| OLD | NEW |