flutter_flutter/shell/gpu/gpu_surface_gl.h
mattsarett ffe8181ffe Run Flutter on iOS and Android with color correct Skia (#3743)
* 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
2017-06-09 08:39:21 -04:00

64 lines
1.6 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 SHELL_GPU_GPU_SURFACE_GL_H_
#define SHELL_GPU_GPU_SURFACE_GL_H_
#include "flutter/shell/common/surface.h"
#include "flutter/synchronization/debug_thread_checker.h"
#include "lib/ftl/macros.h"
#include "lib/ftl/memory/weak_ptr.h"
#include "third_party/skia/include/gpu/GrContext.h"
namespace shell {
class GPUSurfaceGLDelegate {
public:
virtual bool GLContextMakeCurrent() = 0;
virtual bool GLContextClearCurrent() = 0;
virtual bool GLContextPresent() = 0;
virtual intptr_t GLContextFBO() const = 0;
// TODO: Update Mac desktop and make this pure virtual.
virtual sk_sp<SkColorSpace> ColorSpace() const { return nullptr; }
};
class GPUSurfaceGL : public Surface {
public:
GPUSurfaceGL(GPUSurfaceGLDelegate* delegate);
~GPUSurfaceGL() override;
bool Setup() override;
bool IsValid() override;
std::unique_ptr<SurfaceFrame> AcquireFrame(const SkISize& size) override;
GrContext* GetContext() override;
private:
GPUSurfaceGLDelegate* delegate_;
sk_sp<GrContext> context_;
sk_sp<SkSurface> cached_surface_;
ftl::WeakPtrFactory<GPUSurfaceGL> weak_factory_;
sk_sp<SkSurface> CreateSurface(const SkISize& size);
sk_sp<SkSurface> AcquireSurface(const SkISize& size);
bool PresentSurface(SkCanvas* canvas);
bool SelectPixelConfig(GrPixelConfig* config);
FTL_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceGL);
};
} // namespace shell
#endif // SHELL_GPU_GPU_SURFACE_GL_H_