summaryrefslogtreecommitdiffstats
path: root/chromium/gpu/vulkan/vulkan_surface.h
blob: c1cd166e99af9c3b86e75d13aa382ca05961771c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef GPU_VULKAN_VULKAN_SURFACE_H_
#define GPU_VULKAN_VULKAN_SURFACE_H_

#include "base/memory/scoped_ptr.h"
#include "gpu/vulkan/vulkan_export.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/swap_result.h"

namespace gpu {

class VulkanDeviceQueue;
class VulkanSwapChain;

class VULKAN_EXPORT VulkanSurface {
 public:
  static bool InitializeOneOff();

  // Minimum bit depth of surface.
  enum Format {
    FORMAT_BGRA8888,
    FORMAT_RGB565,

    NUM_SURFACE_FORMATS,
    DEFAULT_SURFACE_FORMAT = FORMAT_BGRA8888
  };

  virtual ~VulkanSurface() = 0;

  virtual bool Initialize(VulkanDeviceQueue* device_queue,
                          VulkanSurface::Format format) = 0;
  virtual void Destroy() = 0;

  virtual gfx::SwapResult SwapBuffers() = 0;

  virtual VulkanSwapChain* GetSwapChain() = 0;

  virtual void Finish() = 0;

  // Create a surface that render directlys into a surface.
  static scoped_ptr<VulkanSurface> CreateViewSurface(
      gfx::AcceleratedWidget window);

 protected:
  VulkanSurface();

 private:
  DISALLOW_COPY_AND_ASSIGN(VulkanSurface);
};

}  // namespace gpu

#endif  // GPU_VULKAN_VULKAN_SURFACE_H_