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 <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2017-11-30 11:22:14 -05:00 committed by Skia Commit-Bot
parent f3c1f099de
commit 61e51012ee
4 changed files with 31 additions and 12 deletions

View File

@ -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();

View File

@ -35,7 +35,7 @@ public:
void draw(SkSurface*);
private:
SkSurfaceCharacterization fCharacterization;
const SkSurfaceCharacterization fCharacterization;
// TODO: actually store the GPU opLists
sk_sp<SkImage> fImage;

View File

@ -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<SkColorSpace> 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<GrContextThreadSafeProxy> contextInfo,
GrSurfaceOrigin origin,
int width, int height,
GrPixelConfig config,
int sampleCnt,
sk_sp<GrContextThreadSafeProxy> contextInfo) {
sk_sp<SkColorSpace> 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<GrContextThreadSafeProxy> fContextInfo;
GrSurfaceOrigin fOrigin;
int fWidth;
int fHeight;
GrPixelConfig fConfig;
int fSampleCnt;
sk_sp<GrContextThreadSafeProxy> fContextInfo;
sk_sp<SkColorSpace> fColorSpace;
SkSurfaceProps fSurfaceProps;
};
#else// !SK_SUPPORT_GPU

View File

@ -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) {