gaaclarke f51ea3b01f [Impeller] Adds wide gamut support for iOS. (flutter/engine#39111)
* Implemented wide gamut images for iOS

Moved the surface to an extended range color format.

* wrong gamma but default pixel format set to bgra10_xr

* BGR10_XR add

* format

* updated todos

* updated todo with information about pixel formats

* switched logic for determining if we have a wide gamut image

* cleaned up gamut math to match style and linked source

* made the color attachment pixel format match the surface

* updated vulkan format switch

* removed comment

* added enable disable switch

* moved default to bgr10 for now since there is a bug where someone is still reading this, msaa?

* fixed the decoder settings to make sure we don't lose wide gamut colors

* fixed stored srgb gamut variable

* fixed false lint

* updated test

* added ability to grab the surface data for tests

* made the screenshot utility return the format

* added width and height to the platform channel payload

* fixed a couple of broken targets

* moved back the default pixel buffer format

* cleanup and add docstrings

* made the surfacedata feature only available in debug builds

* added decoding unit test

* fixed objc tests

* turned off by default

* bdero feedback1

* bdero2

* bdero3

* fixed merge issue

* removed using std::shared_ptr
2023-02-11 00:08:20 +00:00

65 lines
1.6 KiB
C++

// Copyright 2013 The Flutter 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_FLOW_SURFACE_H_
#define FLUTTER_FLOW_SURFACE_H_
#include <memory>
#include "flutter/common/graphics/gl_context_switch.h"
#include "flutter/flow/embedded_views.h"
#include "flutter/flow/surface_frame.h"
#include "flutter/fml/macros.h"
namespace impeller {
class AiksContext;
} // namespace impeller
namespace flutter {
/// Abstract Base Class that represents where we will be rendering content.
class Surface {
public:
/// A screenshot of the surface's raw data.
struct SurfaceData {
std::string pixel_format;
sk_sp<SkData> data;
};
Surface();
virtual ~Surface();
virtual bool IsValid() = 0;
virtual std::unique_ptr<SurfaceFrame> AcquireFrame(const SkISize& size) = 0;
virtual SkMatrix GetRootTransformation() const = 0;
virtual GrDirectContext* GetContext() = 0;
virtual std::unique_ptr<GLContextResult> MakeRenderContextCurrent();
virtual bool ClearRenderContext();
virtual bool AllowsDrawingWhenGpuDisabled() const;
virtual bool EnableRasterCache() const;
virtual impeller::AiksContext* GetAiksContext() const;
/// Capture the `SurfaceData` currently present in the surface.
///
/// Not guaranteed to work on all setups and not intended to be used in
/// production. The data field will be null if it was unable to work.
virtual SurfaceData GetSurfaceData() const;
private:
FML_DISALLOW_COPY_AND_ASSIGN(Surface);
};
} // namespace flutter
#endif // FLUTTER_FLOW_SURFACE_H_