1#if defined IGRAPHICS_NANOVG && defined IGRAPHICS_METAL 
    3#include "TestMPSControl.h" 
    5#import <MetalPerformanceShaders/MetalPerformanceShaders.h> 
   11  if (@available(macOS 10.13, *))
 
   16      mFBO = nvgCreateFramebuffer(pCtx, mBitmap.W() * mBitmap.GetScale(), mBitmap.H() * mBitmap.GetScale(), 0);
 
   19    auto dev = 
static_cast<id<MTLDevice>
>(mnvgDevice(pCtx));
 
   20    auto commandQueue = 
static_cast<id<MTLCommandQueue>
>(mnvgCommandQueue(pCtx));
 
   21    auto srcTex = 
static_cast<id<MTLTexture>
>(mnvgImageHandle(pCtx, mBitmap.GetAPIBitmap()->GetBitmap()));
 
   22    auto dstTex = 
static_cast<id<MTLTexture>
>(mnvgImageHandle(pCtx, mFBO->image));
 
   23    id<MTLCommandBuffer> commandBuffer = [commandQueue commandBuffer];
 
   25    MPSUnaryImageKernel* pKernel = 
nullptr;
 
   27    switch (mKernelType) {
 
   28      case 0: pKernel = [[MPSImageGaussianBlur alloc] initWithDevice:dev sigma:
GetValue() * 10.]; 
break;
 
   29      case 1: pKernel = [[MPSImageSobel alloc] initWithDevice:dev]; 
break;
 
   30      case 2: pKernel = [[MPSImageThresholdToZero alloc] initWithDevice:dev thresholdValue:
GetValue() linearGrayColorTransform:nil]; break;
 
   34    [pKernel encodeToCommandBuffer:commandBuffer sourceTexture:srcTex destinationTexture:dstTex];
 
   35    [commandBuffer commit];
 
   36    [commandBuffer waitUntilCompleted];
 
   40    APIBitmap apibmp {mFBO->image, int(mBitmap.W() * mBitmap.GetScale()), int(mBitmap.H() * mBitmap.GetScale()), 1, 1.};
 
   41    IBitmap bmp {&apibmp, 1, 
false};
 
A base class interface for a bitmap abstraction around the different drawing back end bitmap represen...
User-facing bitmap abstraction that you use to manage bitmap data, independant of draw class/platform...
double GetValue(int valIdx=0) const
Get the control's value.
The lowest level base class of an IGraphics context.
virtual void DrawFittedBitmap(const IBitmap &bitmap, const IRECT &bounds, const IBlend *pBlend=0)
Draw a bitmap (raster) image to the graphics context, scaling the image to fit the bounds.
virtual void * GetDrawContext()=0
Gets a void pointer to underlying drawing context, for the IGraphics backend See draw class implement...
void Draw(IGraphics &g) override
Draw the control to the graphics context.