Greg Daniel | a83de58 | 2019-10-22 09:33:25 -0400 | [diff] [blame] | 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 | |
| 11 | #include "include/core/SkRefCnt.h" |
| 12 | #include "include/gpu/GrTypes.h" |
| 13 | #include "src/gpu/GrSurfaceProxy.h" |
| 14 | #include "src/gpu/GrSwizzle.h" |
| 15 | |
| 16 | class GrSurfaceProxyView { |
| 17 | public: |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 18 | GrSurfaceProxyView() = default; |
| 19 | |
Greg Daniel | a83de58 | 2019-10-22 09:33:25 -0400 | [diff] [blame] | 20 | GrSurfaceProxyView(sk_sp<GrSurfaceProxy> proxy, GrSurfaceOrigin origin, GrSwizzle swizzle) |
| 21 | : fProxy(proxy), fOrigin(origin), fSwizzle(swizzle) {} |
| 22 | |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 23 | // This entry point is used when we don't care about the origin or the swizzle. |
| 24 | GrSurfaceProxyView(sk_sp<GrSurfaceProxy> proxy) |
| 25 | : fProxy(proxy), fOrigin(kTopLeft_GrSurfaceOrigin) {} |
Greg Daniel | a83de58 | 2019-10-22 09:33:25 -0400 | [diff] [blame] | 26 | |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 27 | GrSurfaceProxyView(GrSurfaceProxyView&& view) = default; |
Greg Daniel | 549325c | 2019-10-30 16:19:20 -0400 | [diff] [blame^] | 28 | GrSurfaceProxyView(const GrSurfaceProxyView&) = default; |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 29 | |
Greg Daniel | 549325c | 2019-10-30 16:19:20 -0400 | [diff] [blame^] | 30 | GrSurfaceProxyView& operator=(const GrSurfaceProxyView&) = default; |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 31 | |
Greg Daniel | 549325c | 2019-10-30 16:19:20 -0400 | [diff] [blame^] | 32 | bool operator==(const GrSurfaceProxyView& view) const { |
| 33 | return fProxy->uniqueID() == view.fProxy->uniqueID() && |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 34 | fOrigin == view.fOrigin && |
| 35 | fSwizzle == view.fSwizzle; |
| 36 | } |
Greg Daniel | 549325c | 2019-10-30 16:19:20 -0400 | [diff] [blame^] | 37 | bool operator!=(const GrSurfaceProxyView& other) const { return !(*this == other); } |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 38 | |
| 39 | GrSurfaceProxy* proxy() const { return fProxy.get(); } |
Greg Daniel | a83de58 | 2019-10-22 09:33:25 -0400 | [diff] [blame] | 40 | GrTextureProxy* asTextureProxy() const { return fProxy->asTextureProxy(); } |
| 41 | GrRenderTargetProxy* asRenderTargetProxy() const { return fProxy->asRenderTargetProxy(); } |
| 42 | |
| 43 | GrSurfaceOrigin origin() const { return fOrigin; } |
| 44 | const GrSwizzle& swizzle() const { return fSwizzle; } |
| 45 | |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 46 | void reset() { |
| 47 | *this = {}; |
| 48 | } |
| 49 | |
Greg Daniel | a83de58 | 2019-10-22 09:33:25 -0400 | [diff] [blame] | 50 | private: |
| 51 | sk_sp<GrSurfaceProxy> fProxy; |
Greg Daniel | 16f5c65 | 2019-10-29 11:26:01 -0400 | [diff] [blame] | 52 | GrSurfaceOrigin fOrigin = kTopLeft_GrSurfaceOrigin; |
Greg Daniel | a83de58 | 2019-10-22 09:33:25 -0400 | [diff] [blame] | 53 | GrSwizzle fSwizzle; |
| 54 | }; |
| 55 | |
| 56 | #endif |
| 57 | |