Debian Codegraph @

src/gpu/ganesh/GrCanvas.cpp

raw
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 #include "src/gpu/ganesh/GrCanvas.h"
8
9 #include "include/android/SkCanvasAndroid.h"
10 #include "include/core/SkRect.h"
11 #include "include/gpu/ganesh/GrBackendSurface.h"
12 #include "src/core/SkCanvasPriv.h"
13 #include "src/core/SkDevice.h"
14 #include "src/gpu/ganesh/Device.h"
15 #include "src/gpu/ganesh/GrRenderTarget.h"
16 #include "src/gpu/ganesh/GrRenderTargetProxy.h"
17
18 namespace skgpu::ganesh {
19
20 SurfaceDrawContext* TopDeviceSurfaceDrawContext(const SkCanvas* canvas) {
21 if (auto gpuDevice = SkCanvasPriv::TopDevice(canvas)->asGaneshDevice()) {
22 return gpuDevice->surfaceDrawContext();
23 }
24 return nullptr;
25 }
26
27 SurfaceFillContext* TopDeviceSurfaceFillContext(const SkCanvas* canvas) {
28 if (auto gpuDevice = SkCanvasPriv::TopDevice(canvas)->asGaneshDevice()) {
29 return gpuDevice->surfaceFillContext();
30 }
31 return nullptr;
32 }
33
34 GrRenderTargetProxy* TopDeviceTargetProxy(const SkCanvas* canvas) {
35 if (auto gpuDevice = SkCanvasPriv::TopDevice(canvas)->asGaneshDevice()) {
36 return gpuDevice->targetProxy();
37 }
38 return nullptr;
39 }
40
41 SkIRect TopLayerBounds(const SkCanvas* canvas) {
42 return SkCanvasPriv::TopDevice(canvas)->getGlobalBounds();
43 }
44
45 GrBackendRenderTarget TopLayerBackendRenderTarget(const SkCanvas* canvas) {
46 auto proxy = TopDeviceTargetProxy(canvas);
47 if (!proxy) {
48 return {};
49 }
50 const GrRenderTarget* renderTarget = proxy->peekRenderTarget();
51 return renderTarget ? renderTarget->getBackendRenderTarget() : GrBackendRenderTarget();
52 }
53
54 } // namespace skgpu::ganesh