blob: b1e70004c14c5cff5f982ea8cf4aede916f906fd [file] [log] [blame]
/*
* Copyright 2020 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "tools/sk_app/WindowContext.h"
#include "include/gpu/GrDirectContext.h"
#if defined(SK_GRAPHITE)
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recorder.h"
#endif
namespace sk_app {
WindowContext::WindowContext(const DisplayParams& params)
: fDisplayParams(params) {}
WindowContext::~WindowContext() {}
void WindowContext::swapBuffers() {
#if defined(SK_GRAPHITE)
if (fGraphiteContext) {
SkASSERT(fGraphiteRecorder);
std::unique_ptr<skgpu::graphite::Recording> recording = fGraphiteRecorder->snap();
if (recording) {
skgpu::graphite::InsertRecordingInfo info;
info.fRecording = recording.get();
fGraphiteContext->insertRecording(info);
fGraphiteContext->submit(skgpu::graphite::SyncToCpu::kNo);
}
}
#endif
this->onSwapBuffers();
}
} //namespace sk_app