aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-03-06 13:41:51 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-06 19:08:46 +0000
commit94458ee0f2be19392042084f181b41308ae63624 (patch)
treef38c4e6108ce2a3f88caf38c6b0920704e383709 /include/core
parente041e31926f88bf76d8d29eb77868bb8b3749044 (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/core')
-rw-r--r--include/core/SkDeferredDisplayListRecorder.h2
-rw-r--r--include/core/SkSurfaceCharacterization.h190
2 files changed, 191 insertions, 1 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/core/SkSurfaceCharacterization.h b/include/core/SkSurfaceCharacterization.h
new file mode 100644
index 0000000000..65e5e23d4b
--- /dev/null
+++ b/include/core/SkSurfaceCharacterization.h
@@ -0,0 +1,190 @@
+/*
+ * 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"
+
+#include "SkColorSpace.h"
+#include "SkRefCnt.h"
+#include "SkSurfaceProps.h"
+
+class SkColorSpace;
+
+// This define can be used to swap between the default (raster) DDL implementation and the
+// gpu implementation.
+#define SK_RASTER_RECORDER_IMPLEMENTATION 1
+
+#if SK_SUPPORT_GPU
+#include "GrContext.h"
+
+/** \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
+ GrContextThreadSafeProxy and SkColorSpace objects.
+*/
+class SkSurfaceCharacterization {
+public:
+ enum class Textureable : bool { kNo = false, kYes = true };
+ enum class MipMapped : bool { kNo = false, kYes = true };
+
+ SkSurfaceCharacterization()
+ : fCacheMaxResourceBytes(0)
+ , fOrigin(kBottomLeft_GrSurfaceOrigin)
+ , fWidth(0)
+ , fHeight(0)
+ , fConfig(kUnknown_GrPixelConfig)
+ , fFSAAType(GrFSAAType::kNone)
+ , fStencilCnt(0)
+ , fIsTextureable(Textureable::kYes)
+ , fIsMipMapped(MipMapped::kYes)
+ , fSurfaceProps(0, kUnknown_SkPixelGeometry) {
+ }
+
+ SkSurfaceCharacterization(SkSurfaceCharacterization&&) = default;
+ SkSurfaceCharacterization& operator=(SkSurfaceCharacterization&&) = default;
+
+ 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; }
+
+ bool isValid() const { return kUnknown_GrPixelConfig != fConfig; }
+
+ GrSurfaceOrigin origin() const { return fOrigin; }
+ int width() const { return fWidth; }
+ int height() const { return fHeight; }
+ GrPixelConfig config() const { return fConfig; }
+ GrFSAAType fsaaType() const { return fFSAAType; }
+ int stencilCount() const { return fStencilCnt; }
+ bool isTextureable() const { return Textureable::kYes == fIsTextureable; }
+ bool isMipMapped() const { return MipMapped::kYes == fIsMipMapped; }
+ 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'
+ friend class GrContextThreadSafeProxy; // for private ctor
+
+ SkSurfaceCharacterization(sk_sp<GrContextThreadSafeProxy> contextInfo,
+ size_t cacheMaxResourceBytes,
+ GrSurfaceOrigin origin, int width, int height,
+ GrPixelConfig config, GrFSAAType FSAAType, int stencilCnt,
+ Textureable isTextureable, MipMapped isMipMapped,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps& surfaceProps)
+ : fContextInfo(std::move(contextInfo))
+ , fCacheMaxResourceBytes(cacheMaxResourceBytes)
+ , fOrigin(origin)
+ , fWidth(width)
+ , fHeight(height)
+ , fConfig(config)
+ , fFSAAType(FSAAType)
+ , fStencilCnt(stencilCnt)
+ , fIsTextureable(isTextureable)
+ , fIsMipMapped(isMipMapped)
+ , fColorSpace(std::move(colorSpace))
+ , fSurfaceProps(surfaceProps) {
+ }
+
+ void set(sk_sp<GrContextThreadSafeProxy> contextInfo,
+ size_t cacheMaxResourceBytes,
+ GrSurfaceOrigin origin,
+ int width, int height,
+ GrPixelConfig config,
+ GrFSAAType fsaaType,
+ int stencilCnt,
+ Textureable isTextureable,
+ MipMapped isMipMapped,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps& surfaceProps) {
+ SkASSERT(MipMapped::kNo == isMipMapped || Textureable::kYes == isTextureable);
+
+ fContextInfo = contextInfo;
+ fCacheMaxResourceBytes = cacheMaxResourceBytes;
+
+ fOrigin = origin;
+ fWidth = width;
+ fHeight = height;
+ fConfig = config;
+ fFSAAType = fsaaType;
+ fStencilCnt = stencilCnt;
+ fIsTextureable = isTextureable;
+ fIsMipMapped = isMipMapped;
+ fColorSpace = std::move(colorSpace);
+ fSurfaceProps = surfaceProps;
+ }
+
+ sk_sp<GrContextThreadSafeProxy> fContextInfo;
+ size_t fCacheMaxResourceBytes;
+
+ GrSurfaceOrigin fOrigin;
+ int fWidth;
+ int fHeight;
+ GrPixelConfig fConfig;
+ GrFSAAType fFSAAType;
+ int fStencilCnt;
+ Textureable fIsTextureable;
+ MipMapped fIsMipMapped;
+ sk_sp<SkColorSpace> fColorSpace;
+ SkSurfaceProps fSurfaceProps;
+};
+
+#else// !SK_SUPPORT_GPU
+
+class SkSurfaceCharacterization {
+public:
+ 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 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:
+ SkSurfaceProps fSurfaceProps;
+};
+
+#endif
+
+#endif