diff options
author | Robert Phillips <robertphillips@google.com> | 2018-03-06 13:41:51 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-06 19:08:46 +0000 |
commit | 94458ee0f2be19392042084f181b41308ae63624 (patch) | |
tree | f38c4e6108ce2a3f88caf38c6b0920704e383709 /include | |
parent | e041e31926f88bf76d8d29eb77868bb8b3749044 (diff) |
Add SkSurfaceCharacterization::createResized
Change-Id: Ia98ce3cf6c0b9f9100eea9850af56048e43b8d07
Reviewed-on: https://skia-review.googlesource.com/112580
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkDeferredDisplayListRecorder.h | 2 | ||||
-rw-r--r-- | include/core/SkSurfaceCharacterization.h (renamed from include/private/SkSurfaceCharacterization.h) | 44 | ||||
-rw-r--r-- | include/gpu/GrContext.h | 3 |
3 files changed, 36 insertions, 13 deletions
diff --git a/include/core/SkDeferredDisplayListRecorder.h b/include/core/SkDeferredDisplayListRecorder.h index 1dcbbcbe92..c985e7377d 100644 --- a/include/core/SkDeferredDisplayListRecorder.h +++ b/include/core/SkDeferredDisplayListRecorder.h @@ -9,9 +9,9 @@ #define SkDeferredDisplayListMaker_DEFINED #include "SkRefCnt.h" +#include "SkSurfaceCharacterization.h" #include "../private/SkDeferredDisplayList.h" -#include "../private/SkSurfaceCharacterization.h" class GrContext; diff --git a/include/private/SkSurfaceCharacterization.h b/include/core/SkSurfaceCharacterization.h index 9327a538b6..65e5e23d4b 100644 --- a/include/private/SkSurfaceCharacterization.h +++ b/include/core/SkSurfaceCharacterization.h @@ -54,6 +54,24 @@ public: SkSurfaceCharacterization(const SkSurfaceCharacterization&) = default; SkSurfaceCharacterization& operator=(const SkSurfaceCharacterization& other) = default; + SkSurfaceCharacterization createResized(int width, int height) const { + const GrCaps* caps = fContextInfo->caps(); + if (!caps) { + return SkSurfaceCharacterization(); + } + + if (width <= 0 || height <= 0 || + width > caps->maxRenderTargetSize() || height > caps->maxRenderTargetSize()) { + return SkSurfaceCharacterization(); + } + + return SkSurfaceCharacterization(fContextInfo, + fCacheMaxResourceBytes, + fOrigin, width, height, fConfig, fFSAAType, fStencilCnt, + fIsTextureable, fIsMipMapped, fColorSpace, + fSurfaceProps); + } + GrContextThreadSafeProxy* contextInfo() const { return fContextInfo.get(); } sk_sp<GrContextThreadSafeProxy> refContextInfo() const { return fContextInfo; } size_t cacheMaxResourceBytes() const { return fCacheMaxResourceBytes; } @@ -144,25 +162,27 @@ private: class SkSurfaceCharacterization { public: - SkSurfaceCharacterization() - : fWidth(0) - , fHeight(0) - , fSurfaceProps(0, kUnknown_SkPixelGeometry) { + SkSurfaceCharacterization() : fSurfaceProps(0, kUnknown_SkPixelGeometry) { } + + SkSurfaceCharacterization createResized(int width, int height) const { + return *this; } + size_t cacheMaxResourceBytes() const { return 0; } + bool isValid() const { return false; } - int width() const { return fWidth; } - int height() const { return fHeight; } - SkColorSpace* colorSpace() const { return fColorSpace.get(); } - sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; } + int width() const { return 0; } + int height() const { return 0; } + int stencilCount() const { return 0; } + bool isTextureable() const { return false; } + bool isMipMapped() const { return false; } + SkColorSpace* colorSpace() const { return nullptr; } + sk_sp<SkColorSpace> refColorSpace() const { return nullptr; } const SkSurfaceProps& surfaceProps()const { return fSurfaceProps; } private: - int fWidth; - int fHeight; - sk_sp<SkColorSpace> fColorSpace; - SkSurfaceProps fSurfaceProps; + SkSurfaceProps fSurfaceProps; }; #endif diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index bbd43df694..521a3dde7c 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -399,6 +399,9 @@ public: const SkSurfaceProps& surfaceProps, bool isMipMapped); + const GrCaps* caps() const { return fCaps.get(); } + sk_sp<const GrCaps> refCaps() const { return fCaps; } + private: // DDL TODO: need to add unit tests for backend & maybe options GrContextThreadSafeProxy(sk_sp<const GrCaps> caps, |