blob: 8b20cacb364954adef5dd84a5deafe7417fc476e [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 Phillips61e51012017-11-30 11:22:14 -050014#include "SkSurfaceProps.h"
Robert Phillipsad8a43f2017-08-30 12:06:35 -040015
Robert Phillips8def8bf2017-11-30 08:46:03 -050016class GrContextThreadSafeProxy;
Robert Phillips61e51012017-11-30 11:22:14 -050017class SkColorSpace;
Robert Phillips8def8bf2017-11-30 08:46:03 -050018
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 Phillipsad8a43f2017-08-30 12:06:35 -040026class SkSurfaceCharacterization {
27public:
28 SkSurfaceCharacterization()
29 : fOrigin(kBottomLeft_GrSurfaceOrigin)
30 , fWidth(0)
31 , fHeight(0)
Robert Phillips61e51012017-11-30 11:22:14 -050032 , fConfig(kUnknown_GrPixelConfig)
33 , fSampleCnt(0)
34 , fSurfaceProps(0, kUnknown_SkPixelGeometry) {
Robert Phillipsad8a43f2017-08-30 12:06:35 -040035 }
36
Robert Phillips8def8bf2017-11-30 08:46:03 -050037 SkSurfaceCharacterization(SkSurfaceCharacterization&&) = default;
38 SkSurfaceCharacterization& operator=(SkSurfaceCharacterization&&) = default;
39
40 SkSurfaceCharacterization(const SkSurfaceCharacterization&) = default;
41 SkSurfaceCharacterization& operator=(const SkSurfaceCharacterization& other) = default;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040042
Robert Phillips61e51012017-11-30 11:22:14 -050043 GrContextThreadSafeProxy* contextInfo() const { return fContextInfo.get(); }
Robert Phillipsad8a43f2017-08-30 12:06:35 -040044 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 Phillips61e51012017-11-30 11:22:14 -050049 SkColorSpace* colorSpace() const { return fColorSpace.get(); }
50 sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
51 const SkSurfaceProps& surfaceProps()const { return fSurfaceProps; }
Robert Phillipsad8a43f2017-08-30 12:06:35 -040052
53private:
Robert Phillips8def8bf2017-11-30 08:46:03 -050054 friend class SkSurface_Gpu; // for 'set'
55
Robert Phillips61e51012017-11-30 11:22:14 -050056 void set(sk_sp<GrContextThreadSafeProxy> contextInfo,
57 GrSurfaceOrigin origin,
Robert Phillips8def8bf2017-11-30 08:46:03 -050058 int width, int height,
59 GrPixelConfig config,
60 int sampleCnt,
Robert Phillips61e51012017-11-30 11:22:14 -050061 sk_sp<SkColorSpace> colorSpace,
62 const SkSurfaceProps& surfaceProps) {
63 fContextInfo = contextInfo;
Robert Phillips8def8bf2017-11-30 08:46:03 -050064 fOrigin = origin;
65 fWidth = width;
66 fHeight = height;
67 fConfig = config;
68 fSampleCnt = sampleCnt;
Robert Phillips61e51012017-11-30 11:22:14 -050069 fColorSpace = std::move(colorSpace);
70 fSurfaceProps = surfaceProps;
Robert Phillips8def8bf2017-11-30 08:46:03 -050071 }
72
Robert Phillips61e51012017-11-30 11:22:14 -050073 sk_sp<GrContextThreadSafeProxy> fContextInfo;
Robert Phillips8def8bf2017-11-30 08:46:03 -050074 GrSurfaceOrigin fOrigin;
75 int fWidth;
76 int fHeight;
77 GrPixelConfig fConfig;
78 int fSampleCnt;
Robert Phillips61e51012017-11-30 11:22:14 -050079 sk_sp<SkColorSpace> fColorSpace;
80 SkSurfaceProps fSurfaceProps;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040081};
82
Robert Phillips8def8bf2017-11-30 08:46:03 -050083#else// !SK_SUPPORT_GPU
84
85class SkSurfaceCharacterization {
86public:
87 SkSurfaceCharacterization() : fWidth(0), fHeight(0) { }
88
89 int width() const { return fWidth; }
90 int height() const { return fHeight; }
91
92private:
93 int fWidth;
94 int fHeight;
95};
96
97#endif
98
Robert Phillipsad8a43f2017-08-30 12:06:35 -040099#endif