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

gpu / command_buffer / service / shared_image / dawn_egl_image_representation.h [blame]

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_DAWN_EGL_IMAGE_REPRESENTATION_H_
#define GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_DAWN_EGL_IMAGE_REPRESENTATION_H_

#include "gpu/command_buffer/service/shared_image/shared_image_representation.h"
#include "ui/gl/scoped_egl_image.h"

typedef void* EGLImage;

namespace gpu {

class GPU_GLES2_EXPORT DawnEGLImageRepresentation
    : public DawnImageRepresentation {
 public:
  DawnEGLImageRepresentation(
      std::unique_ptr<GLTextureImageRepresentationBase> gl_representation,
      void* egl_image,
      SharedImageManager* manager,
      SharedImageBacking* backing,
      MemoryTypeTracker* tracker,
      const wgpu::Device& device,
      std::vector<wgpu::TextureFormat> view_formats);
  DawnEGLImageRepresentation(
      std::unique_ptr<GLTextureImageRepresentationBase> gl_representation,
      gl::ScopedEGLImage owned_egl_image,
      SharedImageManager* manager,
      SharedImageBacking* backing,
      MemoryTypeTracker* tracker,
      const wgpu::Device& device,
      std::vector<wgpu::TextureFormat> view_formats);
  ~DawnEGLImageRepresentation() override;

 private:
  wgpu::Texture BeginAccess(wgpu::TextureUsage usage,
                            wgpu::TextureUsage internal_usage) override;
  void EndAccess() override;

 private:
  std::unique_ptr<GLTextureImageRepresentationBase> gl_representation_;
  gl::ScopedEGLImage owned_egl_image_;
  raw_ptr<void> egl_image_ = nullptr;  // EGLImageKHR
  const wgpu::Device device_;
  wgpu::Texture texture_;
  std::vector<wgpu::TextureFormat> view_formats_;
};

}  // namespace gpu

#endif  // GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_DAWN_EGL_IMAGE_REPRESENTATION_H_