blob: 90e67fd4323f7082f5919ba4292400a15eb0c41f [file] [log] [blame]
* Copyright 2018 Google Inc.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
#ifndef GrMtlBuffer_DEFINED
#define GrMtlBuffer_DEFINED
#include "GrGpuBuffer.h"
#import <metal/metal.h>
class GrMtlCaps;
class GrMtlGpu;
class GrMtlBuffer: public GrGpuBuffer {
static sk_sp<GrMtlBuffer> Make(GrMtlGpu*, size_t size, GrGpuBufferType intendedType,
GrAccessPattern, const void* data = nullptr);
~GrMtlBuffer() override;
id<MTLBuffer> mtlBuffer() const { return fMtlBuffer; }
GrMtlBuffer(GrMtlGpu*, size_t size, GrGpuBufferType intendedType, GrAccessPattern);
void onAbandon() override;
void onRelease() override;
GrMtlGpu* mtlGpu() const;
void onMap() override;
void onUnmap() override;
bool onUpdateData(const void* src, size_t srcSizeInBytes) override;
void internalMap(size_t sizeInBytes);
void internalUnmap(size_t sizeInBytes);
#ifdef SK_DEBUG
void validate() const;
bool fIsDynamic;
id<MTLBuffer> fMtlBuffer;
id<MTLBuffer> fMappedBuffer;
typedef GrGpuBuffer INHERITED;