blob: cf5d82b1d54a83e5e858cd514e6519c726c93883 [file] [log] [blame]
Greg Daniel94403452017-04-18 15:52:36 -04001/*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrBackendSurface_DEFINED
9#define GrBackendSurface_DEFINED
10
11#include "GrTypes.h"
Greg Danielbcf612b2017-05-01 13:50:58 +000012#include "gl/GrGLTypes.h"
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000013
14#ifdef SK_VULKAN
Greg Danielbcf612b2017-05-01 13:50:58 +000015#include "vk/GrVkTypes.h"
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000016#endif
Greg Daniel94403452017-04-18 15:52:36 -040017
Brian Salomonec045b42017-07-07 10:34:40 -040018class SK_API GrBackendTexture {
Greg Daniel94403452017-04-18 15:52:36 -040019public:
20 GrBackendTexture(int width,
21 int height,
Robert Phillipsfad9e3f2017-06-13 22:16:08 +000022 GrPixelConfig config,
23 const GrGLTextureInfo& glInfo);
Greg Danielc0f8e422017-06-13 13:47:53 -040024
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000025#ifdef SK_VULKAN
26 GrBackendTexture(int width,
27 int height,
28 const GrVkImageInfo& vkInfo);
29#endif
30
Greg Daniel94403452017-04-18 15:52:36 -040031 int width() const { return fWidth; }
32 int height() const { return fHeight; }
33 GrPixelConfig config() const { return fConfig; }
34 GrBackend backend() const {return fBackend; }
35
Robert Phillipsfad9e3f2017-06-13 22:16:08 +000036 // If the backend API is GL, this returns a pointer to the GrGLTextureInfo struct. Otherwise
37 // it returns nullptr.
38 const GrGLTextureInfo* getGLTextureInfo() const;
Greg Danielc0f8e422017-06-13 13:47:53 -040039
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000040#ifdef SK_VULKAN
41 // If the backend API is Vulkan, this returns a pointer to the GrVkImageInfo struct. Otherwise
42 // it returns nullptr.
43 const GrVkImageInfo* getVkImageInfo() const;
44#endif
45
Greg Daniel94403452017-04-18 15:52:36 -040046private:
47 // Temporary constructor which can be used to convert from a GrBackendTextureDesc.
48 GrBackendTexture(const GrBackendTextureDesc& desc, GrBackend backend);
49
50 // Friending for access to above constructor taking a GrBackendTextureDesc
51 friend class SkImage;
52 friend class SkSurface;
53
54 int fWidth; //<! width in pixels
55 int fHeight; //<! height in pixels
56 GrPixelConfig fConfig;
57 GrBackend fBackend;
58
59 union {
Robert Phillipsfad9e3f2017-06-13 22:16:08 +000060 GrGLTextureInfo fGLInfo;
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000061#ifdef SK_VULKAN
62 GrVkImageInfo fVkInfo;
63#endif
Greg Daniel94403452017-04-18 15:52:36 -040064 };
65};
66
Brian Salomonec045b42017-07-07 10:34:40 -040067class SK_API GrBackendRenderTarget {
Greg Daniel94403452017-04-18 15:52:36 -040068public:
69 GrBackendRenderTarget(int width,
70 int height,
71 int sampleCnt,
72 int stencilBits,
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000073 GrPixelConfig config,
74 const GrGLFramebufferInfo& glInfo);
Greg Daniel94403452017-04-18 15:52:36 -040075
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000076#ifdef SK_VULKAN
Greg Daniel94403452017-04-18 15:52:36 -040077 GrBackendRenderTarget(int width,
78 int height,
79 int sampleCnt,
80 int stencilBits,
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000081 const GrVkImageInfo& vkInfo);
82#endif
Greg Daniel94403452017-04-18 15:52:36 -040083
84 int width() const { return fWidth; }
85 int height() const { return fHeight; }
86 int sampleCnt() const { return fSampleCnt; }
87 int stencilBits() const { return fStencilBits; }
88 GrPixelConfig config() const { return fConfig; }
89 GrBackend backend() const {return fBackend; }
90
Robert Phillipsfad9e3f2017-06-13 22:16:08 +000091 // If the backend API is GL, this returns a pointer to the GrGLFramebufferInfo struct. Otherwise
92 // it returns nullptr.
93 const GrGLFramebufferInfo* getGLFramebufferInfo() const;
Greg Danielc0f8e422017-06-13 13:47:53 -040094
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000095#ifdef SK_VULKAN
96 // If the backend API is Vulkan, this returns a pointer to the GrVkImageInfo struct. Otherwise
97 // it returns nullptr
98 const GrVkImageInfo* getVkImageInfo() const;
99#endif
100
Greg Daniel94403452017-04-18 15:52:36 -0400101private:
102 // Temporary constructor which can be used to convert from a GrBackendRenderTargetDesc.
103 GrBackendRenderTarget(const GrBackendRenderTargetDesc& desc, GrBackend backend);
104
105 // Friending for access to above constructor taking a GrBackendTextureDesc
106 friend class SkSurface;
107
108 int fWidth; //<! width in pixels
109 int fHeight; //<! height in pixels
110
111 int fSampleCnt;
112 int fStencilBits;
113 GrPixelConfig fConfig;
114
115 GrBackend fBackend;
116
117 union {
Robert Phillipsfad9e3f2017-06-13 22:16:08 +0000118 GrGLFramebufferInfo fGLInfo;
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000119#ifdef SK_VULKAN
120 GrVkImageInfo fVkInfo;
121#endif
Greg Daniel94403452017-04-18 15:52:36 -0400122 };
123};
124
125#endif
126