Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 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 SkSurfaceCharacterization_DEFINED |
| 9 | #define SkSurfaceCharacterization_DEFINED |
| 10 | |
| 11 | #include "GrTypes.h" |
| 12 | |
Robert Phillips | 61e5101 | 2017-11-30 11:22:14 -0500 | [diff] [blame] | 13 | #include "SkSurfaceProps.h" |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 14 | |
Robert Phillips | 61e5101 | 2017-11-30 11:22:14 -0500 | [diff] [blame] | 15 | class SkColorSpace; |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 16 | |
Robert Phillips | e42edcc | 2017-12-13 11:50:22 -0500 | [diff] [blame] | 17 | #if SK_SUPPORT_GPU |
| 18 | #include "GrTypesPriv.h" |
| 19 | |
| 20 | class GrContextThreadSafeProxy; |
| 21 | |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 22 | /** \class SkSurfaceCharacterization |
| 23 | A surface characterization contains all the information Ganesh requires to makes its internal |
| 24 | rendering decisions. When passed into a SkDeferredDisplayListRecorder it will copy the |
| 25 | data and pass it on to the SkDeferredDisplayList if/when it is created. Note that both of |
| 26 | those objects (the Recorder and the DisplayList) will take a ref on the |
Robert Phillips | 7ffbcf9 | 2017-12-04 12:52:46 -0500 | [diff] [blame] | 27 | GrContextThreadSafeProxy and SkColorSpace objects. |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 28 | */ |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 29 | class SkSurfaceCharacterization { |
| 30 | public: |
| 31 | SkSurfaceCharacterization() |
Robert Phillips | 8d1e67e | 2017-12-04 13:48:14 -0500 | [diff] [blame] | 32 | : fCacheMaxResourceCount(0) |
| 33 | , fCacheMaxResourceBytes(0) |
| 34 | , fOrigin(kBottomLeft_GrSurfaceOrigin) |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 35 | , fWidth(0) |
| 36 | , fHeight(0) |
Robert Phillips | 61e5101 | 2017-11-30 11:22:14 -0500 | [diff] [blame] | 37 | , fConfig(kUnknown_GrPixelConfig) |
Robert Phillips | 7ffbcf9 | 2017-12-04 12:52:46 -0500 | [diff] [blame] | 38 | , fFSAAType(GrFSAAType::kNone) |
| 39 | , fStencilCnt(0) |
Robert Phillips | 61e5101 | 2017-11-30 11:22:14 -0500 | [diff] [blame] | 40 | , fSurfaceProps(0, kUnknown_SkPixelGeometry) { |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 41 | } |
| 42 | |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 43 | SkSurfaceCharacterization(SkSurfaceCharacterization&&) = default; |
| 44 | SkSurfaceCharacterization& operator=(SkSurfaceCharacterization&&) = default; |
| 45 | |
| 46 | SkSurfaceCharacterization(const SkSurfaceCharacterization&) = default; |
| 47 | SkSurfaceCharacterization& operator=(const SkSurfaceCharacterization& other) = default; |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 48 | |
Robert Phillips | 61e5101 | 2017-11-30 11:22:14 -0500 | [diff] [blame] | 49 | GrContextThreadSafeProxy* contextInfo() const { return fContextInfo.get(); } |
Robert Phillips | 8d1e67e | 2017-12-04 13:48:14 -0500 | [diff] [blame] | 50 | int cacheMaxResourceCount() const { return fCacheMaxResourceCount; } |
| 51 | size_t cacheMaxResourceBytes() const { return fCacheMaxResourceBytes; } |
| 52 | |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 53 | GrSurfaceOrigin origin() const { return fOrigin; } |
| 54 | int width() const { return fWidth; } |
| 55 | int height() const { return fHeight; } |
| 56 | GrPixelConfig config() const { return fConfig; } |
Robert Phillips | 7ffbcf9 | 2017-12-04 12:52:46 -0500 | [diff] [blame] | 57 | GrFSAAType fsaaType() const { return fFSAAType; } |
| 58 | int stencilCount() const { return fStencilCnt; } |
Robert Phillips | 61e5101 | 2017-11-30 11:22:14 -0500 | [diff] [blame] | 59 | SkColorSpace* colorSpace() const { return fColorSpace.get(); } |
| 60 | sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; } |
| 61 | const SkSurfaceProps& surfaceProps()const { return fSurfaceProps; } |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 62 | |
| 63 | private: |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 64 | friend class SkSurface_Gpu; // for 'set' |
| 65 | |
Robert Phillips | 61e5101 | 2017-11-30 11:22:14 -0500 | [diff] [blame] | 66 | void set(sk_sp<GrContextThreadSafeProxy> contextInfo, |
Robert Phillips | 8d1e67e | 2017-12-04 13:48:14 -0500 | [diff] [blame] | 67 | int cacheMaxResourceCount, |
| 68 | size_t cacheMaxResourceBytes, |
Robert Phillips | 61e5101 | 2017-11-30 11:22:14 -0500 | [diff] [blame] | 69 | GrSurfaceOrigin origin, |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 70 | int width, int height, |
| 71 | GrPixelConfig config, |
Robert Phillips | 7ffbcf9 | 2017-12-04 12:52:46 -0500 | [diff] [blame] | 72 | GrFSAAType fsaaType, |
| 73 | int stencilCnt, |
Robert Phillips | 61e5101 | 2017-11-30 11:22:14 -0500 | [diff] [blame] | 74 | sk_sp<SkColorSpace> colorSpace, |
| 75 | const SkSurfaceProps& surfaceProps) { |
| 76 | fContextInfo = contextInfo; |
Robert Phillips | 8d1e67e | 2017-12-04 13:48:14 -0500 | [diff] [blame] | 77 | fCacheMaxResourceCount = cacheMaxResourceCount; |
| 78 | fCacheMaxResourceBytes = cacheMaxResourceBytes; |
| 79 | |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 80 | fOrigin = origin; |
| 81 | fWidth = width; |
| 82 | fHeight = height; |
| 83 | fConfig = config; |
Robert Phillips | 7ffbcf9 | 2017-12-04 12:52:46 -0500 | [diff] [blame] | 84 | fFSAAType = fsaaType; |
| 85 | fStencilCnt = stencilCnt; |
Robert Phillips | 61e5101 | 2017-11-30 11:22:14 -0500 | [diff] [blame] | 86 | fColorSpace = std::move(colorSpace); |
| 87 | fSurfaceProps = surfaceProps; |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 88 | } |
| 89 | |
Robert Phillips | 61e5101 | 2017-11-30 11:22:14 -0500 | [diff] [blame] | 90 | sk_sp<GrContextThreadSafeProxy> fContextInfo; |
Robert Phillips | 8d1e67e | 2017-12-04 13:48:14 -0500 | [diff] [blame] | 91 | int fCacheMaxResourceCount; |
| 92 | size_t fCacheMaxResourceBytes; |
| 93 | |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 94 | GrSurfaceOrigin fOrigin; |
| 95 | int fWidth; |
| 96 | int fHeight; |
| 97 | GrPixelConfig fConfig; |
Robert Phillips | 7ffbcf9 | 2017-12-04 12:52:46 -0500 | [diff] [blame] | 98 | GrFSAAType fFSAAType; |
| 99 | int fStencilCnt; |
Robert Phillips | 61e5101 | 2017-11-30 11:22:14 -0500 | [diff] [blame] | 100 | sk_sp<SkColorSpace> fColorSpace; |
| 101 | SkSurfaceProps fSurfaceProps; |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 102 | }; |
| 103 | |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 104 | #else// !SK_SUPPORT_GPU |
| 105 | |
| 106 | class SkSurfaceCharacterization { |
| 107 | public: |
Robert Phillips | e42edcc | 2017-12-13 11:50:22 -0500 | [diff] [blame] | 108 | SkSurfaceCharacterization() |
| 109 | : fWidth(0) |
| 110 | , fHeight(0) |
| 111 | , fSurfaceProps(0, kUnknown_SkPixelGeometry) { |
| 112 | } |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 113 | |
| 114 | int width() const { return fWidth; } |
| 115 | int height() const { return fHeight; } |
Robert Phillips | e42edcc | 2017-12-13 11:50:22 -0500 | [diff] [blame] | 116 | SkColorSpace* colorSpace() const { return fColorSpace.get(); } |
| 117 | sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; } |
| 118 | const SkSurfaceProps& surfaceProps()const { return fSurfaceProps; } |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 119 | |
| 120 | private: |
| 121 | int fWidth; |
| 122 | int fHeight; |
Robert Phillips | e42edcc | 2017-12-13 11:50:22 -0500 | [diff] [blame] | 123 | sk_sp<SkColorSpace> fColorSpace; |
| 124 | SkSurfaceProps fSurfaceProps; |
Robert Phillips | 8def8bf | 2017-11-30 08:46:03 -0500 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | #endif |
| 128 | |
Robert Phillips | ad8a43f | 2017-08-30 12:06:35 -0400 | [diff] [blame] | 129 | #endif |