| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_VIEW_MANAGER_GLES2_COMMAND_BUFFER_LOCAL_H_ | |
| 6 #define COMPONENTS_VIEW_MANAGER_GLES2_COMMAND_BUFFER_LOCAL_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "components/view_manager/gles2/gpu_state.h" | |
| 13 #include "gpu/command_buffer/client/gpu_control.h" | |
| 14 #include "gpu/command_buffer/common/command_buffer.h" | |
| 15 #include "ui/gfx/geometry/size.h" | |
| 16 #include "ui/gfx/gpu_memory_buffer.h" | |
| 17 #include "ui/gfx/native_widget_types.h" | |
| 18 | |
| 19 namespace gpu { | |
| 20 class CommandBuffer; | |
| 21 class CommandBufferService; | |
| 22 class GpuScheduler; | |
| 23 class GpuControlService; | |
| 24 namespace gles2 { | |
| 25 class GLES2Decoder; | |
| 26 } | |
| 27 } | |
| 28 | |
| 29 namespace gfx { | |
| 30 class GLContext; | |
| 31 class GLSurface; | |
| 32 } | |
| 33 | |
| 34 namespace gles2 { | |
| 35 | |
| 36 class CommandBufferLocalClient; | |
| 37 | |
| 38 // This class provides a thin wrapper around a CommandBufferService and a | |
| 39 // GpuControl implementation to allow cc::Display to generate GL directly on | |
| 40 // the same thread. | |
| 41 class CommandBufferLocal : public gpu::GpuControl { | |
| 42 public: | |
| 43 CommandBufferLocal(CommandBufferLocalClient* client, | |
| 44 gfx::AcceleratedWidget widget, | |
| 45 const scoped_refptr<gles2::GpuState>& gpu_state); | |
| 46 ~CommandBufferLocal() override; | |
| 47 | |
| 48 bool Initialize(); | |
| 49 | |
| 50 gpu::CommandBuffer* GetCommandBuffer(); | |
| 51 | |
| 52 // gpu::GpuControl implementation: | |
| 53 gpu::Capabilities GetCapabilities() override; | |
| 54 int32_t CreateImage(ClientBuffer buffer, | |
| 55 size_t width, | |
| 56 size_t height, | |
| 57 unsigned internalformat) override; | |
| 58 void DestroyImage(int32_t id) override; | |
| 59 int32_t CreateGpuMemoryBufferImage(size_t width, | |
| 60 size_t height, | |
| 61 unsigned internalformat, | |
| 62 unsigned usage) override; | |
| 63 uint32 InsertSyncPoint() override; | |
| 64 uint32 InsertFutureSyncPoint() override; | |
| 65 void RetireSyncPoint(uint32 sync_point) override; | |
| 66 void SignalSyncPoint(uint32 sync_point, | |
| 67 const base::Closure& callback) override; | |
| 68 void SignalQuery(uint32 query, const base::Closure& callback) override; | |
| 69 void SetSurfaceVisible(bool visible) override; | |
| 70 uint32 CreateStreamTexture(uint32 texture_id) override; | |
| 71 void SetLock(base::Lock*) override; | |
| 72 bool IsGpuChannelLost() override; | |
| 73 | |
| 74 private: | |
| 75 void PumpCommands(); | |
| 76 | |
| 77 void OnResize(gfx::Size size, float scale_factor); | |
| 78 void OnUpdateVSyncParameters(const base::TimeTicks timebase, | |
| 79 const base::TimeDelta interval); | |
| 80 bool OnWaitSyncPoint(uint32_t sync_point); | |
| 81 void OnParseError(); | |
| 82 void OnContextLost(uint32_t reason); | |
| 83 void OnSyncPointRetired(); | |
| 84 | |
| 85 gfx::AcceleratedWidget widget_; | |
| 86 scoped_refptr<gles2::GpuState> gpu_state_; | |
| 87 scoped_ptr<gpu::CommandBufferService> command_buffer_; | |
| 88 scoped_ptr<gpu::GpuScheduler> scheduler_; | |
| 89 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; | |
| 90 scoped_refptr<gfx::GLContext> context_; | |
| 91 scoped_refptr<gfx::GLSurface> surface_; | |
| 92 CommandBufferLocalClient* client_; | |
| 93 | |
| 94 base::WeakPtrFactory<CommandBufferLocal> weak_factory_; | |
| 95 | |
| 96 DISALLOW_COPY_AND_ASSIGN(CommandBufferLocal); | |
| 97 }; | |
| 98 | |
| 99 } // namespace gles2 | |
| 100 | |
| 101 #endif // COMPONENTS_VIEW_MANAGER_GLES2_COMMAND_BUFFER_LOCAL_H_ | |
| OLD | NEW |