Flutter Engine
The Flutter Engine
Functions | Variables
GrMtlGpu.mm File Reference
#include "src/gpu/ganesh/mtl/GrMtlGpu.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkTextureCompressionType.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/ganesh/mtl/GrMtlBackendSemaphore.h"
#include "include/gpu/ganesh/mtl/GrMtlBackendSurface.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/base/SkMathPriv.h"
#include "src/base/SkRectMemcpy.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkMipmap.h"
#include "src/gpu/DataUtils.h"
#include "src/gpu/ganesh/GrBackendUtils.h"
#include "src/gpu/ganesh/GrDataUtils.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrImageInfo.h"
#include "src/gpu/ganesh/GrPixmap.h"
#include "src/gpu/ganesh/GrRenderTarget.h"
#include "src/gpu/ganesh/GrResourceProvider.h"
#include "src/gpu/ganesh/GrTexture.h"
#include "src/gpu/ganesh/GrThreadSafePipelineBuilder.h"
#include "src/gpu/ganesh/mtl/GrMtlBuffer.h"
#include "src/gpu/ganesh/mtl/GrMtlCommandBuffer.h"
#include "src/gpu/ganesh/mtl/GrMtlOpsRenderPass.h"
#include "src/gpu/ganesh/mtl/GrMtlPipelineStateBuilder.h"
#include "src/gpu/ganesh/mtl/GrMtlRenderCommandEncoder.h"
#include "src/gpu/ganesh/mtl/GrMtlSemaphore.h"
#include "src/gpu/ganesh/mtl/GrMtlTexture.h"
#include "src/gpu/ganesh/mtl/GrMtlTextureRenderTarget.h"
#include "src/gpu/ganesh/mtl/GrMtlUtil.h"
#include "src/gpu/mtl/MtlUtilsPriv.h"
#import <simd/simd.h>

Go to the source code of this file.

Functions

static bool check_max_blit_width (int widthInPixels)
 
static id< MTLTexture > get_texture_from_backend (const GrBackendTexture &backendTex)
 
static id< MTLTexture > get_texture_from_backend (const GrBackendRenderTarget &backendRT)
 
static GrColorType mtl_format_to_backend_tex_clear_colortype (MTLPixelFormat format)
 
void copy_src_data (char *dst, size_t bytesPerPixel, const TArray< size_t > &individualMipOffsets, const GrPixmap srcData[], int numMipLevels, size_t bufferSize)
 

Variables

static const int kDefaultOutstandingAllocCnt = 8
 

Function Documentation

◆ check_max_blit_width()

static bool check_max_blit_width ( int  widthInPixels)
static

Definition at line 311 of file GrMtlGpu.mm.

311 {
312 if (widthInPixels > 32767) {
313 SkASSERT(false); // surfaces should not be this wide anyway
314 return false;
315 }
316 return true;
317}
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ copy_src_data()

void copy_src_data ( char *  dst,
size_t  bytesPerPixel,
const TArray< size_t > &  individualMipOffsets,
const GrPixmap  srcData[],
int  numMipLevels,
size_t  bufferSize 
)

Definition at line 859 of file GrMtlGpu.mm.

864 {
865 SkASSERT(srcData && numMipLevels);
866 SkASSERT(individualMipOffsets.size() == numMipLevels);
867
868 for (int level = 0; level < numMipLevels; ++level) {
869 const size_t trimRB = srcData[level].width() * bytesPerPixel;
870 SkASSERT(individualMipOffsets[level] + trimRB * srcData[level].height() <= bufferSize);
871 SkRectMemcpy(dst + individualMipOffsets[level], trimRB,
872 srcData[level].addr(), srcData[level].rowBytes(),
873 trimRB, srcData[level].height());
874 }
875}
static void SkRectMemcpy(void *dst, size_t dstRB, const void *src, size_t srcRB, size_t trimRowBytes, int rowCount)
Definition: SkRectMemcpy.h:16
int width() const
Definition: GrPixmap.h:27
int size() const
Definition: SkTArray.h:421
dst
Definition: cp.py:12
int32_t height

◆ get_texture_from_backend() [1/2]

static id< MTLTexture > get_texture_from_backend ( const GrBackendRenderTarget backendRT)
static

Definition at line 721 of file GrMtlGpu.mm.

721 {
722 GrMtlTextureInfo textureInfo;
723 if (!GrBackendRenderTargets::GetMtlTextureInfo(backendRT, &textureInfo)) {
724 return nil;
725 }
726 return GrGetMTLTexture(textureInfo.fTexture.get());
727}
GR_NORETAIN_BEGIN SK_ALWAYS_INLINE id< MTLTexture > GrGetMTLTexture(const void *mtlTexture)
Definition: GrMtlUtil.h:36
SK_API bool GetMtlTextureInfo(const GrBackendRenderTarget &, GrMtlTextureInfo *)

◆ get_texture_from_backend() [2/2]

static id< MTLTexture > get_texture_from_backend ( const GrBackendTexture backendTex)
static

Definition at line 713 of file GrMtlGpu.mm.

713 {
714 GrMtlTextureInfo textureInfo;
715 if (!GrBackendTextures::GetMtlTextureInfo(backendTex, &textureInfo)) {
716 return nil;
717 }
718 return GrGetMTLTexture(textureInfo.fTexture.get());
719}
SK_API bool GetMtlTextureInfo(const GrBackendTexture &, GrMtlTextureInfo *)

◆ mtl_format_to_backend_tex_clear_colortype()

static GrColorType mtl_format_to_backend_tex_clear_colortype ( MTLPixelFormat  format)
static

Definition at line 834 of file GrMtlGpu.mm.

834 {
835 switch(format) {
836 case MTLPixelFormatA8Unorm: return GrColorType::kAlpha_8;
837 case MTLPixelFormatR8Unorm: return GrColorType::kR_8;
838 case MTLPixelFormatB5G6R5Unorm: return GrColorType::kBGR_565;
839 case MTLPixelFormatABGR4Unorm: return GrColorType::kABGR_4444;
840 case MTLPixelFormatRGBA8Unorm: return GrColorType::kRGBA_8888;
841 case MTLPixelFormatRGBA8Unorm_sRGB: return GrColorType::kRGBA_8888_SRGB;
842
843 case MTLPixelFormatRG8Unorm: return GrColorType::kRG_88;
844 case MTLPixelFormatBGRA8Unorm: return GrColorType::kBGRA_8888;
845 case MTLPixelFormatRGB10A2Unorm: return GrColorType::kRGBA_1010102;
846 case MTLPixelFormatBGR10A2Unorm: return GrColorType::kBGRA_1010102;
847 case MTLPixelFormatR16Float: return GrColorType::kR_F16;
848 case MTLPixelFormatRGBA16Float: return GrColorType::kRGBA_F16;
849 case MTLPixelFormatR16Unorm: return GrColorType::kR_16;
850 case MTLPixelFormatRG16Unorm: return GrColorType::kRG_1616;
851 case MTLPixelFormatRGBA16Unorm: return GrColorType::kRGBA_16161616;
852 case MTLPixelFormatRG16Float: return GrColorType::kRG_F16;
853 default: return GrColorType::kUnknown;
854 }
855
857}
#define SkUNREACHABLE
Definition: SkAssert.h:135
uint32_t uint32_t * format

Variable Documentation

◆ kDefaultOutstandingAllocCnt

const int kDefaultOutstandingAllocCnt = 8
static

Definition at line 87 of file GrMtlGpu.mm.