1 /* 2 * Copyright 2023 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 #include "tools/window/WindowContext.h" 9 10 #include "include/gpu/GrDirectContext.h" 11 #if defined(SK_GRAPHITE) 12 #include "include/gpu/graphite/Context.h" 13 #include "include/gpu/graphite/Recorder.h" 14 #endif 15 16 namespace skwindow { 17 WindowContext(const DisplayParams & params)18WindowContext::WindowContext(const DisplayParams& params) 19 : fDisplayParams(params) {} 20 ~WindowContext()21WindowContext::~WindowContext() {} 22 swapBuffers()23void WindowContext::swapBuffers() { 24 this->onSwapBuffers(); 25 } 26 27 #if defined(SK_GRAPHITE) snapRecordingAndSubmit()28void WindowContext::snapRecordingAndSubmit() { 29 if (fGraphiteContext) { 30 SkASSERT(fGraphiteRecorder); 31 std::unique_ptr<skgpu::graphite::Recording> recording = fGraphiteRecorder->snap(); 32 if (recording) { 33 skgpu::graphite::InsertRecordingInfo info; 34 info.fRecording = recording.get(); 35 fGraphiteContext->insertRecording(info); 36 fGraphiteContext->submit(skgpu::graphite::SyncToCpu::kNo); 37 } 38 } 39 } 40 #endif 41 42 } // namespace skwindow 43