xref: /aosp_15_r20/external/skia/src/gpu/ganesh/GrOnFlushResourceProvider.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2017 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 #include "src/gpu/ganesh/GrOnFlushResourceProvider.h"
8 
9 #include "include/gpu/ganesh/GrContextOptions.h"
10 #include "include/gpu/ganesh/GrDirectContext.h"
11 #include "include/gpu/ganesh/GrRecordingContext.h"
12 #include "include/private/base/SkAssert.h"
13 #include "src/gpu/ganesh/GrDirectContextPriv.h"
14 #include "src/gpu/ganesh/GrDrawingManager.h"
15 #include "src/gpu/ganesh/GrRecordingContextPriv.h"
16 #include "src/gpu/ganesh/GrSurfaceProxy.h"
17 #include "src/gpu/ganesh/GrSurfaceProxyPriv.h"
18 
instantiateProxy(GrSurfaceProxy * proxy)19 bool GrOnFlushResourceProvider::instantiateProxy(GrSurfaceProxy* proxy) {
20     SkASSERT(proxy->canSkipResourceAllocator());
21 
22     // TODO: this class should probably just get a GrDirectContext
23     auto direct = fDrawingMgr->getContext()->asDirectContext();
24     if (!direct) {
25         return false;
26     }
27 
28     auto resourceProvider = direct->priv().resourceProvider();
29 
30     if (proxy->isLazy()) {
31         return proxy->priv().doLazyInstantiation(resourceProvider);
32     }
33 
34     return proxy->instantiate(resourceProvider);
35 }
36 
caps() const37 const GrCaps* GrOnFlushResourceProvider::caps() const {
38     return fDrawingMgr->getContext()->priv().caps();
39 }
40 
41 #if defined(GPU_TEST_UTILS)
failFlushTimeCallbacks() const42 bool GrOnFlushResourceProvider::failFlushTimeCallbacks() const {
43     return fDrawingMgr->getContext()->priv().options().fFailFlushTimeCallbacks;
44 }
45 #endif
46