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 #ifndef ANDROID_GUI_VIEW_SURFACE_H 18 #define ANDROID_GUI_VIEW_SURFACE_H 19 20 #include <utils/Errors.h> 21 #include <utils/StrongPointer.h> 22 #include <utils/String16.h> 23 24 #include <binder/IBinder.h> 25 #include <binder/Parcelable.h> 26 27 namespace android { 28 29 class IGraphicBufferProducer; 30 31 namespace view { 32 33 /** 34 * A simple holder for an IGraphicBufferProducer, to match the managed-side 35 * android.view.Surface parcelable behavior. 36 * 37 * This implements android/view/Surface.aidl 38 * 39 * TODO: Convert IGraphicBufferProducer into AIDL so that it can be directly 40 * used in managed Binder calls. 41 */ 42 class Surface : public Parcelable { 43 public: 44 45 String16 name; 46 sp<IGraphicBufferProducer> graphicBufferProducer; 47 sp<IBinder> surfaceControlHandle; 48 49 virtual status_t writeToParcel(Parcel* parcel) const override; 50 virtual status_t readFromParcel(const Parcel* parcel) override; 51 52 // nameAlreadyWritten set to true by Surface.java, because it splits 53 // Parceling itself between managed and native code, so it only wants a part 54 // of the full parceling to happen on its native side. 55 status_t writeToParcel(Parcel* parcel, bool nameAlreadyWritten) const; 56 57 // nameAlreadyRead set to true by Surface.java, because it splits 58 // Parceling itself between managed and native code, so it only wants a part 59 // of the full parceling to happen on its native side. 60 status_t readFromParcel(const Parcel* parcel, bool nameAlreadyRead); 61 62 private: 63 64 static String16 readMaybeEmptyString16(const Parcel* parcel); 65 }; 66 67 } // namespace view 68 } // namespace android 69 70 #endif // ANDROID_GUI_VIEW_SURFACE_H 71