Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
pipeline_gles.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7namespace impeller {
8
9PipelineGLES::PipelineGLES(std::shared_ptr<ReactorGLES> reactor,
10 std::weak_ptr<PipelineLibrary> library,
11 const PipelineDescriptor& desc,
12 std::shared_ptr<UniqueHandleGLES> handle)
13 : Pipeline(std::move(library), desc),
14 reactor_(std::move(reactor)),
15 handle_(std::move(handle)),
16 is_valid_(handle_->IsValid()) {
17 if (is_valid_) {
18 reactor_->SetDebugLabel(handle_->Get(), GetDescriptor().GetLabel());
19 }
20}
21
22// |Pipeline|
23PipelineGLES::~PipelineGLES() = default;
24
25// |Pipeline|
26bool PipelineGLES::IsValid() const {
27 return is_valid_;
28}
29
30const HandleGLES& PipelineGLES::GetProgramHandle() const {
31 return handle_->Get();
32}
33
34const std::shared_ptr<UniqueHandleGLES> PipelineGLES::GetSharedHandle() const {
35 return handle_;
36}
37
38BufferBindingsGLES* PipelineGLES::GetBufferBindings() const {
39 return buffer_bindings_.get();
40}
41
42bool PipelineGLES::BuildVertexDescriptor(const ProcTableGLES& gl,
43 GLuint program) {
44 if (buffer_bindings_) {
45 return false;
46 }
47 auto vtx_desc = std::make_unique<BufferBindingsGLES>();
48 if (!vtx_desc->RegisterVertexStageInput(
49 gl, GetDescriptor().GetVertexDescriptor()->GetStageInputs(),
50 GetDescriptor().GetVertexDescriptor()->GetStageLayouts())) {
51 return false;
52 }
53 if (!vtx_desc->ReadUniformsBindings(gl, program)) {
54 return false;
55 }
56 // Cache the y-flip uniform; -1 if not declared.
57 y_flip_uniform_location_ = gl.GetUniformLocation(program, "_impeller_y_flip");
58 buffer_bindings_ = std::move(vtx_desc);
59 return true;
60}
61
62[[nodiscard]] bool PipelineGLES::BindProgram() const {
63 if (!handle_->IsValid()) {
64 return false;
65 }
66 auto handle = reactor_->GetGLHandle(handle_->Get());
67 if (!handle.has_value()) {
68 return false;
69 }
70 reactor_->GetProcTable().UseProgram(handle.value());
71 return true;
72}
73
74[[nodiscard]] bool PipelineGLES::UnbindProgram() const {
75 if (reactor_) {
76 reactor_->GetProcTable().UseProgram(0u);
77 }
78 return true;
79}
80
81} // namespace impeller
Sets up stage bindings for single draw call in the OpenGLES backend.
Represents a handle to an underlying OpenGL object. Unlike OpenGL object handles, these handles can b...
Definition handle_gles.h:42
Definition ref_ptr.h:261
fuchsia::ui::composition::ParentViewportWatcherHandle handle_
std::shared_ptr< ReactorGLES > reactor