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