flutter_flutter/shell/gpu/gpu_surface_gl.h
Brian Osman 0a7155d4e1
Disable linear blending, use SkColorSpaceXformCanvas instead (#4355)
This retains gamut correction (adjusting colors for screens with different capabilities), but does all blending and interpolation with sRGB-encoded values. That matches the behavior expected by most users, as well as the behavior of nearly all other systems. It also greatly simplifies the EGL code.

A future Skia change will make this behavior more of a first-class citizen, so some of these implementation details will change again, but the behavior will not. The bulk of this change (elimination of complication from the GL surface code) is permanent - it's just the SkColorSpaceXformCanvas that will be replaced.
2017-11-14 13:33:26 -05:00

60 lines
1.4 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/fml/memory/weak_ptr.h"
#include "flutter/shell/common/surface.h"
#include "flutter/synchronization/debug_thread_checker.h"
#include "lib/fxl/macros.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;
};
class GPUSurfaceGL : public Surface {
public:
GPUSurfaceGL(GPUSurfaceGLDelegate* delegate);
~GPUSurfaceGL() 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> onscreen_surface_;
bool valid_ = false;
fml::WeakPtrFactory<GPUSurfaceGL> weak_factory_;
bool CreateOrUpdateSurfaces(const SkISize& size);
sk_sp<SkSurface> AcquireRenderSurface(const SkISize& size);
bool PresentSurface(SkCanvas* canvas);
bool SelectPixelConfig(GrPixelConfig* config);
FXL_DISALLOW_COPY_AND_ASSIGN(GPUSurfaceGL);
};
} // namespace shell
#endif // SHELL_GPU_GPU_SURFACE_GL_H_