be39f713e5
Bug: skia:8737 Change-Id: I5c4c839bcf39f2cd3a9a32d005bf4bdb7c42e6a5 Reviewed-on: https://skia-review.googlesource.com/c/187925 Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
59 lines
1.5 KiB
Objective-C
59 lines
1.5 KiB
Objective-C
|
|
/*
|
|
* Copyright 2019 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
#ifndef MetalWindowContext_DEFINED
|
|
#define MetalWindowContext_DEFINED
|
|
|
|
#include "SkRefCnt.h"
|
|
#include "SkSurface.h"
|
|
|
|
#include "WindowContext.h"
|
|
|
|
#import <Metal/Metal.h>
|
|
#import <MetalKit/MetalKit.h>
|
|
|
|
class GrContext;
|
|
|
|
namespace sk_app {
|
|
|
|
class MetalWindowContext : public WindowContext {
|
|
public:
|
|
sk_sp<SkSurface> getBackbufferSurface() override;
|
|
|
|
bool isValid() override { return fValid; }
|
|
|
|
void resize(int w, int h) override;
|
|
void swapBuffers() override;
|
|
|
|
void setDisplayParams(const DisplayParams& params) override;
|
|
|
|
protected:
|
|
MetalWindowContext(const DisplayParams&);
|
|
// This should be called by subclass constructor. It is also called when window/display
|
|
// parameters change. This will in turn call onInitializeContext().
|
|
void initializeContext();
|
|
virtual bool onInitializeContext() = 0;
|
|
|
|
// This should be called by subclass destructor. It is also called when window/display
|
|
// parameters change prior to initializing a new GL context. This will in turn call
|
|
// onDestroyContext().
|
|
void destroyContext();
|
|
virtual void onDestroyContext() = 0;
|
|
|
|
|
|
bool fValid;
|
|
id<MTLDevice> fDevice;
|
|
id<MTLCommandQueue> fQueue;
|
|
dispatch_semaphore_t fInFlightSemaphore;
|
|
MTKView* fMTKView;
|
|
sk_sp<SkSurface> fSurface;
|
|
};
|
|
|
|
} // namespace sk_app
|
|
|
|
#endif
|