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