skia2/experimental/skottie_ios/SkottieMtkView.h
Jim Van Verth c910602376 Reland "Minimal iOS app: Perform present subsequent to flush"
This is a reland of 4e385e21a4

Original change's description:
> Minimal iOS app: Perform present subsequent to flush
> 
> Currently the backbuffer present is not on the same MTLCommandQueue
> as the flush from Skia, which probably means that it's happening
> concurrently. This can overwhelm the GPU. This CL submits the present
> to the same queue as the flush.
> 
> Change-Id: Ibaf805553931c9dc46368b362a2391425ae3e60e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/248557
> Reviewed-by: Hal Canary <halcanary@skia.org>
> Commit-Queue: Jim Van Verth <jvanverth@google.com>

Change-Id: I118047630b8936838d5da8ef4307ad5c5e8d2ade
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/248562
Reviewed-by: Hal Canary <halcanary@skia.org>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2019-10-14 18:32:37 +00:00

50 lines
1.4 KiB
Objective-C

// Copyright 2019 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#ifndef SkottieMtkView_DEFINED
#define SkottieMtkView_DEFINED
#import <MetalKit/MetalKit.h>
#import <UIKit/UIKit.h>
class GrContext;
@interface SkottieMtkView : MTKView
// Must be set to a Metal-backed GrContext in order to draw.
// e.g.: use SkMetalDeviceToGrContext().
@property (assign) GrContext* grContext; // non-owning pointer.
// Must be set to a valid MTLCommandQueue. Will be used to present.
@property (assign) id<MTLCommandQueue> queue; // non-owning pointer.
// When set, pauses at end of loop.
@property (assign) BOOL stopAtEnd;
// Override of the MTKView interface. Uses Skia+Skottie+Metal to draw.
- (void)drawRect:(CGRect)rect;
// Load an animation from a Lottie JSON file. Returns Yes on success.
- (BOOL)loadAnimation:(NSData*)d;
// Jump to the specified location in the animation.
- (void)seek:(float)seconds;
// Toggle paused mode. Return paused state.
- (BOOL)togglePaused;
// Return the current paused state.
- (BOOL)isPaused;
// Return the default size of the Lottie animation.
- (CGSize)size;
// Return the length of the animation loop.
- (float)animationDurationSeconds;
// Return the current position in the animation in seconds (between zero and
// animationDurationSeconds).
- (float)currentTime;
@end
#endif // SkottieMtkView_DEFINED