From 61e51012ee150e12f953bc4225fbdbdc1564007d Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Thu, 30 Nov 2017 11:22:14 -0500 Subject: [PATCH] Flesh out SkSurfaceCharacterization This should be it for now except for maybe a GrMipMapped field. Change-Id: I8f20a1048eaa8cd2b5eab5f42ca58c61649f72e7 Reviewed-on: https://skia-review.googlesource.com/78440 Reviewed-by: Brian Salomon Commit-Queue: Robert Phillips --- include/core/SkSurfaceProps.h | 4 ++++ include/private/SkDeferredDisplayList.h | 2 +- include/private/SkSurfaceCharacterization.h | 26 +++++++++++++++------ src/image/SkSurface_Gpu.cpp | 11 +++++---- 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/include/core/SkSurfaceProps.h b/include/core/SkSurfaceProps.h index da04d1fe92..66617995e4 100644 --- a/include/core/SkSurfaceProps.h +++ b/include/core/SkSurfaceProps.h @@ -72,6 +72,10 @@ public: return SkToBool(fFlags & kUseDeviceIndependentFonts_Flag); } + bool operator==(const SkSurfaceProps& that) const { + return fFlags == that.fFlags && fPixelGeometry == that.fPixelGeometry; + } + private: SkSurfaceProps(); diff --git a/include/private/SkDeferredDisplayList.h b/include/private/SkDeferredDisplayList.h index 30c2518bdc..c6e67f4dcc 100644 --- a/include/private/SkDeferredDisplayList.h +++ b/include/private/SkDeferredDisplayList.h @@ -35,7 +35,7 @@ public: void draw(SkSurface*); private: - SkSurfaceCharacterization fCharacterization; + const SkSurfaceCharacterization fCharacterization; // TODO: actually store the GPU opLists sk_sp fImage; diff --git a/include/private/SkSurfaceCharacterization.h b/include/private/SkSurfaceCharacterization.h index 9f0faf33f4..8b20cacb36 100644 --- a/include/private/SkSurfaceCharacterization.h +++ b/include/private/SkSurfaceCharacterization.h @@ -11,8 +11,10 @@ #include "GrTypes.h" #if SK_SUPPORT_GPU +#include "SkSurfaceProps.h" class GrContextThreadSafeProxy; +class SkColorSpace; /** \class SkSurfaceCharacterization A surface characterization contains all the information Ganesh requires to makes its internal @@ -27,8 +29,9 @@ public: : fOrigin(kBottomLeft_GrSurfaceOrigin) , fWidth(0) , fHeight(0) - , fConfig(kRGBA_8888_GrPixelConfig) - , fSampleCnt(0) { + , fConfig(kUnknown_GrPixelConfig) + , fSampleCnt(0) + , fSurfaceProps(0, kUnknown_SkPixelGeometry) { } SkSurfaceCharacterization(SkSurfaceCharacterization&&) = default; @@ -37,35 +40,44 @@ public: SkSurfaceCharacterization(const SkSurfaceCharacterization&) = default; SkSurfaceCharacterization& operator=(const SkSurfaceCharacterization& other) = default; + GrContextThreadSafeProxy* contextInfo() const { return fContextInfo.get(); } GrSurfaceOrigin origin() const { return fOrigin; } int width() const { return fWidth; } int height() const { return fHeight; } GrPixelConfig config() const { return fConfig; } int sampleCount() const { return fSampleCnt; } - GrContextThreadSafeProxy* contextInfo() const { return fContextInfo.get(); } + SkColorSpace* colorSpace() const { return fColorSpace.get(); } + sk_sp refColorSpace() const { return fColorSpace; } + const SkSurfaceProps& surfaceProps()const { return fSurfaceProps; } private: friend class SkSurface_Gpu; // for 'set' - void set(GrSurfaceOrigin origin, + void set(sk_sp contextInfo, + GrSurfaceOrigin origin, int width, int height, GrPixelConfig config, int sampleCnt, - sk_sp contextInfo) { + sk_sp colorSpace, + const SkSurfaceProps& surfaceProps) { + fContextInfo = contextInfo; fOrigin = origin; fWidth = width; fHeight = height; fConfig = config; fSampleCnt = sampleCnt; - fContextInfo = contextInfo; + fColorSpace = std::move(colorSpace); + fSurfaceProps = surfaceProps; } + sk_sp fContextInfo; GrSurfaceOrigin fOrigin; int fWidth; int fHeight; GrPixelConfig fConfig; int fSampleCnt; - sk_sp fContextInfo; + sk_sp fColorSpace; + SkSurfaceProps fSurfaceProps; }; #else// !SK_SUPPORT_GPU diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index 3d19762cd4..605f229023 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -164,8 +164,9 @@ bool SkSurface_Gpu::onCharacterize(SkSurfaceCharacterization* data) const { GrRenderTargetContext* rtc = fDevice->accessRenderTargetContext(); GrContext* ctx = fDevice->context(); - data->set(rtc->origin(), rtc->width(), rtc->height(), rtc->colorSpaceInfo().config(), - rtc->numColorSamples(), ctx->threadSafeProxy()); + data->set(ctx->threadSafeProxy(), rtc->origin(), rtc->width(), rtc->height(), + rtc->colorSpaceInfo().config(), rtc->numColorSamples(), + rtc->colorSpaceInfo().refColorSpace(), this->props()); return true; } @@ -174,10 +175,12 @@ bool SkSurface_Gpu::isCompatible(const SkSurfaceCharacterization& data) const { GrRenderTargetContext* rtc = fDevice->accessRenderTargetContext(); GrContext* ctx = fDevice->context(); - return data.origin() == rtc->origin() && data.width() == rtc->width() && + return data.contextInfo() && data.contextInfo()->matches(ctx) && + data.origin() == rtc->origin() && data.width() == rtc->width() && data.height() == rtc->height() && data.config() == rtc->colorSpaceInfo().config() && data.sampleCount() == rtc->numColorSamples() && - data.contextInfo() && data.contextInfo()->matches(ctx); + SkColorSpace::Equals(data.colorSpace(), rtc->colorSpaceInfo().colorSpace()) && + data.surfaceProps() == rtc->surfaceProps(); } void SkSurface_Gpu::onDraw(SkDeferredDisplayList* dl) {