blob: f450b704d91f97e6b302875724519d496b72403a [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()
30 : fOrigin(kBottomLeft_GrSurfaceOrigin)
31 , fWidth(0)
32 , fHeight(0)
Robert Phillips61e51012017-11-30 11:22:14 -050033 , fConfig(kUnknown_GrPixelConfig)
Robert Phillips7ffbcf92017-12-04 12:52:46 -050034 , fFSAAType(GrFSAAType::kNone)
35 , fStencilCnt(0)
Robert Phillips61e51012017-11-30 11:22:14 -050036 , fSurfaceProps(0, kUnknown_SkPixelGeometry) {
Robert Phillipsad8a43f2017-08-30 12:06:35 -040037 }
38
Robert Phillips8def8bf2017-11-30 08:46:03 -050039 SkSurfaceCharacterization(SkSurfaceCharacterization&&) = default;
40 SkSurfaceCharacterization& operator=(SkSurfaceCharacterization&&) = default;
41
42 SkSurfaceCharacterization(const SkSurfaceCharacterization&) = default;
43 SkSurfaceCharacterization& operator=(const SkSurfaceCharacterization& other) = default;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040044
Robert Phillips61e51012017-11-30 11:22:14 -050045 GrContextThreadSafeProxy* contextInfo() const { return fContextInfo.get(); }
Robert Phillipsad8a43f2017-08-30 12:06:35 -040046 GrSurfaceOrigin origin() const { return fOrigin; }
47 int width() const { return fWidth; }
48 int height() const { return fHeight; }
49 GrPixelConfig config() const { return fConfig; }
Robert Phillips7ffbcf92017-12-04 12:52:46 -050050 GrFSAAType fsaaType() const { return fFSAAType; }
51 int stencilCount() const { return fStencilCnt; }
Robert Phillips61e51012017-11-30 11:22:14 -050052 SkColorSpace* colorSpace() const { return fColorSpace.get(); }
53 sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
54 const SkSurfaceProps& surfaceProps()const { return fSurfaceProps; }
Robert Phillipsad8a43f2017-08-30 12:06:35 -040055
56private:
Robert Phillips8def8bf2017-11-30 08:46:03 -050057 friend class SkSurface_Gpu; // for 'set'
58
Robert Phillips61e51012017-11-30 11:22:14 -050059 void set(sk_sp<GrContextThreadSafeProxy> contextInfo,
60 GrSurfaceOrigin origin,
Robert Phillips8def8bf2017-11-30 08:46:03 -050061 int width, int height,
62 GrPixelConfig config,
Robert Phillips7ffbcf92017-12-04 12:52:46 -050063 GrFSAAType fsaaType,
64 int stencilCnt,
Robert Phillips61e51012017-11-30 11:22:14 -050065 sk_sp<SkColorSpace> colorSpace,
66 const SkSurfaceProps& surfaceProps) {
67 fContextInfo = contextInfo;
Robert Phillips8def8bf2017-11-30 08:46:03 -050068 fOrigin = origin;
69 fWidth = width;
70 fHeight = height;
71 fConfig = config;
Robert Phillips7ffbcf92017-12-04 12:52:46 -050072 fFSAAType = fsaaType;
73 fStencilCnt = stencilCnt;
Robert Phillips61e51012017-11-30 11:22:14 -050074 fColorSpace = std::move(colorSpace);
75 fSurfaceProps = surfaceProps;
Robert Phillips8def8bf2017-11-30 08:46:03 -050076 }
77
Robert Phillips61e51012017-11-30 11:22:14 -050078 sk_sp<GrContextThreadSafeProxy> fContextInfo;
Robert Phillips8def8bf2017-11-30 08:46:03 -050079 GrSurfaceOrigin fOrigin;
80 int fWidth;
81 int fHeight;
82 GrPixelConfig fConfig;
Robert Phillips7ffbcf92017-12-04 12:52:46 -050083 GrFSAAType fFSAAType;
84 int fStencilCnt;
Robert Phillips61e51012017-11-30 11:22:14 -050085 sk_sp<SkColorSpace> fColorSpace;
86 SkSurfaceProps fSurfaceProps;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040087};
88
Robert Phillips8def8bf2017-11-30 08:46:03 -050089#else// !SK_SUPPORT_GPU
90
91class SkSurfaceCharacterization {
92public:
93 SkSurfaceCharacterization() : fWidth(0), fHeight(0) { }
94
95 int width() const { return fWidth; }
96 int height() const { return fHeight; }
97
98private:
99 int fWidth;
100 int fHeight;
101};
102
103#endif
104
Robert Phillipsad8a43f2017-08-30 12:06:35 -0400105#endif