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_SURFACES_COMMAND_LOCAL_H_ | |
6 #define COMPONENTS_VIEW_MANAGER_SURFACES_COMMAND_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 "gpu/command_buffer/common/command_buffer_shared.h" | |
16 #include "gpu/command_buffer/service/command_buffer_service.h" | |
17 #include "ui/gfx/geometry/size.h" | |
18 #include "ui/gfx/gpu_memory_buffer.h" | |
19 #include "ui/gfx/native_widget_types.h" | |
20 | |
21 namespace gpu { | |
22 class CommandBufferService; | |
23 class GpuScheduler; | |
24 class GpuControlService; | |
25 namespace gles2 { | |
26 class GLES2Decoder; | |
27 } | |
28 } | |
29 | |
30 namespace gfx { | |
31 class GLContext; | |
32 class GLSurface; | |
33 } | |
34 | |
35 namespace surfaces { | |
36 | |
37 // This class provides a thin wrapper around a CommandBufferService and a | |
rjkroege
2015/08/13 17:45:38
I don't think that this class should exist. i.e.:
| |
38 // GpuControl implementation to allow cc::Display to generate GL directly on | |
39 // the same thread. | |
40 class CommandBufferLocal : public gpu::GpuControl { | |
41 public: | |
42 class Client { | |
43 public: | |
44 virtual ~Client() {} | |
45 virtual void UpdateVSyncParameters(int64_t timebase, int64_t interval) = 0; | |
46 virtual void DidLoseContext() = 0; | |
47 }; | |
48 | |
49 CommandBufferLocal(Client* client, | |
50 gfx::AcceleratedWidget widget, | |
51 const scoped_refptr<gles2::GpuState>& gpu_state); | |
52 ~CommandBufferLocal() override; | |
53 | |
54 bool Initialize(); | |
55 | |
56 gpu::CommandBuffer* command_buffer() { return command_buffer_.get(); } | |
57 | |
58 // gpu::GpuControl implementation: | |
59 gpu::Capabilities GetCapabilities() override; | |
60 int32_t CreateImage(ClientBuffer buffer, | |
61 size_t width, | |
62 size_t height, | |
63 unsigned internalformat) override; | |
64 void DestroyImage(int32_t id) override; | |
65 int32_t CreateGpuMemoryBufferImage(size_t width, | |
66 size_t height, | |
67 unsigned internalformat, | |
68 unsigned usage) override; | |
69 uint32 InsertSyncPoint() override; | |
70 uint32 InsertFutureSyncPoint() override; | |
71 void RetireSyncPoint(uint32 sync_point) override; | |
72 void SignalSyncPoint(uint32 sync_point, | |
73 const base::Closure& callback) override; | |
74 void SignalQuery(uint32 query, const base::Closure& callback) override; | |
75 void SetSurfaceVisible(bool visible) override; | |
76 uint32 CreateStreamTexture(uint32 texture_id) override; | |
77 void SetLock(base::Lock*) override; | |
78 bool IsGpuChannelLost() override; | |
79 | |
80 private: | |
81 void PumpCommands(); | |
82 static scoped_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer( | |
rjkroege
2015/08/13 17:45:37
we can have a custom GpuMemoryBuffer for this kind
| |
83 const gfx::Size& size, | |
84 gfx::BufferFormat format); | |
85 | |
86 void OnResize(gfx::Size size, float scale_factor); | |
87 void OnUpdateVSyncParameters(const base::TimeTicks timebase, | |
88 const base::TimeDelta interval); | |
89 bool OnWaitSyncPoint(uint32_t sync_point); | |
90 void OnParseError(); | |
91 void OnContextLost(uint32_t reason); | |
92 void OnSyncPointRetired(); | |
93 | |
94 gfx::AcceleratedWidget widget_; | |
95 scoped_refptr<gles2::GpuState> gpu_state_; | |
96 scoped_ptr<gpu::CommandBufferService> command_buffer_; | |
97 scoped_ptr<gpu::GpuScheduler> scheduler_; | |
98 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; | |
99 scoped_refptr<gfx::GLContext> context_; | |
100 scoped_refptr<gfx::GLSurface> surface_; | |
101 Client* client_; | |
102 | |
103 base::WeakPtrFactory<CommandBufferLocal> weak_factory_; | |
104 | |
105 DISALLOW_COPY_AND_ASSIGN(CommandBufferLocal); | |
106 }; | |
107 | |
108 } // namespace surfaces | |
109 | |
110 #endif // COMPONENTS_VIEW_MANAGER_SURFACES_COMMAND_BUFFER_LOCAL_H_ | |
OLD | NEW |