@@ -150,29 +150,29 @@ struct ColorSettings {
150150 GrGLenum pixFormat;
151151};
152152
153- sk_sp<GrContext > MakeGrContext (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context)
153+ sk_sp<GrDirectContext > MakeGrContext (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context)
154154{
155155 EMSCRIPTEN_RESULT r = emscripten_webgl_make_context_current (context);
156156 if (r < 0 ) {
157157 printf (" failed to make webgl context current %d\n " , r);
158158 return nullptr ;
159159 }
160- // setup GrContext
160+ // setup GrDirectContext
161161 auto interface = GrGLMakeNativeInterface ();
162162 // setup contexts
163- sk_sp<GrContext> grContext ( GrContext ::MakeGL (interface));
164- return grContext ;
163+ sk_sp<GrDirectContext> dContext ( GrDirectContext ::MakeGL (interface));
164+ return dContext ;
165165}
166166
167- sk_sp<SkSurface> MakeOnScreenGLSurface (sk_sp<GrContext> grContext , int width, int height,
167+ sk_sp<SkSurface> MakeOnScreenGLSurface (sk_sp<GrDirectContext> dContext , int width, int height,
168168 sk_sp<SkColorSpace> colorSpace) {
169169 // WebGL should already be clearing the color and stencil buffers, but do it again here to
170170 // ensure Skia receives them in the expected state.
171171 glBindFramebuffer (GL_FRAMEBUFFER, 0 );
172172 glClearColor (0 , 0 , 0 , 0 );
173173 glClearStencil (0 );
174174 glClear (GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
175- grContext ->resetContext (kRenderTarget_GrGLBackendState | kMisc_GrGLBackendState );
175+ dContext ->resetContext (kRenderTarget_GrGLBackendState | kMisc_GrGLBackendState );
176176
177177 // The on-screen canvas is FBO 0. Wrap it in a Skia render target so Skia can render to it.
178178 GrGLFramebufferInfo info;
@@ -187,24 +187,24 @@ sk_sp<SkSurface> MakeOnScreenGLSurface(sk_sp<GrContext> grContext, int width, in
187187 const auto colorSettings = ColorSettings (colorSpace);
188188 info.fFormat = colorSettings.pixFormat ;
189189 GrBackendRenderTarget target (width, height, sampleCnt, stencil, info);
190- sk_sp<SkSurface> surface (SkSurface::MakeFromBackendRenderTarget (grContext .get (), target,
190+ sk_sp<SkSurface> surface (SkSurface::MakeFromBackendRenderTarget (dContext .get (), target,
191191 kBottomLeft_GrSurfaceOrigin , colorSettings.colorType , colorSpace, nullptr ));
192192 return surface;
193193}
194194
195- sk_sp<SkSurface> MakeRenderTarget (sk_sp<GrContext> grContext , int width, int height) {
195+ sk_sp<SkSurface> MakeRenderTarget (sk_sp<GrDirectContext> dContext , int width, int height) {
196196 SkImageInfo info = SkImageInfo::MakeN32 (width, height, SkAlphaType::kPremul_SkAlphaType );
197197
198- sk_sp<SkSurface> surface (SkSurface::MakeRenderTarget (grContext .get (),
198+ sk_sp<SkSurface> surface (SkSurface::MakeRenderTarget (dContext .get (),
199199 SkBudgeted::kYes ,
200200 info, 0 ,
201201 kBottomLeft_GrSurfaceOrigin ,
202202 nullptr , true ));
203203 return surface;
204204}
205205
206- sk_sp<SkSurface> MakeRenderTarget (sk_sp<GrContext> grContext , SimpleImageInfo sii) {
207- sk_sp<SkSurface> surface (SkSurface::MakeRenderTarget (grContext .get (),
206+ sk_sp<SkSurface> MakeRenderTarget (sk_sp<GrDirectContext> dContext , SimpleImageInfo sii) {
207+ sk_sp<SkSurface> surface (SkSurface::MakeRenderTarget (dContext .get (),
208208 SkBudgeted::kYes ,
209209 toSkImageInfo (sii), 0 ,
210210 kBottomLeft_GrSurfaceOrigin ,
@@ -737,8 +737,8 @@ EMSCRIPTEN_BINDINGS(Skia) {
737737 function (" setCurrentContext" , &emscripten_webgl_make_context_current);
738738 function (" MakeGrContext" , &MakeGrContext);
739739 function (" MakeOnScreenGLSurface" , &MakeOnScreenGLSurface);
740- function (" MakeRenderTarget" , select_overload<sk_sp<SkSurface>(sk_sp<GrContext >, int , int )>(&MakeRenderTarget));
741- function (" MakeRenderTarget" , select_overload<sk_sp<SkSurface>(sk_sp<GrContext >, SimpleImageInfo)>(&MakeRenderTarget));
740+ function (" MakeRenderTarget" , select_overload<sk_sp<SkSurface>(sk_sp<GrDirectContext >, int , int )>(&MakeRenderTarget));
741+ function (" MakeRenderTarget" , select_overload<sk_sp<SkSurface>(sk_sp<GrDirectContext >, SimpleImageInfo)>(&MakeRenderTarget));
742742
743743 constant (" gpu" , true );
744744#endif
@@ -910,22 +910,26 @@ EMSCRIPTEN_BINDINGS(Skia) {
910910 }), allow_raw_pointers ());
911911
912912#ifdef SK_GL
913- class_<GrContext>(" GrContext" )
914- .smart_ptr <sk_sp<GrContext>>(" sk_sp<GrContext>" )
915- .function (" getResourceCacheLimitBytes" , optional_override ([](GrContext& self)->size_t {
913+ class_<GrDirectContext>(" GrDirectContext" )
914+ .smart_ptr <sk_sp<GrDirectContext>>(" sk_sp<GrDirectContext>" )
915+ .function (" getResourceCacheLimitBytes" ,
916+ optional_override ([](GrDirectContext& self)->size_t {
916917 int maxResources = 0 ;// ignored
917918 size_t currMax = 0 ;
918919 self.getResourceCacheLimits (&maxResources, &currMax);
919920 return currMax;
920921 }))
921- .function (" getResourceCacheUsageBytes" , optional_override ([](GrContext& self)->size_t {
922+ .function (" getResourceCacheUsageBytes" ,
923+ optional_override ([](GrDirectContext& self)->size_t {
922924 int usedResources = 0 ;// ignored
923925 size_t currUsage = 0 ;
924926 self.getResourceCacheUsage (&usedResources, &currUsage);
925927 return currUsage;
926928 }))
927- .function (" releaseResourcesAndAbandonContext" , &GrContext::releaseResourcesAndAbandonContext)
928- .function (" setResourceCacheLimitBytes" , optional_override ([](GrContext& self, size_t maxResourceBytes)->void {
929+ .function (" releaseResourcesAndAbandonContext" ,
930+ &GrDirectContext::releaseResourcesAndAbandonContext)
931+ .function (" setResourceCacheLimitBytes" ,
932+ optional_override ([](GrDirectContext& self, size_t maxResourceBytes)->void {
929933 int maxResources = 0 ;
930934 size_t currMax = 0 ; // ignored
931935 self.getResourceCacheLimits (&maxResources, &currMax);
0 commit comments