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