Home | History | Annotate | Download | only in common
      1 // Copyright 2013 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_COMMAND_BUFFER_COMMON_GPU_CONTROL_H_
      6 #define GPU_COMMAND_BUFFER_COMMON_GPU_CONTROL_H_
      7 
      8 #include <vector>
      9 
     10 #include "base/callback.h"
     11 #include "gpu/command_buffer/common/capabilities.h"
     12 #include "gpu/command_buffer/common/mailbox.h"
     13 #include "gpu/command_buffer/common/types.h"
     14 #include "gpu/gpu_export.h"
     15 
     16 namespace gfx {
     17 class GpuMemoryBuffer;
     18 }
     19 
     20 namespace gpu {
     21 struct ManagedMemoryStats;
     22 
     23 // Common interface for GpuControl implementations.
     24 class GPU_EXPORT GpuControl {
     25  public:
     26   GpuControl() {}
     27   virtual ~GpuControl() {}
     28 
     29   virtual Capabilities GetCapabilities() = 0;
     30 
     31   // Create a gpu memory buffer of the given dimensions and format. Returns
     32   // its ID or -1 on error.
     33   virtual gfx::GpuMemoryBuffer* CreateGpuMemoryBuffer(
     34       size_t width,
     35       size_t height,
     36       unsigned internalformat,
     37       int32* id) = 0;
     38 
     39   // Destroy a gpu memory buffer. The ID must be positive.
     40   virtual void DestroyGpuMemoryBuffer(int32 id) = 0;
     41 
     42   // Generates n unique mailbox names that can be used with
     43   // GL_texture_mailbox_CHROMIUM.
     44   virtual bool GenerateMailboxNames(unsigned num,
     45                                     std::vector<gpu::Mailbox>* names) = 0;
     46 
     47   // Inserts a sync point, returning its ID. Sync point IDs are global and can
     48   // be used for cross-context synchronization.
     49   virtual uint32 InsertSyncPoint() = 0;
     50 
     51   // Runs |callback| when a sync point is reached.
     52   virtual void SignalSyncPoint(uint32 sync_point,
     53                                const base::Closure& callback) = 0;
     54 
     55   // Runs |callback| when a query created via glCreateQueryEXT() has cleared
     56   // passed the glEndQueryEXT() point.
     57   virtual void SignalQuery(uint32 query, const base::Closure& callback) = 0;
     58 
     59   virtual void SetSurfaceVisible(bool visible) = 0;
     60 
     61   virtual void SendManagedMemoryStats(const ManagedMemoryStats& stats) = 0;
     62 
     63   // Invokes the callback once the context has been flushed.
     64   virtual void Echo(const base::Closure& callback) = 0;
     65 
     66  private:
     67   DISALLOW_COPY_AND_ASSIGN(GpuControl);
     68 };
     69 
     70 }  // namespace gpu
     71 
     72 #endif  // GPU_COMMAND_BUFFER_COMMON_GPU_CONTROL_H_
     73