blob: 9f0faf33f4170f28fb792ce173f9212e03be8a2c [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 Phillipsad8a43f2017-08-30 12:06:35 -040014
Robert Phillips8def8bf2017-11-30 08:46:03 -050015class 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 Phillipsad8a43f2017-08-30 12:06:35 -040024class SkSurfaceCharacterization {
25public:
26 SkSurfaceCharacterization()
27 : fOrigin(kBottomLeft_GrSurfaceOrigin)
28 , fWidth(0)
29 , fHeight(0)
30 , fConfig(kRGBA_8888_GrPixelConfig)
31 , fSampleCnt(0) {
32 }
33
Robert Phillips8def8bf2017-11-30 08:46:03 -050034 SkSurfaceCharacterization(SkSurfaceCharacterization&&) = default;
35 SkSurfaceCharacterization& operator=(SkSurfaceCharacterization&&) = default;
36
37 SkSurfaceCharacterization(const SkSurfaceCharacterization&) = default;
38 SkSurfaceCharacterization& operator=(const SkSurfaceCharacterization& other) = default;
Robert Phillipsad8a43f2017-08-30 12:06:35 -040039
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 Phillips8def8bf2017-11-30 08:46:03 -050045 GrContextThreadSafeProxy* contextInfo() const { return fContextInfo.get(); }
Robert Phillipsad8a43f2017-08-30 12:06:35 -040046
47private:
Robert Phillips8def8bf2017-11-30 08:46:03 -050048 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 Phillipsad8a43f2017-08-30 12:06:35 -040069};
70
Robert Phillips8def8bf2017-11-30 08:46:03 -050071#else// !SK_SUPPORT_GPU
72
73class SkSurfaceCharacterization {
74public:
75 SkSurfaceCharacterization() : fWidth(0), fHeight(0) { }
76
77 int width() const { return fWidth; }
78 int height() const { return fHeight; }
79
80private:
81 int fWidth;
82 int fHeight;
83};
84
85#endif
86
Robert Phillipsad8a43f2017-08-30 12:06:35 -040087#endif