aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/mtl/GrMtlCaps.mm
diff options
context:
space:
mode:
authorGravatar Timothy Liang <timliang@google.com>2018-07-20 16:53:00 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-23 17:23:24 +0000
commite35055f31c7f2a2c7f3c693b9231c44d181ec599 (patch)
tree5283d4e83d140bc7f360430b2b891c04a696b401 /src/gpu/mtl/GrMtlCaps.mm
parent206dbe8a21b614bbf09b9d2b488ff453e41fdfd9 (diff)
implemented copy surface as blit for metal gpu backend
Bug: skia: Change-Id: Ic59fe585c02168a361985f0864242b3c11e9d98e Reviewed-on: https://skia-review.googlesource.com/142684 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Timothy Liang <timliang@google.com>
Diffstat (limited to 'src/gpu/mtl/GrMtlCaps.mm')
-rw-r--r--src/gpu/mtl/GrMtlCaps.mm49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index 2527be9ceb..3093352272 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -9,7 +9,10 @@
#include "GrBackendSurface.h"
#include "GrMtlUtil.h"
+#include "GrRenderTargetProxy.h"
#include "GrShaderCaps.h"
+#include "GrSurfaceProxy.h"
+#include "SkRect.h"
GrMtlCaps::GrMtlCaps(const GrContextOptions& contextOptions, const id<MTLDevice> device,
MTLFeatureSet featureSet)
@@ -101,6 +104,52 @@ void GrMtlCaps::initFeatureSet(MTLFeatureSet featureSet) {
SK_ABORT("Requested an unsupported feature set");
}
+bool GrMtlCaps::canCopyAsBlit(GrPixelConfig dstConfig, int dstSampleCount,
+ GrSurfaceOrigin dstOrigin,
+ GrPixelConfig srcConfig, int srcSampleCount,
+ GrSurfaceOrigin srcOrigin,
+ const SkIRect& srcRect, const SkIPoint& dstPoint,
+ bool areDstSrcSameObj) const {
+ if (dstConfig != srcConfig) {
+ return false;
+ }
+ if ((dstSampleCount > 1 || srcSampleCount > 1) && (dstSampleCount != srcSampleCount)) {
+ return false;
+ }
+ if (dstOrigin != srcOrigin) {
+ return false;
+ }
+ if (areDstSrcSameObj) {
+ SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.x(), dstPoint.y(),
+ srcRect.width(), srcRect.height());
+ if (dstRect.intersect(srcRect)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool GrMtlCaps::canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
+ const SkIRect& srcRect, const SkIPoint& dstPoint) const {
+ GrSurfaceOrigin dstOrigin = dst->origin();
+ GrSurfaceOrigin srcOrigin = src->origin();
+
+ int dstSampleCnt = 0;
+ int srcSampleCnt = 0;
+ if (const GrRenderTargetProxy* rtProxy = dst->asRenderTargetProxy()) {
+ dstSampleCnt = rtProxy->numColorSamples();
+ }
+ if (const GrRenderTargetProxy* rtProxy = src->asRenderTargetProxy()) {
+ srcSampleCnt = rtProxy->numColorSamples();
+ }
+ SkASSERT((dstSampleCnt > 0) == SkToBool(dst->asRenderTargetProxy()));
+ SkASSERT((srcSampleCnt > 0) == SkToBool(src->asRenderTargetProxy()));
+
+ return this->canCopyAsBlit(dst->config(), dstSampleCnt, dstOrigin,
+ src->config(), srcSampleCnt, srcOrigin,
+ srcRect, dstPoint, dst == src);
+}
+
void GrMtlCaps::initGrCaps(const id<MTLDevice> device) {
// Max vertex attribs is the same on all devices
fMaxVertexAttributes = 31;