blob: 282043a8797b95a7addb25f01243f8042f116ad3 [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 Phillips8def8bf2017-11-30 08:46:03 -050013#if SK_SUPPORT_GPU
Robert Phillips7ffbcf92017-12-04 12:52:46 -050014#include "GrTypesPriv.h"
Robert Phillips61e51012017-11-30 11:22:14 -050015#include "SkSurfaceProps.h"
Robert Phillipsad8a43f2017-08-30 12:06:35 -040016
Robert Phillips8def8bf2017-11-30 08:46:03 -050017class GrContextThreadSafeProxy;
Robert Phillips61e51012017-11-30 11:22:14 -050018class SkColorSpace;
Robert Phillips8def8bf2017-11-30 08:46:03 -050019
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 Phillips7ffbcf92017-12-04 12:52:46 -050025 GrContextThreadSafeProxy and SkColorSpace objects.
Robert Phillips8def8bf2017-11-30 08:46:03 -050026*/
Robert Phillipsad8a43f2017-08-30 12:06:35 -040027class SkSurfaceCharacterization {
28public:
29 SkSurfaceCharacterization()
Robert Phillips8d1e67e2017-12-04 13:48:14 -050030 : fCacheMaxResourceCount(0)
31 , fCacheMaxResourceBytes(0)
32 , fOrigin(kBottomLeft_GrSurfaceOrigin)
Robert Phillipsad8a43f2017-08-30 12:06:35 -040033 , fWidth(0)
34 , fHeight(0)
Robert Phillips61e51012017-11-30 11:22:14 -050035 , fConfig(kUnknown_GrPixelConfig)
Robert Phillips7ffbcf92017-12-04 12:52:46 -050036 , fFSAAType(GrFSAAType::kNone)
37 , fStencilCnt(0)
Robert Phillips61e51012017-11-30 11:22:14 -050038 , fSurfaceProps(0, kUnknown_SkPixelGeometry) {
Robert Phillipsad8a43f2017-08-30 12:06:35 -040039 }
40
Robert Phillips8def8bf2017-11-30 08:46:03 -050041 SkSurfaceCharacterization(SkSurfaceCharacterization&&) = default;
42 SkSurfaceCharacterization& operator=(SkSurfaceCharacterization&&) = default;
43
44 SkSurfaceCharacterization(const SkSurfaceCharacterization&) = default;
45 SkSurfaceCharacterization& operator=(const SkSurfaceCharacterization& other) = default;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040046
Robert Phillips61e51012017-11-30 11:22:14 -050047 GrContextThreadSafeProxy* contextInfo() const { return fContextInfo.get(); }
Robert Phillips8d1e67e2017-12-04 13:48:14 -050048 int cacheMaxResourceCount() const { return fCacheMaxResourceCount; }
49 size_t cacheMaxResourceBytes() const { return fCacheMaxResourceBytes; }
50
Robert Phillipsad8a43f2017-08-30 12:06:35 -040051 GrSurfaceOrigin origin() const { return fOrigin; }
52 int width() const { return fWidth; }
53 int height() const { return fHeight; }
54 GrPixelConfig config() const { return fConfig; }
Robert Phillips7ffbcf92017-12-04 12:52:46 -050055 GrFSAAType fsaaType() const { return fFSAAType; }
56 int stencilCount() const { return fStencilCnt; }
Robert Phillips61e51012017-11-30 11:22:14 -050057 SkColorSpace* colorSpace() const { return fColorSpace.get(); }
58 sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
59 const SkSurfaceProps& surfaceProps()const { return fSurfaceProps; }
Robert Phillipsad8a43f2017-08-30 12:06:35 -040060
61private:
Robert Phillips8def8bf2017-11-30 08:46:03 -050062 friend class SkSurface_Gpu; // for 'set'
63
Robert Phillips61e51012017-11-30 11:22:14 -050064 void set(sk_sp<GrContextThreadSafeProxy> contextInfo,
Robert Phillips8d1e67e2017-12-04 13:48:14 -050065 int cacheMaxResourceCount,
66 size_t cacheMaxResourceBytes,
Robert Phillips61e51012017-11-30 11:22:14 -050067 GrSurfaceOrigin origin,
Robert Phillips8def8bf2017-11-30 08:46:03 -050068 int width, int height,
69 GrPixelConfig config,
Robert Phillips7ffbcf92017-12-04 12:52:46 -050070 GrFSAAType fsaaType,
71 int stencilCnt,
Robert Phillips61e51012017-11-30 11:22:14 -050072 sk_sp<SkColorSpace> colorSpace,
73 const SkSurfaceProps& surfaceProps) {
74 fContextInfo = contextInfo;
Robert Phillips8d1e67e2017-12-04 13:48:14 -050075 fCacheMaxResourceCount = cacheMaxResourceCount;
76 fCacheMaxResourceBytes = cacheMaxResourceBytes;
77
Robert Phillips8def8bf2017-11-30 08:46:03 -050078 fOrigin = origin;
79 fWidth = width;
80 fHeight = height;
81 fConfig = config;
Robert Phillips7ffbcf92017-12-04 12:52:46 -050082 fFSAAType = fsaaType;
83 fStencilCnt = stencilCnt;
Robert Phillips61e51012017-11-30 11:22:14 -050084 fColorSpace = std::move(colorSpace);
85 fSurfaceProps = surfaceProps;
Robert Phillips8def8bf2017-11-30 08:46:03 -050086 }
87
Robert Phillips61e51012017-11-30 11:22:14 -050088 sk_sp<GrContextThreadSafeProxy> fContextInfo;
Robert Phillips8d1e67e2017-12-04 13:48:14 -050089 int fCacheMaxResourceCount;
90 size_t fCacheMaxResourceBytes;
91
Robert Phillips8def8bf2017-11-30 08:46:03 -050092 GrSurfaceOrigin fOrigin;
93 int fWidth;
94 int fHeight;
95 GrPixelConfig fConfig;
Robert Phillips7ffbcf92017-12-04 12:52:46 -050096 GrFSAAType fFSAAType;
97 int fStencilCnt;
Robert Phillips61e51012017-11-30 11:22:14 -050098 sk_sp<SkColorSpace> fColorSpace;
99 SkSurfaceProps fSurfaceProps;
Robert Phillipsad8a43f2017-08-30 12:06:35 -0400100};
101
Robert Phillips8def8bf2017-11-30 08:46:03 -0500102#else// !SK_SUPPORT_GPU
103
104class SkSurfaceCharacterization {
105public:
106 SkSurfaceCharacterization() : fWidth(0), fHeight(0) { }
107
108 int width() const { return fWidth; }
109 int height() const { return fHeight; }
110
111private:
112 int fWidth;
113 int fHeight;
114};
115
116#endif
117
Robert Phillipsad8a43f2017-08-30 12:06:35 -0400118#endif