• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2023 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "gfxstream/virtio-gpu-gfxstream-renderer-goldfish.h"
16 
17 #include "host-common/opengles.h"
18 
stream_renderer_snapshot_presave_pause()19 VG_EXPORT int stream_renderer_snapshot_presave_pause() {
20     android_getOpenglesRenderer()->pauseAllPreSave();
21     return 0;
22 }
23 
stream_renderer_snapshot_postsave_resume()24 VG_EXPORT int stream_renderer_snapshot_postsave_resume() {
25     android_getOpenglesRenderer()->resumeAll();
26     return 0;
27 }
28 
29 // In end2end tests, we don't really do snapshot save for render threads.
30 // We will need to resume all render threads without waiting for snapshot.
stream_renderer_snapshot_postsave_resume_for_testing()31 VG_EXPORT int stream_renderer_snapshot_postsave_resume_for_testing() {
32     android_getOpenglesRenderer()->resumeAll(false);
33     return 0;
34 }
35 
stream_renderer_snapshot_save(void * stream,void * textureSaver)36 VG_EXPORT int stream_renderer_snapshot_save(void* stream, void* textureSaver) {
37     android_getOpenglesRenderer()->save(
38         static_cast<android::base::Stream*>(stream),
39         *static_cast<const android::snapshot::ITextureSaverPtr*>(textureSaver));
40     return 0;
41 }
42 
stream_renderer_snapshot_load(void * stream,void * textureLoader)43 VG_EXPORT int stream_renderer_snapshot_load(void* stream, void* textureLoader) {
44     android_getOpenglesRenderer()->load(
45         static_cast<android::base::Stream*>(stream),
46         *static_cast<const android::snapshot::ITextureLoaderPtr*>(textureLoader));
47     return 0;
48 }
49