1 // Copyright 2018 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 GPU_IPC_RASTER_IN_PROCESS_CONTEXT_H_ 6 #define GPU_IPC_RASTER_IN_PROCESS_CONTEXT_H_ 7 8 #include <memory> 9 10 #include "base/macros.h" 11 #include "base/memory/scoped_refptr.h" 12 #include "base/single_thread_task_runner.h" 13 #include "gpu/ipc/command_buffer_task_executor.h" 14 #include "gpu/ipc/in_process_command_buffer.h" 15 16 namespace base { 17 class TestSimpleTaskRunner; 18 } // namespace base 19 20 namespace gpu { 21 class CommandBufferHelper; 22 class ContextSupport; 23 class ServiceTransferCache; 24 class SharedImageInterface; 25 class TransferBuffer; 26 struct GpuFeatureInfo; 27 struct SharedMemoryLimits; 28 29 namespace raster { 30 class RasterInterface; 31 class RasterImplementation; 32 } // namespace raster 33 34 // Runs client and server side command buffer code in process. Only supports 35 // RasterInterface. 36 class RasterInProcessContext { 37 public: 38 RasterInProcessContext(); 39 ~RasterInProcessContext(); 40 41 // |attrib_list| must be null or a NONE-terminated list of attribute/value 42 // pairs. |gpu_channel_manager| should be non-null when used in the GPU 43 // process. 44 ContextResult Initialize( 45 CommandBufferTaskExecutor* task_executor, 46 const ContextCreationAttribs& attribs, 47 const SharedMemoryLimits& memory_limits, 48 GpuMemoryBufferManager* gpu_memory_buffer_manager, 49 ImageFactory* image_factory, 50 GpuChannelManagerDelegate* gpu_channel_manager_delegate, 51 gpu::raster::GrShaderCache* gr_shader_cache, 52 GpuProcessActivityFlags* activity_flags); 53 54 const Capabilities& GetCapabilities() const; 55 const GpuFeatureInfo& GetGpuFeatureInfo() const; 56 57 // Allows direct access to the RasterImplementation so a 58 // RasterInProcessContext can be used without making it current. 59 gpu::raster::RasterInterface* GetImplementation(); 60 61 ContextSupport* GetContextSupport(); 62 63 SharedImageInterface* GetSharedImageInterface(); 64 65 // Test only functions. 66 ServiceTransferCache* GetTransferCacheForTest() const; 67 InProcessCommandBuffer* GetCommandBufferForTest() const; 68 int GetRasterDecoderIdForTest() const; 69 70 // Test only function. Returns false if using passthrough decoding, which is 71 // currently unsupported. 72 static bool SupportedInTest(); 73 74 private: 75 std::unique_ptr<CommandBufferHelper> helper_; 76 std::unique_ptr<TransferBuffer> transfer_buffer_; 77 std::unique_ptr<raster::RasterImplementation> raster_implementation_; 78 std::unique_ptr<InProcessCommandBuffer> command_buffer_; 79 scoped_refptr<base::TestSimpleTaskRunner> client_task_runner_; 80 81 DISALLOW_COPY_AND_ASSIGN(RasterInProcessContext); 82 }; 83 84 } // namespace gpu 85 86 #endif // GPU_IPC_RASTER_IN_PROCESS_CONTEXT_H_ 87