aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/mtl/GrMtlGpu.mm
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-08-04 09:34:44 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-04 19:53:55 +0000
commit4a081e2475fa69dd55fcace9f8e6d3166ea25ad1 (patch)
treea42a3b82ab0697237fe66e7dda836d07af8e443d /src/gpu/mtl/GrMtlGpu.mm
parent21c3fb94deac8527719be74deff9e8fb8a490e23 (diff)
Add GrMtlTexture classes
Adds support for basic Texture creation. Bug: skia: Change-Id: I9a3f15bef1c88054c19e952e231cad94ad69f296 Reviewed-on: https://skia-review.googlesource.com/30781 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/gpu/mtl/GrMtlGpu.mm')
-rw-r--r--src/gpu/mtl/GrMtlGpu.mm41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm
index 7a9a673d69..a830959bdd 100644
--- a/src/gpu/mtl/GrMtlGpu.mm
+++ b/src/gpu/mtl/GrMtlGpu.mm
@@ -7,6 +7,8 @@
#include "GrMtlGpu.h"
+#include "GrMtlTexture.h"
+
#if !__has_feature(objc_arc)
#error This file must be compiled with Arc. Use -fobjc-arc flag
#endif
@@ -103,3 +105,42 @@ GrMtlGpu::GrMtlGpu(GrContext* context, const GrContextOptions& options,
// Unused queue warning fix
SkDebugf("ptr to queue: %p\n", fQueue);
}
+
+sk_sp<GrTexture> GrMtlGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
+ const GrMipLevel texels[], int mipLevelCount) {
+ int mipLevels = !mipLevelCount ? 1 : mipLevelCount;
+
+ if (!fMtlCaps->isConfigTexturable(desc.fConfig)) {
+ return nullptr;
+ }
+
+ bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
+ if (renderTarget) {
+ // Current we don't have render target support
+ return nullptr;
+ }
+
+ sk_sp<GrMtlTexture> tex;
+ if (renderTarget) {
+ // Enable once we have render target support
+#if 0
+ tex = GrMtlTextureRenderTarget::CreateNewTextureRenderTarget(this, budgeted,
+ desc, mipLevels);
+#endif
+ } else {
+ tex = GrMtlTexture::CreateNewTexture(this, budgeted, desc, mipLevels);
+ }
+
+ if (!tex) {
+ return nullptr;
+ }
+
+ if (mipLevelCount) {
+ // Perform initial data upload here
+ }
+
+ if (desc.fFlags & kPerformInitialClear_GrSurfaceFlag) {
+ // Do initial clear of the texture
+ }
+ return tex;
+}