Add maxSurfaceSampleCountForColorType to GrContextThreadSafeProxy

Change-Id: I7d98b2dff9fbb29bb9709c72679551473078fe0f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/513877
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2022-03-01 09:38:59 -05:00 committed by SkCQ
parent 9867574f71
commit d6d3cabb49
7 changed files with 34 additions and 10 deletions

View File

@ -2,6 +2,11 @@ Skia Graphics Release Notes
This file includes a list of high level updates for each milestone release.
Milestone 101
-------------
* Add maxSurfaceSampleCountForColorType(SkColorType ct) in GrContextThreadSafeProxy
Milestone 100
-------------
* Skia now requires C++17 and the corresponding standard library (or newer).

View File

@ -114,6 +114,13 @@ public:
*/
GrBackendFormat compressedBackendFormat(SkImage::CompressionType c) const;
/**
* Gets the maximum supported sample count for a color type. 1 is returned if only non-MSAA
* rendering is supported for the color type. 0 is returned if rendering to this color type
* is not supported at all.
*/
int maxSurfaceSampleCountForColorType(SkColorType colorType) const;
bool isValid() const { return nullptr != fCaps; }
bool operator==(const GrContextThreadSafeProxy& that) const {

View File

@ -90,7 +90,9 @@ public:
* rendering is supported for the color type. 0 is returned if rendering to this color type
* is not supported at all.
*/
SK_API int maxSurfaceSampleCountForColorType(SkColorType) const;
SK_API int maxSurfaceSampleCountForColorType(SkColorType colorType) const {
return INHERITED::maxSurfaceSampleCountForColorType(colorType);
}
// Provides access to functions that aren't part of the public API.
GrRecordingContextPriv priv();

View File

@ -45,6 +45,13 @@ public:
SK_API GrBackendFormat compressedBackendFormat(SkImage::CompressionType) const;
/**
* Gets the maximum supported sample count for a color type. 1 is returned if only non-MSAA
* rendering is supported for the color type. 0 is returned if rendering to this color type
* is not supported at all.
*/
SK_API int maxSurfaceSampleCountForColorType(SkColorType colorType) const;
// TODO: When the public version is gone, rename to refThreadSafeProxy and add raw ptr ver.
sk_sp<GrContextThreadSafeProxy> threadSafeProxy();

View File

@ -162,6 +162,14 @@ GrBackendFormat GrContextThreadSafeProxy::compressedBackendFormat(SkImage::Compr
return format;
}
int GrContextThreadSafeProxy::maxSurfaceSampleCountForColorType(SkColorType colorType) const {
SkASSERT(fCaps);
GrBackendFormat format = fCaps->getDefaultBackendFormat(SkColorTypeToGrColorType(colorType),
GrRenderable::kYes);
return fCaps->maxRenderTargetSampleCount(format);
}
void GrContextThreadSafeProxy::abandonContext() {
if (!fAbandoned.exchange(true)) {
fTextBlobRedrawCoordinator->freeAll();
@ -183,4 +191,3 @@ void GrContextThreadSafeProxyPriv::init(sk_sp<const GrCaps> caps,
sk_sp<GrThreadSafePipelineBuilder> builder) const {
fProxy->init(std::move(caps), std::move(builder));
}

View File

@ -44,6 +44,10 @@ GrBackendFormat GrContext_Base::compressedBackendFormat(SkImage::CompressionType
return fThreadSafeProxy->compressedBackendFormat(c);
}
int GrContext_Base::maxSurfaceSampleCountForColorType(SkColorType colorType) const {
return fThreadSafeProxy->maxSurfaceSampleCountForColorType(colorType);
}
sk_sp<GrContextThreadSafeProxy> GrContext_Base::threadSafeProxy() { return fThreadSafeProxy; }
///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -53,13 +53,6 @@ GrRecordingContext::~GrRecordingContext() {
#endif
}
int GrRecordingContext::maxSurfaceSampleCountForColorType(SkColorType colorType) const {
GrBackendFormat format =
this->caps()->getDefaultBackendFormat(SkColorTypeToGrColorType(colorType),
GrRenderable::kYes);
return this->caps()->maxRenderTargetSampleCount(format);
}
bool GrRecordingContext::init() {
if (!INHERITED::init()) {
return false;
@ -249,4 +242,3 @@ void GrRecordingContext::DMSAAStats::merge(const DMSAAStats& stats) {
#endif // GR_GPU_STATS
#endif // GR_TEST_UTILS