1 /* 2 * Copyright 2021 Google LLC 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 8 #ifndef skgpu_Gpu_DEFINED 9 #define skgpu_Gpu_DEFINED 10 11 #include "include/core/SkRefCnt.h" 12 #include "include/private/SkDeque.h" 13 14 #include "experimental/graphite/include/GraphiteTypes.h" 15 16 namespace skgpu { 17 18 class Caps; 19 class ResourceProvider; 20 class CommandBuffer; 21 class GpuWorkSubmission; 22 23 class Gpu : public SkRefCnt { 24 public: 25 ~Gpu() override; 26 27 /** 28 * Gets the capabilities of the draw target. 29 */ caps()30 const Caps* caps() const { return fCaps.get(); } 31 sk_sp<const Caps> refCaps() const; 32 resourceProvider()33 ResourceProvider* resourceProvider() const { return fResourceProvider.get(); } 34 35 bool submit(sk_sp<CommandBuffer>); 36 void checkForFinishedWork(SyncToCpu); 37 38 #if GRAPHITE_TEST_UTILS testingOnly_startCapture()39 virtual void testingOnly_startCapture() {} testingOnly_endCapture()40 virtual void testingOnly_endCapture() {} 41 #endif 42 43 protected: 44 Gpu(sk_sp<const Caps>); 45 46 std::unique_ptr<ResourceProvider> fResourceProvider; 47 48 using OutstandingSubmission = std::unique_ptr<GpuWorkSubmission>; 49 SkDeque fOutstandingSubmissions; 50 51 private: 52 virtual bool onSubmit(sk_sp<CommandBuffer>) = 0; 53 54 sk_sp<const Caps> fCaps; 55 }; 56 57 } // namespace skgpu 58 59 #endif // skgpu_Gpu_DEFINED 60