flutter_flutter/shell/platform/embedder/platform_view_embedder.cc
Chinmay Garde def8061d49 Create a window toolkit agnostic Flutter engine API. (#3987)
* The Flutter engine will be shipped as a shared library.
* The engine is renderer and window toolkit agnostic.
* The simple public C API is described in embedder.h.
* ABI breaking changes will be indicated by changing the FLUTTER_ENGINE_VERSION.
* A simple GLFW based example of this API is available at https://gist.github.com/chinmaygarde/8abf44921f7d87f6da7bf026267c4792
2017-08-23 16:05:16 -07:00

56 lines
1.6 KiB
C++

// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/shell/platform/embedder/platform_view_embedder.h"
#include "flutter/shell/gpu/gpu_rasterizer.h"
namespace shell {
PlatformViewEmbedder::PlatformViewEmbedder(DispatchTable dispatch_table)
: PlatformView(std::make_unique<GPURasterizer>(nullptr)),
dispatch_table_(dispatch_table) {}
PlatformViewEmbedder::~PlatformViewEmbedder() {
NotifyDestroyed();
}
bool PlatformViewEmbedder::GLContextMakeCurrent() {
return dispatch_table_.gl_make_current_callback();
}
bool PlatformViewEmbedder::GLContextClearCurrent() {
return dispatch_table_.gl_clear_current_callback();
}
bool PlatformViewEmbedder::GLContextPresent() {
return dispatch_table_.gl_present_callback();
}
intptr_t PlatformViewEmbedder::GLContextFBO() const {
return dispatch_table_.gl_fbo_callback();
}
bool PlatformViewEmbedder::SurfaceSupportsSRGB() const {
return true;
}
void PlatformViewEmbedder::Attach() {
CreateEngine();
PostAddToShellTask();
NotifyCreated(std::make_unique<shell::GPUSurfaceGL>(this));
}
bool PlatformViewEmbedder::ResourceContextMakeCurrent() {
// Unsupported.
return false;
}
void PlatformViewEmbedder::RunFromSource(const std::string& assets_directory,
const std::string& main,
const std::string& packages) {
FTL_LOG(INFO) << "Hot reloading is unsupported on this platform.";
}
} // namespace shell