Update iOS Skottie App for GrContext changes
Change-Id: Iddfd7c483a5fc734284a4e28a64c3cd249e22e5c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/310116
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/tools/skottie_ios_app/GrContextHolder.mm b/tools/skottie_ios_app/GrContextHolder.mm
index 6a01c60..21e38df 100644
--- a/tools/skottie_ios_app/GrContextHolder.mm
+++ b/tools/skottie_ios_app/GrContextHolder.mm
@@ -7,8 +7,8 @@
#if SK_SUPPORT_GPU
-#include "include/gpu/GrContext.h"
#include "include/gpu/GrContextOptions.h"
+#include "include/gpu/GrDirectContext.h"
#include "include/gpu/gl/GrGLInterface.h"
#ifdef SK_GL
diff --git a/tools/skottie_ios_app/SkMetalViewBridge.mm b/tools/skottie_ios_app/SkMetalViewBridge.mm
index 0da5926..6fa5117 100644
--- a/tools/skottie_ios_app/SkMetalViewBridge.mm
+++ b/tools/skottie_ios_app/SkMetalViewBridge.mm
@@ -5,8 +5,8 @@
#include "include/core/SkSurface.h"
#include "include/gpu/GrBackendSurface.h"
-#include "include/gpu/GrContext.h"
#include "include/gpu/GrContextOptions.h"
+#include "include/gpu/GrDirectContext.h"
#include "include/gpu/mtl/GrMtlTypes.h"
#import <Metal/Metal.h>
diff --git a/tools/skottie_ios_app/SkiaGLContext.mm b/tools/skottie_ios_app/SkiaGLContext.mm
index e6e4e04..916e3f4 100644
--- a/tools/skottie_ios_app/SkiaGLContext.mm
+++ b/tools/skottie_ios_app/SkiaGLContext.mm
@@ -6,7 +6,7 @@
#include "include/core/SkSurface.h"
#include "include/core/SkTime.h"
#include "include/gpu/GrBackendSurface.h"
-#include "include/gpu/GrContext.h"
+#include "include/gpu/GrDirectContext.h"
#include "include/gpu/gl/GrGLInterface.h"
#include "include/gpu/gl/GrGLTypes.h"
@@ -22,17 +22,17 @@
[view setDrawableStencilFormat:GLKViewDrawableStencilFormat8];
}
-static sk_sp<SkSurface> make_gl_surface(GrContext* grContext, int width, int height) {
+static sk_sp<SkSurface> make_gl_surface(GrDirectContext* dContext, int width, int height) {
static constexpr int kStencilBits = 8;
static constexpr int kSampleCount = 1;
static const SkSurfaceProps surfaceProps = SkSurfaceProps::kLegacyFontHost_InitType;
- if (!grContext || width <= 0 || height <= 0) {
+ if (!dContext || width <= 0 || height <= 0) {
return nullptr;
}
GLint fboid = 0;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &fboid);
return SkSurface::MakeFromBackendRenderTarget(
- grContext,
+ dContext,
GrBackendRenderTarget(width,
height,
kSampleCount,
@@ -54,18 +54,18 @@
// Required initializer.
- (instancetype)initWithFrame:(CGRect)frame
withEAGLContext:(EAGLContext*)eaglContext
- withGrContext:(GrContext*)grContext;
+ withDirectContext:(GrDirectContext*)dContext;
@end
@implementation SkiaGLView {
- GrContext* fGrContext;
+ GrDirectContext* fDContext;
}
- (instancetype)initWithFrame:(CGRect)frame
withEAGLContext:(EAGLContext*)eaglContext
- withGrContext:(GrContext*)grContext {
+ withDirectContext:(GrDirectContext*)dContext {
self = [super initWithFrame:frame context:eaglContext];
- fGrContext = grContext;
+ fDContext = dContext;
configure_glkview_for_skia(self);
return self;
}
@@ -79,11 +79,11 @@
int width = (int)[self drawableWidth],
height = (int)[self drawableHeight];
- if (!(fGrContext)) {
- NSLog(@"Error: grContext missing.\n");
+ if (!(fDContext)) {
+ NSLog(@"Error: GrDirectContext missing.\n");
return;
}
- if (sk_sp<SkSurface> surface = make_gl_surface(fGrContext, width, height)) {
+ if (sk_sp<SkSurface> surface = make_gl_surface(fDContext, width, height)) {
[viewController draw:rect
toCanvas:(surface->getCanvas())
atSize:CGSize{(CGFloat)width, (CGFloat)height}];
@@ -107,7 +107,7 @@
@end
@implementation SkiaGLContext {
- sk_sp<GrContext> fGrContext;
+ sk_sp<GrDirectContext> fDContext;
}
- (instancetype) init {
self = [super init];
@@ -122,10 +122,10 @@
}
EAGLContext* oldContext = [EAGLContext currentContext];
[EAGLContext setCurrentContext:[self eaglContext]];
- fGrContext = GrContext::MakeGL(nullptr, GrContextOptions());
+ fDContext = GrDirectContext::MakeGL(nullptr, GrContextOptions());
[EAGLContext setCurrentContext:oldContext];
- if (!fGrContext) {
- NSLog(@"GrContext::MakeGL failed");
+ if (!fDContext) {
+ NSLog(@"GrDirectContext::MakeGL failed");
return nil;
}
return self;
@@ -134,7 +134,7 @@
- (UIView*) makeViewWithController:(SkiaViewController*)vc withFrame:(CGRect)frame {
SkiaGLView* skiaView = [[SkiaGLView alloc] initWithFrame:frame
withEAGLContext:[self eaglContext]
- withGrContext:fGrContext.get()];
+ withDirectContext:fDContext.get()];
[skiaView setController:vc];
return skiaView;
}
diff --git a/tools/skottie_ios_app/SkiaMetalContext.mm b/tools/skottie_ios_app/SkiaMetalContext.mm
index f67d547..594749a 100644
--- a/tools/skottie_ios_app/SkiaMetalContext.mm
+++ b/tools/skottie_ios_app/SkiaMetalContext.mm
@@ -4,7 +4,7 @@
#include "tools/skottie_ios_app/SkiaContext.h"
#include "include/core/SkSurface.h"
-#include "include/gpu/GrContext.h"
+#include "include/gpu/GrDirectContext.h"
#include "tools/skottie_ios_app/SkMetalViewBridge.h"
#import <Metal/Metal.h>
@@ -22,21 +22,21 @@
- (instancetype)initWithFrame:(CGRect)frameRect
device:(id<MTLDevice>)device
queue:(id<MTLCommandQueue>)queue
- grDevice:(GrContext*)grContext;
+ grDevice:(GrDirectContext*)dContext;
@end
@implementation SkiaMtkView {
id<MTLCommandQueue> fQueue;
- GrContext* fGrContext;
+ GrDirectContext* fDContext;
}
- (instancetype)initWithFrame:(CGRect)frameRect
device:(id<MTLDevice>)mtlDevice
queue:(id<MTLCommandQueue>)queue
- grDevice:(GrContext*)grContext {
+ grDevice:(GrDirectContext*)dContext {
self = [super initWithFrame:frameRect device:mtlDevice];
fQueue = queue;
- fGrContext = grContext;
+ fDContext = dContext;
SkMtkViewConfigForSkia(self);
return self;
}
@@ -45,11 +45,11 @@
[super drawRect:rect];
// TODO(halcanary): Use the rect and the InvalidationController to speed up rendering.
SkiaViewController* viewController = [self controller];
- if (!viewController || ![[self currentDrawable] texture] || !fGrContext) {
+ if (!viewController || ![[self currentDrawable] texture] || !fDContext) {
return;
}
CGSize size = [self drawableSize];
- sk_sp<SkSurface> surface = SkMtkViewToSurface(self, fGrContext);
+ sk_sp<SkSurface> surface = SkMtkViewToSurface(self, fDContext);
if (!surface) {
NSLog(@"error: no sksurface");
return;
@@ -77,7 +77,7 @@
@end
@implementation SkiaMetalContext {
- sk_sp<GrContext> fGrContext;
+ sk_sp<GrDirectContext> fDContext;
}
- (instancetype) init {
@@ -88,12 +88,12 @@
return nil;
}
[self setMetalQueue:[[self metalDevice] newCommandQueue]];
- fGrContext = GrContext::MakeMetal((__bridge void*)[self metalDevice],
- (__bridge void*)[self metalQueue],
- GrContextOptions());
+ fDContext = GrDirectContext::MakeMetal((__bridge void*)[self metalDevice],
+ (__bridge void*)[self metalQueue],
+ GrContextOptions());
- if (!fGrContext) {
- NSLog(@"GrContext::MakeMetal failed");
+ if (!fDContext) {
+ NSLog(@"GrDirectContext::MakeMetal failed");
return nil;
}
return self;
@@ -103,7 +103,7 @@
SkiaMtkView* skiaView = [[SkiaMtkView alloc] initWithFrame:frame
device:[self metalDevice]
queue:[self metalQueue]
- grDevice:fGrContext.get()];
+ grDevice:fDContext.get()];
[skiaView setPreferredFramesPerSecond:30];
[skiaView setController:vc];
return skiaView;