1 /* 2 * Copyright 2015 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 SURFACE_UTILS_H_ 18 19 #define SURFACE_UTILS_H_ 20 21 #include <utils/Errors.h> 22 #include <utils/StrongPointer.h> 23 24 struct ANativeWindow; 25 class Surface; 26 27 namespace android { 28 29 struct HDRStaticInfo; 30 class IProducerListener; 31 32 /** 33 * Configures |nativeWindow| for given |width|x|height|, pixel |format|, |rotation| and |usage|. 34 * If |reconnect| is true, reconnects to the native window before hand. 35 * @return first error encountered, or NO_ERROR on success. 36 */ 37 status_t setNativeWindowSizeFormatAndUsage( 38 ANativeWindow *nativeWindow /* nonnull */, 39 int width, int height, int format, int rotation, int usage, bool reconnect); 40 void setNativeWindowHdrMetadata( 41 ANativeWindow *nativeWindow /* nonnull */, HDRStaticInfo *info /* nonnull */); 42 status_t setNativeWindowRotation( 43 ANativeWindow *nativeWindow /* nonnull */, int rotation); 44 status_t pushBlankBuffersToNativeWindow(ANativeWindow *nativeWindow /* nonnull */); 45 status_t nativeWindowConnect(ANativeWindow *surface, const char *reason); 46 status_t nativeWindowDisconnect(ANativeWindow *surface, const char *reason); 47 status_t surfaceConnectWithListener(const sp<Surface> &surface, 48 sp<IProducerListener> listener, const char *reason); 49 50 /** 51 * Disable buffer dropping behavior of BufferQueue if target sdk of application 52 * is Q or later. If the caller is not an app (e.g. MediaPlayer in mediaserver) 53 * retain buffer dropping behavior. 54 * 55 * @return NO_ERROR 56 */ 57 status_t disableLegacyBufferDropPostQ(const sp<Surface> &surface); 58 59 } // namespace android 60 61 #endif // SURFACE_UTILS_H_ 62