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 #include "snapshot/common.h" 19 stream_renderer_snapshot_presave_pause()20VG_EXPORT int stream_renderer_snapshot_presave_pause() { 21 android_getOpenglesRenderer()->pauseAllPreSave(); 22 return 0; 23 } 24 stream_renderer_snapshot_postsave_resume()25VG_EXPORT int stream_renderer_snapshot_postsave_resume() { 26 android_getOpenglesRenderer()->resumeAll(); 27 return 0; 28 } 29 30 // In end2end tests, we don't really do snapshot save for render threads. 31 // We will need to resume all render threads without waiting for snapshot. stream_renderer_snapshot_postload_resume_for_testing()32VG_EXPORT int stream_renderer_snapshot_postload_resume_for_testing() { 33 android_getOpenglesRenderer()->resumeAll(false); 34 return 0; 35 } 36 stream_renderer_snapshot_save(void * saverStream)37VG_EXPORT int stream_renderer_snapshot_save(void* saverStream) { 38 auto* saver = static_cast<android::snapshot::SnapshotSaveStream*>(saverStream); 39 android_getOpenglesRenderer()->save(saver->stream, saver->textureSaver); 40 return 0; 41 } 42 stream_renderer_snapshot_load(void * loaderStream)43VG_EXPORT int stream_renderer_snapshot_load(void* loaderStream) { 44 auto* loader = static_cast<android::snapshot::SnapshotLoadStream*>(loaderStream); 45 android_getOpenglesRenderer()->load(loader->stream, loader->textureLoader); 46 return 0; 47 } 48