Debian Codegraph @

src/gpu/ganesh/GrDstProxyView.h

raw
1 /*
2 * Copyright 2021 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 GrDstProxyView_DEFINED
9 #define GrDstProxyView_DEFINED
10
11 #include "include/core/SkPoint.h"
12 #include "include/private/base/SkTypeTraits.h"
13 #include "include/private/gpu/ganesh/GrTypesPriv.h"
14 #include "src/gpu/ganesh/GrSurfaceProxyView.h"
15
16 #include <type_traits>
17 #include <utility>
18
19 class GrSurfaceProxy;
20
21 /**
22 * GrDstProxyView holds a texture containing the destination pixel values, and an integer-coordinate
23 * offset from device-space to the space of the texture. When framebuffer fetch is not available, a
24 * GrDstProxyView may be used to support blending in the fragment shader/xfer processor.
25 */
26 class GrDstProxyView {
27 public:
28 GrDstProxyView() {}
29
30 GrDstProxyView(const GrDstProxyView& other) {
31 *this = other;
32 }
33
34 GrDstProxyView& operator=(const GrDstProxyView& other) {
35 fProxyView = other.fProxyView;
36 fOffset = other.fOffset;
37 fDstSampleFlags = other.fDstSampleFlags;
38 return *this;
39 }
40
41 bool operator==(const GrDstProxyView& that) const {
42 return fProxyView == that.fProxyView &&
43 fOffset == that.fOffset &&
44 fDstSampleFlags == that.fDstSampleFlags;
45 }
46 bool operator!=(const GrDstProxyView& that) const { return !(*this == that); }
47
48 const SkIPoint& offset() const { return fOffset; }
49
50 void setOffset(const SkIPoint& offset) { fOffset = offset; }
51 void setOffset(int ox, int oy) { fOffset.set(ox, oy); }
52
53 GrSurfaceProxy* proxy() const { return fProxyView.proxy(); }
54 const GrSurfaceProxyView& proxyView() const { return fProxyView; }
55
56 void setProxyView(GrSurfaceProxyView view) {
57 fProxyView = std::move(view);
58 if (!fProxyView.proxy()) {
59 fOffset = {0, 0};
60 }
61 }
62
63 GrDstSampleFlags dstSampleFlags() const { return fDstSampleFlags; }
64
65 void setDstSampleFlags(GrDstSampleFlags dstSampleFlags) { fDstSampleFlags = dstSampleFlags; }
66
67 using sk_is_trivially_relocatable = std::true_type;
68
69 private:
70 GrSurfaceProxyView fProxyView;
71 SkIPoint fOffset = {0, 0};
72 GrDstSampleFlags fDstSampleFlags = GrDstSampleFlags::kNone;
73
74 static_assert(::sk_is_trivially_relocatable<decltype(fProxyView)>::value);
75 static_assert(::sk_is_trivially_relocatable<decltype(fOffset)>::value);
76 static_assert(::sk_is_trivially_relocatable<decltype(fDstSampleFlags)>::value);
77 };
78
79 #endif