• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2023 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expresso or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <GLES2/gl2.h>
16 
17 #include <memory>
18 #include <vector>
19 
20 #include "FrameworkFormats.h"
21 
22 namespace gfxstream {
23 namespace vk {
24 
25 class ColorBufferVk {
26    public:
27     static std::unique_ptr<ColorBufferVk> create(uint32_t handle, uint32_t width, uint32_t height,
28                                                  GLenum format, FrameworkFormat frameworkFormat,
29                                                  bool vulkanOnly, uint32_t memoryProperty);
30 
31     ~ColorBufferVk();
32 
33     bool readToBytes(std::vector<uint8_t>* outBytes);
34     bool readToBytes(uint32_t x, uint32_t y, uint32_t w, uint32_t h, void* outBytes);
35 
36     bool updateFromBytes(const std::vector<uint8_t>& bytes);
37     bool updateFromBytes(uint32_t x, uint32_t y, uint32_t w, uint32_t h, const void* bytes);
38 
39    private:
40     ColorBufferVk(uint32_t handle);
41 
42     const uint32_t mHandle;
43 };
44 
45 }  // namespace vk
46 }  // namespace gfxstream
47