blob: de1ba00211d3bb59cb48a484b2667fc47bd4b5e1 [file] [log] [blame]
Fedor Kudasova8871162019-07-04 12:54:28 +01001/*
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
25namespace android {
26
27class Surface : public ANativeObjectBase<ANativeWindow, Surface, RefBase> {
28public:
29 explicit Surface(const sp<IGraphicBufferProducer>& bufferProducer,
30 bool controlledByApp = false) {
31 ANativeWindow::perform = hook_perform;
32 }
33 static bool isValid(const sp<Surface>& surface) { return surface != nullptr; }
34 void allocateBuffers() {}
35
36 uint64_t getNextFrameNumber() const { return 0; }
37
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
46 virtual int lock(ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds) {
47 // TODO: implement this
48 return 0;
49 }
50 virtual int unlockAndPost() { return 0; }
51 virtual int query(int what, int* value) const { return 0; }
52
53protected:
54 virtual ~Surface() {}
55
56 static int hook_perform(ANativeWindow* window, int operation, ...) { return 0; }
57
58private:
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