skia2/tools/sk_app/MetalWindowContext.h
Jim Van Verth e8a1c0150b Revert "Remove ARC from tools lib."
This reverts commit 4c4c80fa12.

Reason for revert: Need to update Flutter with sk_cf_obj renaming.

Original change's description:
> Remove ARC from tools lib.
>
> Trying this in baby steps to manage leaks better.
>
> Change-Id: Id8597ba236c752bcbf1c7ec94f6c1021e636d547
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372556
> Commit-Queue: Jim Van Verth <jvanverth@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Adlai Holler <adlai@google.com>

TBR=jvanverth@google.com,bsalomon@google.com,adlai@google.com

Change-Id: I7dc226d002184b80a1d8d2aee09d122d2e13d732
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372680
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2021-02-20 00:08:41 +00:00

60 lines
1.7 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 "include/core/SkRefCnt.h"
#include "include/core/SkSurface.h"
#include "tools/sk_app/WindowContext.h"
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>
namespace sk_app {
class MetalWindowContext : public WindowContext {
public:
sk_sp<SkSurface> getBackbufferSurface() override;
bool isValid() override { return fValid; }
void swapBuffers() override;
void setDisplayParams(const DisplayParams& params) override;
void activate(bool isActive) override;
protected:
static NSURL* CacheURL();
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 Metal context. This will in turn call
// onDestroyContext().
void destroyContext();
virtual void onDestroyContext() = 0;
bool fValid;
id<MTLDevice> fDevice;
id<MTLCommandQueue> fQueue;
CAMetalLayer* fMetalLayer;
GrMTLHandle fDrawableHandle;
#if GR_METAL_SDK_VERSION >= 230
id<MTLBinaryArchive> fPipelineArchive SK_API_AVAILABLE(macos(11.0), ios(14.0));
#endif
};
} // namespace sk_app
#endif