1/*
2 * Copyright 2014 Google Inc.
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
8#ifndef SkSurface_Ganesh_DEFINED
9#define SkSurface_Ganesh_DEFINED
10
11#include "include/core/SkTypes.h"
12
13#include "include/core/SkImageInfo.h"
14#include "include/core/SkRefCnt.h"
15#include "include/core/SkSamplingOptions.h"
16#include "include/core/SkScalar.h"
17#include "include/gpu/GrBackendSurface.h"
18#include "src/image/SkSurface_Base.h"
19
20class GrBackendSemaphore;
21class GrDeferredDisplayList;
22class GrRecordingContext;
23class GrSurfaceCharacterization;
24class SkCanvas;
25class SkCapabilities;
26class SkColorSpace;
27class SkImage;
28class SkPaint;
29class SkPixmap;
30class SkSurface;
31enum GrSurfaceOrigin : int;
32namespace skgpu {
33namespace ganesh {
34class Device;
35}
36} // namespace skgpu
37struct SkIRect;
38struct SkISize;
39
40class SkSurface_Ganesh : public SkSurface_Base {
41public:
42 SkSurface_Ganesh(sk_sp<skgpu::ganesh::Device>);
43 ~SkSurface_Ganesh() override;
44
45 // From SkSurface.h
46 SkImageInfo imageInfo() const override;
47 bool replaceBackendTexture(const GrBackendTexture&,
48 GrSurfaceOrigin,
49 ContentChangeMode,
50 TextureReleaseProc,
51 ReleaseContext) override;
52
53 // From SkSurface_Base.h
54 SkSurface_Base::Type type() const override { return SkSurface_Base::Type::kGanesh; }
55
56 GrRecordingContext* onGetRecordingContext() const override;
57
58 SkCanvas* onNewCanvas() override;
59 sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override;
60 sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subset) override;
61 void onWritePixels(const SkPixmap&, int x, int y) override;
62 void onAsyncRescaleAndReadPixels(const SkImageInfo& info,
63 SkIRect srcRect,
64 RescaleGamma rescaleGamma,
65 RescaleMode,
66 ReadPixelsCallback callback,
67 ReadPixelsContext context) override;
68 void onAsyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvColorSpace,
69 bool readAlpha,
70 sk_sp<SkColorSpace> dstColorSpace,
71 SkIRect srcRect,
72 SkISize dstSize,
73 RescaleGamma rescaleGamma,
74 RescaleMode,
75 ReadPixelsCallback callback,
76 ReadPixelsContext context) override;
77 bool onCopyOnWrite(ContentChangeMode) override;
78 void onDiscard() override;
79 bool onWait(int numSemaphores,
80 const GrBackendSemaphore* waitSemaphores,
81 bool deleteSemaphoresAfterWait) override;
82 bool onCharacterize(GrSurfaceCharacterization*) const override;
83 bool onIsCompatible(const GrSurfaceCharacterization&) const override;
84 void onDraw(SkCanvas* canvas,
85 SkScalar x,
86 SkScalar y,
87 const SkSamplingOptions&,
88 const SkPaint* paint) override;
89
90 sk_sp<const SkCapabilities> onCapabilities() override;
91
92 skgpu::ganesh::Device* getDevice();
93 GrBackendTexture getBackendTexture(BackendHandleAccess);
94 GrBackendRenderTarget getBackendRenderTarget(BackendHandleAccess);
95 void resolveMSAA();
96 bool draw(sk_sp<const GrDeferredDisplayList>);
97
98private:
99 sk_sp<skgpu::ganesh::Device> fDevice;
100
101 using INHERITED = SkSurface_Base;
102};
103
104#endif // SkSurface_Ganesh_DEFINED
105

source code of flutter_engine/third_party/skia/src/gpu/ganesh/surface/SkSurface_Ganesh.h