Home | History | Annotate | Download | only in gpu
      1 // Copyright 2014 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 CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_
      6 #define CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_
      7 
      8 #include "base/memory/ref_counted.h"
      9 #include "base/memory/scoped_ptr.h"
     10 #include "ui/gfx/geometry/size.h"
     11 #include "ui/gfx/gpu_memory_buffer.h"
     12 
     13 namespace gfx {
     14 class GLImage;
     15 }
     16 
     17 namespace content {
     18 
     19 class GpuMemoryBufferFactory {
     20  public:
     21   GpuMemoryBufferFactory() {}
     22   virtual ~GpuMemoryBufferFactory() {}
     23 
     24   // Creates a new platform specific factory instance.
     25   static scoped_ptr<GpuMemoryBufferFactory> Create();
     26 
     27   // Creates a GPU memory buffer instance from |handle|. Whether the storage for
     28   // the buffer is passed with the handle or allocated as part of buffer
     29   // creation depends on the type. A valid handle is returned on success.
     30   virtual gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer(
     31       const gfx::GpuMemoryBufferHandle& handle,
     32       const gfx::Size& size,
     33       unsigned internalformat,
     34       unsigned usage) = 0;
     35 
     36   // Destroys GPU memory buffer identified by |handle|.
     37   virtual void DestroyGpuMemoryBuffer(
     38       const gfx::GpuMemoryBufferHandle& handle) = 0;
     39 
     40   // Creates a GLImage instance for GPU memory buffer identified by |handle|.
     41   // |client_id| should be set to the client requesting the creation of instance
     42   // and can be used by factory implementation to verify access rights.
     43   virtual scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
     44       const gfx::GpuMemoryBufferHandle& handle,
     45       const gfx::Size& size,
     46       unsigned internalformat,
     47       int client_id) = 0;
     48 
     49  private:
     50   DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferFactory);
     51 };
     52 
     53 }  // namespace content
     54 
     55 #endif  // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_H_
     56