2017-08-30 16:06:35 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkSurfaceCharacterization_DEFINED
|
|
|
|
#define SkSurfaceCharacterization_DEFINED
|
|
|
|
|
|
|
|
#include "GrTypes.h"
|
|
|
|
|
2017-11-30 13:46:03 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2017-12-04 17:52:46 +00:00
|
|
|
#include "GrTypesPriv.h"
|
2017-11-30 16:22:14 +00:00
|
|
|
#include "SkSurfaceProps.h"
|
2017-08-30 16:06:35 +00:00
|
|
|
|
2017-11-30 13:46:03 +00:00
|
|
|
class GrContextThreadSafeProxy;
|
2017-11-30 16:22:14 +00:00
|
|
|
class SkColorSpace;
|
2017-11-30 13:46:03 +00:00
|
|
|
|
|
|
|
/** \class SkSurfaceCharacterization
|
|
|
|
A surface characterization contains all the information Ganesh requires to makes its internal
|
|
|
|
rendering decisions. When passed into a SkDeferredDisplayListRecorder it will copy the
|
|
|
|
data and pass it on to the SkDeferredDisplayList if/when it is created. Note that both of
|
|
|
|
those objects (the Recorder and the DisplayList) will take a ref on the
|
2017-12-04 17:52:46 +00:00
|
|
|
GrContextThreadSafeProxy and SkColorSpace objects.
|
2017-11-30 13:46:03 +00:00
|
|
|
*/
|
2017-08-30 16:06:35 +00:00
|
|
|
class SkSurfaceCharacterization {
|
|
|
|
public:
|
|
|
|
SkSurfaceCharacterization()
|
2017-12-04 18:48:14 +00:00
|
|
|
: fCacheMaxResourceCount(0)
|
|
|
|
, fCacheMaxResourceBytes(0)
|
|
|
|
, fOrigin(kBottomLeft_GrSurfaceOrigin)
|
2017-08-30 16:06:35 +00:00
|
|
|
, fWidth(0)
|
|
|
|
, fHeight(0)
|
2017-11-30 16:22:14 +00:00
|
|
|
, fConfig(kUnknown_GrPixelConfig)
|
2017-12-04 17:52:46 +00:00
|
|
|
, fFSAAType(GrFSAAType::kNone)
|
|
|
|
, fStencilCnt(0)
|
2017-11-30 16:22:14 +00:00
|
|
|
, fSurfaceProps(0, kUnknown_SkPixelGeometry) {
|
2017-08-30 16:06:35 +00:00
|
|
|
}
|
|
|
|
|
2017-11-30 13:46:03 +00:00
|
|
|
SkSurfaceCharacterization(SkSurfaceCharacterization&&) = default;
|
|
|
|
SkSurfaceCharacterization& operator=(SkSurfaceCharacterization&&) = default;
|
|
|
|
|
|
|
|
SkSurfaceCharacterization(const SkSurfaceCharacterization&) = default;
|
|
|
|
SkSurfaceCharacterization& operator=(const SkSurfaceCharacterization& other) = default;
|
|
|
|
|
2017-11-30 16:22:14 +00:00
|
|
|
GrContextThreadSafeProxy* contextInfo() const { return fContextInfo.get(); }
|
2017-12-04 18:48:14 +00:00
|
|
|
int cacheMaxResourceCount() const { return fCacheMaxResourceCount; }
|
|
|
|
size_t cacheMaxResourceBytes() const { return fCacheMaxResourceBytes; }
|
|
|
|
|
2017-11-30 13:46:03 +00:00
|
|
|
GrSurfaceOrigin origin() const { return fOrigin; }
|
|
|
|
int width() const { return fWidth; }
|
|
|
|
int height() const { return fHeight; }
|
|
|
|
GrPixelConfig config() const { return fConfig; }
|
2017-12-04 17:52:46 +00:00
|
|
|
GrFSAAType fsaaType() const { return fFSAAType; }
|
|
|
|
int stencilCount() const { return fStencilCnt; }
|
2017-11-30 16:22:14 +00:00
|
|
|
SkColorSpace* colorSpace() const { return fColorSpace.get(); }
|
|
|
|
sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
|
|
|
|
const SkSurfaceProps& surfaceProps()const { return fSurfaceProps; }
|
2017-11-30 13:46:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SkSurface_Gpu; // for 'set'
|
|
|
|
|
2017-11-30 16:22:14 +00:00
|
|
|
void set(sk_sp<GrContextThreadSafeProxy> contextInfo,
|
2017-12-04 18:48:14 +00:00
|
|
|
int cacheMaxResourceCount,
|
|
|
|
size_t cacheMaxResourceBytes,
|
2017-11-30 16:22:14 +00:00
|
|
|
GrSurfaceOrigin origin,
|
2017-08-30 16:06:35 +00:00
|
|
|
int width, int height,
|
|
|
|
GrPixelConfig config,
|
2017-12-04 17:52:46 +00:00
|
|
|
GrFSAAType fsaaType,
|
|
|
|
int stencilCnt,
|
2017-11-30 16:22:14 +00:00
|
|
|
sk_sp<SkColorSpace> colorSpace,
|
|
|
|
const SkSurfaceProps& surfaceProps) {
|
|
|
|
fContextInfo = contextInfo;
|
2017-12-04 18:48:14 +00:00
|
|
|
fCacheMaxResourceCount = cacheMaxResourceCount;
|
|
|
|
fCacheMaxResourceBytes = cacheMaxResourceBytes;
|
|
|
|
|
2017-08-30 16:06:35 +00:00
|
|
|
fOrigin = origin;
|
|
|
|
fWidth = width;
|
|
|
|
fHeight = height;
|
|
|
|
fConfig = config;
|
2017-12-04 17:52:46 +00:00
|
|
|
fFSAAType = fsaaType;
|
|
|
|
fStencilCnt = stencilCnt;
|
2017-11-30 16:22:14 +00:00
|
|
|
fColorSpace = std::move(colorSpace);
|
|
|
|
fSurfaceProps = surfaceProps;
|
2017-08-30 16:06:35 +00:00
|
|
|
}
|
|
|
|
|
2017-11-30 16:22:14 +00:00
|
|
|
sk_sp<GrContextThreadSafeProxy> fContextInfo;
|
2017-12-04 18:48:14 +00:00
|
|
|
int fCacheMaxResourceCount;
|
|
|
|
size_t fCacheMaxResourceBytes;
|
|
|
|
|
2017-11-30 13:46:03 +00:00
|
|
|
GrSurfaceOrigin fOrigin;
|
|
|
|
int fWidth;
|
|
|
|
int fHeight;
|
|
|
|
GrPixelConfig fConfig;
|
2017-12-04 17:52:46 +00:00
|
|
|
GrFSAAType fFSAAType;
|
|
|
|
int fStencilCnt;
|
2017-11-30 16:22:14 +00:00
|
|
|
sk_sp<SkColorSpace> fColorSpace;
|
|
|
|
SkSurfaceProps fSurfaceProps;
|
2017-11-30 13:46:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#else// !SK_SUPPORT_GPU
|
|
|
|
|
|
|
|
class SkSurfaceCharacterization {
|
|
|
|
public:
|
|
|
|
SkSurfaceCharacterization() : fWidth(0), fHeight(0) { }
|
|
|
|
|
2017-08-30 16:06:35 +00:00
|
|
|
int width() const { return fWidth; }
|
|
|
|
int height() const { return fHeight; }
|
|
|
|
|
|
|
|
private:
|
2017-11-30 13:46:03 +00:00
|
|
|
int fWidth;
|
|
|
|
int fHeight;
|
2017-08-30 16:06:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2017-11-30 13:46:03 +00:00
|
|
|
|
|
|
|
#endif
|