mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
* Run Flutter on iOS and Android with color correct Skia (#3716) ***Turns on color correct rendering for Android and iOS ***Communicates dst color space to raster cache ***Turns on color space aware image decoding Test: ***color_testing_demo on Pixel XL ***flutter_gallery on iPad Mini and iPad Pro (haven't figured out how to run manual_tests on iOS) TODO: I needed to split up this CL somewhere. These are follow-up tasks. ***Make desktop backends color correct ***Make debugging tools (ex: encoding frames to png) preserve color space ***Investigate using UIKit API to allow iOS to fine tune color space of rendered content
72 lines
2.1 KiB
C++
72 lines
2.1 KiB
C++
// Copyright 2016 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.
|
|
|
|
#ifndef FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_GL_H_
|
|
#define FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_GL_H_
|
|
|
|
#include <jni.h>
|
|
#include <memory>
|
|
|
|
#include "flutter/shell/gpu/gpu_surface_gl.h"
|
|
#include "flutter/shell/platform/android/android_context_gl.h"
|
|
#include "flutter/shell/platform/android/android_environment_gl.h"
|
|
#include "flutter/shell/platform/android/android_surface.h"
|
|
#include "lib/ftl/macros.h"
|
|
|
|
namespace shell {
|
|
|
|
class AndroidSurfaceGL : public GPUSurfaceGLDelegate, public AndroidSurface {
|
|
public:
|
|
explicit AndroidSurfaceGL(PlatformView::SurfaceConfig offscreen_config);
|
|
|
|
~AndroidSurfaceGL() override;
|
|
|
|
bool IsValid() const;
|
|
|
|
bool IsOffscreenContextValid() const;
|
|
|
|
std::unique_ptr<Surface> CreateGPUSurface() override;
|
|
|
|
void TeardownOnScreenContext() override;
|
|
|
|
SkISize OnScreenSurfaceSize() const override;
|
|
|
|
bool OnScreenSurfaceResize(const SkISize& size) const override;
|
|
|
|
bool ResourceContextMakeCurrent() override;
|
|
|
|
bool SetNativeWindow(ftl::RefPtr<AndroidNativeWindow> window,
|
|
PlatformView::SurfaceConfig config) override;
|
|
|
|
bool GLContextMakeCurrent() override;
|
|
|
|
bool GLContextClearCurrent() override;
|
|
|
|
bool GLContextPresent() override;
|
|
|
|
intptr_t GLContextFBO() const override;
|
|
|
|
sk_sp<SkColorSpace> ColorSpace() const override {
|
|
// TODO:
|
|
// We can render more consistently across devices when Android makes it
|
|
// possible to query for the color space of the display.
|
|
return onscreen_context_->SupportsSRGB() ? SkColorSpace::MakeSRGB()
|
|
: nullptr;
|
|
}
|
|
|
|
void SetFlutterView(
|
|
const fml::jni::JavaObjectWeakGlobalRef& flutter_view) override;
|
|
|
|
private:
|
|
ftl::RefPtr<AndroidContextGL> onscreen_context_;
|
|
ftl::RefPtr<AndroidContextGL> offscreen_context_;
|
|
sk_sp<GrContext> gr_context_;
|
|
|
|
FTL_DISALLOW_COPY_AND_ASSIGN(AndroidSurfaceGL);
|
|
};
|
|
|
|
} // namespace shell
|
|
|
|
#endif // FLUTTER_SHELL_PLATFORM_ANDROID_ANDROID_SURFACE_GL_H_
|