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