Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrSurfaceProxyView.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 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
8#ifndef GrSurfaceProxyView_DEFINED
9#define GrSurfaceProxyView_DEFINED
10
12#include "include/core/SkSize.h"
14#include "include/gpu/GrTypes.h"
17#include "src/gpu/Swizzle.h"
19
20#include <string_view>
21#include <type_traits>
22#include <utility>
23
26class GrTextureProxy;
27enum class SkBackingFit;
28struct SkIRect;
29namespace skgpu {
30enum class Budgeted : bool;
31enum class Mipmapped : bool;
32}
33
35public:
36 GrSurfaceProxyView() = default;
37
40
41 // This entry point is used when we don't care about the origin or the swizzle.
44
47
48 explicit operator bool() const { return SkToBool(fProxy.get()); }
49
52
53 bool operator==(const GrSurfaceProxyView& view) const;
54 bool operator!=(const GrSurfaceProxyView& other) const { return !(*this == other); }
55
56 int width() const { return this->proxy()->width(); }
57 int height() const { return this->proxy()->height(); }
58 SkISize dimensions() const { return this->proxy()->dimensions(); }
59
61
62 GrSurfaceProxy* proxy() const { return fProxy.get(); }
63 sk_sp<GrSurfaceProxy> refProxy() const { return fProxy; }
64
67
70
71 GrSurfaceOrigin origin() const { return fOrigin; }
72 skgpu::Swizzle swizzle() const { return fSwizzle; }
73
75
77
79
80 void reset();
81
82 // Helper that copies a rect of a src view's proxy and then creates a view for the copy with
83 // the same origin and swizzle as the src view.
87 SkIRect srcRect,
88 SkBackingFit fit,
89 skgpu::Budgeted budgeted,
90 std::string_view label);
91
95 SkBackingFit fit,
96 skgpu::Budgeted budgeted,
97 std::string_view label);
98
99 // This does not reset the origin or swizzle, so the View can still be used to access those
100 // properties associated with the detached proxy.
101 sk_sp<GrSurfaceProxy> detachProxy() { return std::move(fProxy); }
102
103 using sk_is_trivially_relocatable = std::true_type;
104
105private:
108 skgpu::Swizzle fSwizzle;
109
110 static_assert(::sk_is_trivially_relocatable<decltype(fProxy)>::value);
111 static_assert(::sk_is_trivially_relocatable<decltype(fOrigin)>::value);
112 static_assert(::sk_is_trivially_relocatable<decltype(fSwizzle)>::value);
113};
114
115#endif
const TextureProxy * fProxy
Definition DrawPass.cpp:181
GrSurfaceOrigin
Definition GrTypes.h:147
@ kTopLeft_GrSurfaceOrigin
Definition GrTypes.h:148
SkBackingFit
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35
skgpu::Swizzle swizzle() const
std::true_type sk_is_trivially_relocatable
skgpu::Mipmapped mipmapped() const
void concatSwizzle(skgpu::Swizzle swizzle)
GrSurfaceProxyView(sk_sp< GrSurfaceProxy > proxy)
GrTextureProxy * asTextureProxy() const
sk_sp< GrSurfaceProxy > detachProxy()
SkISize dimensions() const
sk_sp< GrTextureProxy > asTextureProxyRef() const
GrSurfaceProxyView(const GrSurfaceProxyView &)=default
GrSurfaceProxyView(sk_sp< GrSurfaceProxy > proxy, GrSurfaceOrigin origin, skgpu::Swizzle swizzle)
GrSurfaceProxyView(GrSurfaceProxyView &&view)=default
GrSurfaceProxyView makeSwizzle(skgpu::Swizzle swizzle) const &
GrSurfaceOrigin origin() const
GrSurfaceProxy * proxy() const
GrRenderTargetProxy * asRenderTargetProxy() const
GrSurfaceProxyView & operator=(const GrSurfaceProxyView &)=default
sk_sp< GrSurfaceProxy > refProxy() const
static GrSurfaceProxyView Copy(GrRecordingContext *context, GrSurfaceProxyView src, skgpu::Mipmapped mipmapped, SkIRect srcRect, SkBackingFit fit, skgpu::Budgeted budgeted, std::string_view label)
sk_sp< GrRenderTargetProxy > asRenderTargetProxyRef() const
GrSurfaceProxyView()=default
bool operator==(const GrSurfaceProxyView &view) const
GrSurfaceProxyView & operator=(GrSurfaceProxyView &&view)=default
bool operator!=(const GrSurfaceProxyView &other) const
int width() const
SkISize dimensions() const
int height() const
T * get() const
Definition SkRefCnt.h:303
Budgeted
Definition GpuTypes.h:35
Mipmapped
Definition GpuTypes.h:53
Definition ref_ptr.h:256