Reland "Add DisplayGl and DisplaySurfaceGl"
This reverts commit 0b7132a43f6945b1283cdceac055a0b3fb2f45b4.
Original change: aosp/2232570
See https://android-review.googlesource.com/c/device/generic/vulkan-cereal/+/2252598/15..16
for the difference between the original change and this
change to reland.
The original change accidentally updated ColorBuffer's
borrowed image info onCommandsIssued to do an additional
context bind which could lead to the "ColorBuffer"/pbuffer
context across both the virtio gpu thread and the post
worker thread.
Bug: b/233939967
Test: android build
Test: cmake build
Test: cvd start --gpu_mode=gfxstream
Test: gfxstream unit tests
Change-Id: I04459e7eb8f7f18b5c381b782ff1f8be6ba75ab0
diff --git a/stream-servers/DisplaySurfaceUser.h b/stream-servers/DisplaySurfaceUser.h
new file mode 100644
index 0000000..0065709
--- /dev/null
+++ b/stream-servers/DisplaySurfaceUser.h
@@ -0,0 +1,43 @@
+// Copyright (C) 2022 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#pragma once
+
+namespace gfxstream {
+
+class DisplaySurface;
+class DisplaySurfaceUser;
+
+class DisplaySurfaceUser {
+ public:
+ virtual ~DisplaySurfaceUser();
+
+ public:
+ void bindToSurface(DisplaySurface* surface);
+
+ void unbindFromSurface();
+
+ protected:
+ virtual void bindToSurfaceImpl(DisplaySurface* surface) = 0;
+
+ virtual void unbindFromSurfaceImpl() = 0;
+
+ const DisplaySurface* getBoundSurface() const { return mBoundSurface; }
+
+ private:
+ friend class DisplaySurface;
+ DisplaySurface* mBoundSurface = nullptr;
+};
+
+} // namespace gfxstream