blob: 40be90c68515945b0dd184d86ab46b01f2b8dd8e [file] [log] [blame]
Robert Phillipsad8a43f2017-08-30 12:06:35 -04001/*
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 Phillips61e51012017-11-30 11:22:14 -050013#include "SkSurfaceProps.h"
Robert Phillipsad8a43f2017-08-30 12:06:35 -040014
Robert Phillips61e51012017-11-30 11:22:14 -050015class SkColorSpace;
Robert Phillips8def8bf2017-11-30 08:46:03 -050016
Robert Phillipse42edcc2017-12-13 11:50:22 -050017#if SK_SUPPORT_GPU
18#include "GrTypesPriv.h"
19
20class GrContextThreadSafeProxy;
21
Robert Phillips8def8bf2017-11-30 08:46:03 -050022/** \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 Phillips7ffbcf92017-12-04 12:52:46 -050027 GrContextThreadSafeProxy and SkColorSpace objects.
Robert Phillips8def8bf2017-11-30 08:46:03 -050028*/
Robert Phillipsad8a43f2017-08-30 12:06:35 -040029class SkSurfaceCharacterization {
30public:
31 SkSurfaceCharacterization()
Robert Phillips8d1e67e2017-12-04 13:48:14 -050032 : fCacheMaxResourceCount(0)
33 , fCacheMaxResourceBytes(0)
34 , fOrigin(kBottomLeft_GrSurfaceOrigin)
Robert Phillipsad8a43f2017-08-30 12:06:35 -040035 , fWidth(0)
36 , fHeight(0)
Robert Phillips61e51012017-11-30 11:22:14 -050037 , fConfig(kUnknown_GrPixelConfig)
Robert Phillips7ffbcf92017-12-04 12:52:46 -050038 , fFSAAType(GrFSAAType::kNone)
39 , fStencilCnt(0)
Robert Phillips61e51012017-11-30 11:22:14 -050040 , fSurfaceProps(0, kUnknown_SkPixelGeometry) {
Robert Phillipsad8a43f2017-08-30 12:06:35 -040041 }
42
Robert Phillips8def8bf2017-11-30 08:46:03 -050043 SkSurfaceCharacterization(SkSurfaceCharacterization&&) = default;
44 SkSurfaceCharacterization& operator=(SkSurfaceCharacterization&&) = default;
45
46 SkSurfaceCharacterization(const SkSurfaceCharacterization&) = default;
47 SkSurfaceCharacterization& operator=(const SkSurfaceCharacterization& other) = default;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040048
Robert Phillips61e51012017-11-30 11:22:14 -050049 GrContextThreadSafeProxy* contextInfo() const { return fContextInfo.get(); }
Robert Phillips8d1e67e2017-12-04 13:48:14 -050050 int cacheMaxResourceCount() const { return fCacheMaxResourceCount; }
51 size_t cacheMaxResourceBytes() const { return fCacheMaxResourceBytes; }
52
Robert Phillipsad8a43f2017-08-30 12:06:35 -040053 GrSurfaceOrigin origin() const { return fOrigin; }
54 int width() const { return fWidth; }
55 int height() const { return fHeight; }
56 GrPixelConfig config() const { return fConfig; }
Robert Phillips7ffbcf92017-12-04 12:52:46 -050057 GrFSAAType fsaaType() const { return fFSAAType; }
58 int stencilCount() const { return fStencilCnt; }
Robert Phillips61e51012017-11-30 11:22:14 -050059 SkColorSpace* colorSpace() const { return fColorSpace.get(); }
60 sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
61 const SkSurfaceProps& surfaceProps()const { return fSurfaceProps; }
Robert Phillipsad8a43f2017-08-30 12:06:35 -040062
63private:
Robert Phillips8def8bf2017-11-30 08:46:03 -050064 friend class SkSurface_Gpu; // for 'set'
65
Robert Phillips61e51012017-11-30 11:22:14 -050066 void set(sk_sp<GrContextThreadSafeProxy> contextInfo,
Robert Phillips8d1e67e2017-12-04 13:48:14 -050067 int cacheMaxResourceCount,
68 size_t cacheMaxResourceBytes,
Robert Phillips61e51012017-11-30 11:22:14 -050069 GrSurfaceOrigin origin,
Robert Phillips8def8bf2017-11-30 08:46:03 -050070 int width, int height,
71 GrPixelConfig config,
Robert Phillips7ffbcf92017-12-04 12:52:46 -050072 GrFSAAType fsaaType,
73 int stencilCnt,
Robert Phillips61e51012017-11-30 11:22:14 -050074 sk_sp<SkColorSpace> colorSpace,
75 const SkSurfaceProps& surfaceProps) {
76 fContextInfo = contextInfo;
Robert Phillips8d1e67e2017-12-04 13:48:14 -050077 fCacheMaxResourceCount = cacheMaxResourceCount;
78 fCacheMaxResourceBytes = cacheMaxResourceBytes;
79
Robert Phillips8def8bf2017-11-30 08:46:03 -050080 fOrigin = origin;
81 fWidth = width;
82 fHeight = height;
83 fConfig = config;
Robert Phillips7ffbcf92017-12-04 12:52:46 -050084 fFSAAType = fsaaType;
85 fStencilCnt = stencilCnt;
Robert Phillips61e51012017-11-30 11:22:14 -050086 fColorSpace = std::move(colorSpace);
87 fSurfaceProps = surfaceProps;
Robert Phillips8def8bf2017-11-30 08:46:03 -050088 }
89
Robert Phillips61e51012017-11-30 11:22:14 -050090 sk_sp<GrContextThreadSafeProxy> fContextInfo;
Robert Phillips8d1e67e2017-12-04 13:48:14 -050091 int fCacheMaxResourceCount;
92 size_t fCacheMaxResourceBytes;
93
Robert Phillips8def8bf2017-11-30 08:46:03 -050094 GrSurfaceOrigin fOrigin;
95 int fWidth;
96 int fHeight;
97 GrPixelConfig fConfig;
Robert Phillips7ffbcf92017-12-04 12:52:46 -050098 GrFSAAType fFSAAType;
99 int fStencilCnt;
Robert Phillips61e51012017-11-30 11:22:14 -0500100 sk_sp<SkColorSpace> fColorSpace;
101 SkSurfaceProps fSurfaceProps;
Robert Phillipsad8a43f2017-08-30 12:06:35 -0400102};
103
Robert Phillips8def8bf2017-11-30 08:46:03 -0500104#else// !SK_SUPPORT_GPU
105
106class SkSurfaceCharacterization {
107public:
Robert Phillipse42edcc2017-12-13 11:50:22 -0500108 SkSurfaceCharacterization()
109 : fWidth(0)
110 , fHeight(0)
111 , fSurfaceProps(0, kUnknown_SkPixelGeometry) {
112 }
Robert Phillips8def8bf2017-11-30 08:46:03 -0500113
114 int width() const { return fWidth; }
115 int height() const { return fHeight; }
Robert Phillipse42edcc2017-12-13 11:50:22 -0500116 SkColorSpace* colorSpace() const { return fColorSpace.get(); }
117 sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
118 const SkSurfaceProps& surfaceProps()const { return fSurfaceProps; }
Robert Phillips8def8bf2017-11-30 08:46:03 -0500119
120private:
121 int fWidth;
122 int fHeight;
Robert Phillipse42edcc2017-12-13 11:50:22 -0500123 sk_sp<SkColorSpace> fColorSpace;
124 SkSurfaceProps fSurfaceProps;
Robert Phillips8def8bf2017-11-30 08:46:03 -0500125};
126
127#endif
128
Robert Phillipsad8a43f2017-08-30 12:06:35 -0400129#endif