native_window.cpp revision 54a181b1a2b1517a9479b21fbf7705a688232faf
1/*
2 * Copyright (C) 2010 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#define LOG_TAG "Surface"
18#include <utils/Log.h>
19
20#include <android/native_window.h>
21#include <surfaceflinger/Surface.h>
22
23using android::Surface;
24
25static int32_t getWindowProp(ANativeWindow* window, int what) {
26    int value;
27    int res = window->query(window, what, &value);
28    return res < 0 ? res : value;
29}
30
31int32_t ANativeWindow_getWidth(ANativeWindow* window) {
32    return getWindowProp(window, NATIVE_WINDOW_WIDTH);
33}
34
35int32_t ANativeWindow_getHeight(ANativeWindow* window) {
36    return getWindowProp(window, NATIVE_WINDOW_HEIGHT);
37}
38
39int32_t ANativeWindow_getFormat(ANativeWindow* window) {
40    return getWindowProp(window, NATIVE_WINDOW_FORMAT);
41}
42