| Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2007 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_CONTROL_H | 
|  | 18 | #define ANDROID_GUI_SURFACE_CONTROL_H | 
|  | 19 |  | 
|  | 20 | #include <stdint.h> | 
|  | 21 | #include <sys/types.h> | 
|  | 22 |  | 
|  | 23 | #include <utils/KeyedVector.h> | 
|  | 24 | #include <utils/RefBase.h> | 
|  | 25 | #include <utils/threads.h> | 
|  | 26 |  | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 27 | #include <ui/FrameStats.h> | 
| Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 28 | #include <ui/PixelFormat.h> | 
|  | 29 | #include <ui/Region.h> | 
|  | 30 |  | 
| Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 31 | #include <gui/ISurfaceComposerClient.h> | 
|  | 32 |  | 
|  | 33 | namespace android { | 
|  | 34 |  | 
|  | 35 | // --------------------------------------------------------------------------- | 
|  | 36 |  | 
|  | 37 | class IGraphicBufferProducer; | 
|  | 38 | class Surface; | 
|  | 39 | class SurfaceComposerClient; | 
|  | 40 |  | 
|  | 41 | // --------------------------------------------------------------------------- | 
|  | 42 |  | 
|  | 43 | class SurfaceControl : public RefBase | 
|  | 44 | { | 
|  | 45 | public: | 
|  | 46 | static bool isValid(const sp<SurfaceControl>& surface) { | 
|  | 47 | return (surface != 0) && surface->isValid(); | 
|  | 48 | } | 
| Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 49 |  | 
| Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 50 | bool isValid() { | 
| Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 51 | return mHandle!=0 && mClient!=0; | 
| Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 52 | } | 
| Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 53 |  | 
| Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 54 | static bool isSameSurface( | 
|  | 55 | const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs); | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 56 |  | 
| Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 57 | // release surface data from java | 
|  | 58 | void        clear(); | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 59 |  | 
| Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 60 | status_t    setLayerStack(int32_t layerStack); | 
|  | 61 | status_t    setLayer(int32_t layer); | 
| Ramanan Rajeswaran | d6480c0 | 2013-03-21 15:49:59 +0000 | [diff] [blame] | 62 | status_t    setPosition(float x, float y); | 
| Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 63 | status_t    setSize(uint32_t w, uint32_t h); | 
|  | 64 | status_t    hide(); | 
|  | 65 | status_t    show(); | 
|  | 66 | status_t    setFlags(uint32_t flags, uint32_t mask); | 
|  | 67 | status_t    setTransparentRegionHint(const Region& transparent); | 
|  | 68 | status_t    setAlpha(float alpha=1.0f); | 
|  | 69 | status_t    setMatrix(float dsdx, float dtdx, float dsdy, float dtdy); | 
|  | 70 | status_t    setCrop(const Rect& crop); | 
|  | 71 |  | 
|  | 72 | static status_t writeSurfaceToParcel( | 
|  | 73 | const sp<SurfaceControl>& control, Parcel* parcel); | 
|  | 74 |  | 
|  | 75 | sp<Surface> getSurface() const; | 
|  | 76 |  | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 77 | status_t clearLayerFrameStats() const; | 
|  | 78 | status_t getLayerFrameStats(FrameStats* outStats) const; | 
|  | 79 |  | 
| Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 80 | private: | 
|  | 81 | // can't be copied | 
|  | 82 | SurfaceControl& operator = (SurfaceControl& rhs); | 
|  | 83 | SurfaceControl(const SurfaceControl& rhs); | 
|  | 84 |  | 
|  | 85 | friend class SurfaceComposerClient; | 
|  | 86 | friend class Surface; | 
|  | 87 |  | 
|  | 88 | SurfaceControl( | 
|  | 89 | const sp<SurfaceComposerClient>& client, | 
| Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 90 | const sp<IBinder>& handle, | 
|  | 91 | const sp<IGraphicBufferProducer>& gbp); | 
| Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 92 |  | 
|  | 93 | ~SurfaceControl(); | 
|  | 94 |  | 
|  | 95 | status_t validate() const; | 
|  | 96 | void destroy(); | 
| Svetoslav | d85084b | 2014-03-20 10:28:31 -0700 | [diff] [blame] | 97 |  | 
| Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 98 | sp<SurfaceComposerClient>   mClient; | 
| Mathias Agopian | 4d9b822 | 2013-03-12 17:11:48 -0700 | [diff] [blame] | 99 | sp<IBinder>                 mHandle; | 
| Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 100 | sp<IGraphicBufferProducer>  mGraphicBufferProducer; | 
|  | 101 | mutable Mutex               mLock; | 
|  | 102 | mutable sp<Surface>         mSurfaceData; | 
|  | 103 | }; | 
|  | 104 |  | 
|  | 105 | }; // namespace android | 
|  | 106 |  | 
|  | 107 | #endif // ANDROID_GUI_SURFACE_CONTROL_H |