Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GrBackendSurface.h
1 /*
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"
12 #include "gl/GrGLTypes.h"
13 
14 #ifdef SK_VULKAN
15 #include "vk/GrVkTypes.h"
16 #endif
17 
19 public:
20  GrBackendTexture(int width,
21  int height,
22  GrPixelConfig config,
23  const GrGLTextureInfo& glInfo);
24 
25 #ifdef SK_VULKAN
26  GrBackendTexture(int width,
27  int height,
28  const GrVkImageInfo& vkInfo);
29 #endif
30 
31  int width() const { return fWidth; }
32  int height() const { return fHeight; }
33  GrPixelConfig config() const { return fConfig; }
34  GrBackend backend() const {return fBackend; }
35 
36  // If the backend API is GL, this returns a pointer to the GrGLTextureInfo struct. Otherwise
37  // it returns nullptr.
38  const GrGLTextureInfo* getGLTextureInfo() const;
39 
40 #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 
46 private:
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 {
60  GrGLTextureInfo fGLInfo;
61 #ifdef SK_VULKAN
62  GrVkImageInfo fVkInfo;
63 #endif
64  };
65 };
66 
68 public:
69  GrBackendRenderTarget(int width,
70  int height,
71  int sampleCnt,
72  int stencilBits,
73  GrPixelConfig config,
74  const GrGLFramebufferInfo& glInfo);
75 
76 #ifdef SK_VULKAN
77  GrBackendRenderTarget(int width,
78  int height,
79  int sampleCnt,
80  int stencilBits,
81  const GrVkImageInfo& vkInfo);
82 #endif
83 
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 
91  // If the backend API is GL, this returns a pointer to the GrGLFramebufferInfo struct. Otherwise
92  // it returns nullptr.
93  const GrGLFramebufferInfo* getGLFramebufferInfo() const;
94 
95 #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 
101 private:
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 {
118  GrGLFramebufferInfo fGLInfo;
119 #ifdef SK_VULKAN
120  GrVkImageInfo fVkInfo;
121 #endif
122  };
123 };
124 
125 #endif
126 
Definition: GrTypes.h:679
Definition: GrBackendSurface.h:67
SkSurface is responsible for managing the pixels that a canvas draws into.
Definition: SkSurface.h:32
Gr can wrap an existing render target created by the client in the 3D API with a GrRenderTarget objec...
Definition: GrTypes.h:711
Definition: GrBackendSurface.h:18
SkImage is an abstraction for drawing a rectagle of pixels, though the particular type of image could...
Definition: SkImage.h:48