File: gles2_external_framebuffer.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (96 lines) | stat: -rw-r--r-- 3,259 bytes parent folder | download | duplicates (11)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright 2022 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_GLES2_EXTERNAL_FRAMEBUFFER_H_
#define GPU_COMMAND_BUFFER_SERVICE_GLES2_EXTERNAL_FRAMEBUFFER_H_

#include <memory>

#include "base/containers/flat_map.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/service/shared_image/shared_image_representation.h"
#include "gpu/gpu_gles2_export.h"
#include "ui/gl/gl_bindings.h"

namespace gpu {
class SharedImageRepresentationFactory;
}

namespace gpu::gles2 {
class FeatureInfo;

// Encapsulates FrameBuffer Object and corresponding attachments for use as
// default framebuffer from command decoders. Only user of default emulated
// framebuffer is NaCL and hopefully will be deleted at some point.
class GPU_GLES2_EXPORT GLES2ExternalFramebuffer {
 public:
  GLES2ExternalFramebuffer(
      bool passthrough,
      const FeatureInfo& feature_info,
      SharedImageRepresentationFactory* shared_image_representation_factory);
  ~GLES2ExternalFramebuffer();

  // Attaches new SharedImage (if mailbox is not zero) to the framebuffer and
  // resolves and detaches previously attached image if any.
  bool AttachSharedImage(const Mailbox& mailbox,
                         int samples_count,
                         bool preserve,
                         bool need_depth,
                         bool need_stencil);

  // If the framebuffer is multisampled, resolves the framebuffer into current
  // SharedImage. If we preserve contents, blits preserved buffer to the shared
  // image. Detaches shared image from the framebuffer.
  void ResolveAndDetach();

  GLuint GetFramebufferId() const;
  bool IsSharedImageAttached() const;
  void Destroy(bool have_context);

  // Validating command decoder needs these for validation.
  gfx::Size GetSize() const;
  GLenum GetColorFormat() const;
  GLenum GetDepthFormat() const;
  GLenum GetStencilFormat() const;
  int GetSamplesCount() const;
  bool HasAlpha() const;
  bool HasDepth() const;
  bool HasStencil() const;

 private:
  class Attachment;

  bool UpdateAttachment(GLenum attachment,
                        const gfx::Size& size,
                        int samples,
                        GLenum format);
  std::unique_ptr<Attachment> CreateAttachment(GLenum attachment,
                                               const gfx::Size& size,
                                               int samples,
                                               GLenum format);

  // Caps
  const bool passthrough_;
  GLint max_sample_count_ = 0;
  bool packed_depth_stencil_ = false;
  bool supports_separate_fbo_bindings_ = false;
  bool supports_window_rectangles_ = false;

  // Main frame buffer
  GLuint fbo_ = 0;

  base::flat_map<GLenum, std::unique_ptr<Attachment>> attachments_;

  const raw_ptr<SharedImageRepresentationFactory>
      shared_image_representation_factory_;

  std::unique_ptr<GLTextureImageRepresentationBase>
      shared_image_representation_;
  std::unique_ptr<GLTextureImageRepresentationBase::ScopedAccess>
      scoped_access_;
};

}  // namespace gpu::gles2

#endif  // GPU_COMMAND_BUFFER_SERVICE_GLES2_EXTERNAL_FRAMEBUFFER_H_