• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_GUI_SURFACE_H
18 #define ANDROID_GUI_SURFACE_H
19 
20 #include <gui/IGraphicBufferProducer.h>
21 #include <ui/ANativeObjectBase.h>
22 #include <utils/RefBase.h>
23 #include <system/window.h>
24 
25 namespace android {
26 
27 class Surface : public ANativeObjectBase<ANativeWindow, Surface, RefBase> {
28 public:
29     explicit Surface(const sp<IGraphicBufferProducer>& bufferProducer,
30                      bool controlledByApp = false) {
31         ANativeWindow::perform = hook_perform;
32     }
isValid(const sp<Surface> & surface)33     static bool isValid(const sp<Surface>& surface) { return surface != nullptr; }
allocateBuffers()34     void allocateBuffers() {}
35 
getNextFrameNumber()36     uint64_t getNextFrameNumber() const { return 0; }
37 
setScalingMode(int mode)38     int setScalingMode(int mode) { return 0; }
39 
40     virtual int disconnect(int api,
41                            IGraphicBufferProducer::DisconnectMode mode =
42                                    IGraphicBufferProducer::DisconnectMode::Api) {
43         return 0;
44     }
45 
lock(ANativeWindow_Buffer * outBuffer,ARect * inOutDirtyBounds)46     virtual int lock(ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds) {
47         // TODO: implement this
48         return 0;
49     }
unlockAndPost()50     virtual int unlockAndPost() { return 0; }
query(int what,int * value)51     virtual int query(int what, int* value) const { return 0; }
52 
53 protected:
~Surface()54     virtual ~Surface() {}
55 
hook_perform(ANativeWindow * window,int operation,...)56     static int hook_perform(ANativeWindow* window, int operation, ...) { return 0; }
57 
58 private:
59     // can't be copied
60     Surface& operator=(const Surface& rhs);
61     Surface(const Surface& rhs);
62 };
63 
64 } // namespace android
65 
66 #endif  // ANDROID_GUI_SURFACE_H
67