Flutter Engine
 
Loading...
Searching...
No Matches
context_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
8#include "impeller/entity/gles/entity_shaders_gles.h"
9#include "impeller/entity/gles/framebuffer_blend_shaders_gles.h"
11
13
15 std::function<void*(const char* gl_proc_name)> proc_address_callback) {
16 auto proc_table = std::make_unique<ProcTableGLES>(
17 impeller::ProcTableGLES(std::move(proc_address_callback)));
18 if (!proc_table || !proc_table->IsValid()) {
19 VALIDATION_LOG << "Could not create valid OpenGL ES proc. table.";
20 return {};
21 }
22 std::vector<std::shared_ptr<fml::Mapping>> shader_mappings = {
23 std::make_shared<fml::NonOwnedMapping>(
24 impeller_entity_shaders_gles_data,
25 impeller_entity_shaders_gles_length),
26 std::make_shared<fml::NonOwnedMapping>(
27 impeller_framebuffer_blend_shaders_gles_data,
28 impeller_framebuffer_blend_shaders_gles_length),
29 };
30 auto impeller_context = impeller::ContextGLES::Create(
31 Flags{}, std::move(proc_table), shader_mappings, false);
32 if (!impeller_context) {
33 VALIDATION_LOG << "Could not create Impeller context.";
34 return {};
35 }
36 auto reactor_worker = std::make_shared<ReactorWorkerGLES>();
37 auto worker_id = impeller_context->AddReactorWorker(reactor_worker);
38 if (!worker_id.has_value()) {
39 VALIDATION_LOG << "Could not add reactor worker.";
40 return {};
41 }
42 return Create(std::move(impeller_context), std::move(reactor_worker));
43}
44
46 std::shared_ptr<impeller::Context> impeller_context,
47 std::shared_ptr<ReactorWorkerGLES> worker) {
48 // Can't call Create because of private constructor. Adopt the raw pointer
49 // instead.
50 auto context = Adopt<Context>(
51 new ContextGLES(std::move(impeller_context), std::move(worker)));
52
53 if (!context->IsValid()) {
54 VALIDATION_LOG << "Could not create valid context.";
55 return {};
56 }
57 return context;
58}
59
60ContextGLES::ContextGLES(std::shared_ptr<impeller::Context> context,
61 std::shared_ptr<ReactorWorkerGLES> worker)
62 : Context(std::move(context)), worker_(std::move(worker)) {}
63
65
66} // namespace impeller::interop
static std::shared_ptr< ContextGLES > Create(const Flags &flags, std::unique_ptr< ProcTableGLES > gl, const std::vector< std::shared_ptr< fml::Mapping > > &shader_libraries, bool enable_gpu_tracing)
static ScopedObject< Context > Create(std::function< void *(const char *gl_proc_name)> proc_address_callback)
Definition ref_ptr.h:261
#define VALIDATION_LOG
Definition validation.h:91