Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
WindowContext.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#ifndef WindowContext_DEFINED
8#define WindowContext_DEFINED
9
12#include "include/gpu/GrTypes.h"
14
15class GrDirectContext;
16class SkSurface;
17#if defined(SK_GRAPHITE)
18namespace skgpu::graphite {
19class Context;
20class Recorder;
21}
22#endif
23
24namespace skwindow {
25
27public:
29
30 virtual ~WindowContext();
31
33
34 void swapBuffers();
35
36 virtual bool isValid() = 0;
37
38 virtual void resize(int w, int h) = 0;
39
40 virtual void activate(bool isActive) {}
41
43 virtual void setDisplayParams(const DisplayParams& params) = 0;
44
46#if defined(SK_GRAPHITE)
47 skgpu::graphite::Context* graphiteContext() const { return fGraphiteContext.get(); }
48 skgpu::graphite::Recorder* graphiteRecorder() const { return fGraphiteRecorder.get(); }
49#endif
50
51 int width() const { return fWidth; }
52 int height() const { return fHeight; }
53 SkISize dimensions() const { return {fWidth, fHeight}; }
54 int sampleCount() const { return fSampleCount; }
55 int stencilBits() const { return fStencilBits; }
56
57protected:
58 virtual bool isGpuContext() { return true; }
59
60 virtual void onSwapBuffers() = 0;
61
63#if defined(SK_GRAPHITE)
64 std::unique_ptr<skgpu::graphite::Context> fGraphiteContext;
65 std::unique_ptr<skgpu::graphite::Recorder> fGraphiteRecorder;
66#endif
67
68 int fWidth;
71
72 // parameters obtained from the native window
73 // Note that the platform .cpp file is responsible for
74 // initializing fSampleCount and fStencilBits!
75 int fSampleCount = 1;
76 int fStencilBits = 0;
77};
78
79} // namespace skwindow
80
81#endif
T * get() const
Definition SkRefCnt.h:303
sk_sp< GrDirectContext > fContext
virtual bool isValid()=0
DisplayParams fDisplayParams
virtual sk_sp< SkSurface > getBackbufferSurface()=0
virtual void setDisplayParams(const DisplayParams &params)=0
const DisplayParams & getDisplayParams()
SkISize dimensions() const
virtual bool isGpuContext()
GrDirectContext * directContext() const
virtual void resize(int w, int h)=0
virtual void onSwapBuffers()=0
virtual void activate(bool isActive)
const EmbeddedViewParams * params
SkScalar w
SkScalar h