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