SurfaceControl.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #ifndef ANDROID_GUI_SURFACE_CONTROL_H
  17. #define ANDROID_GUI_SURFACE_CONTROL_H
  18. #include <stdint.h>
  19. #include <sys/types.h>
  20. #include <utils/KeyedVector.h>
  21. #include <utils/RefBase.h>
  22. #include <utils/threads.h>
  23. #include <ui/FrameStats.h>
  24. #include <ui/PixelFormat.h>
  25. #include <ui/Region.h>
  26. #include <gui/ISurfaceComposerClient.h>
  27. namespace android {
  28. // ---------------------------------------------------------------------------
  29. class IGraphicBufferProducer;
  30. class Surface;
  31. class SurfaceComposerClient;
  32. // ---------------------------------------------------------------------------
  33. class SurfaceControl : public RefBase
  34. {
  35. public:
  36. static bool isValid(const sp<SurfaceControl>& surface) {
  37. return (surface != 0) && surface->isValid();
  38. }
  39. bool isValid() {
  40. return mHandle!=0 && mClient!=0;
  41. }
  42. static bool isSameSurface(
  43. const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs);
  44. // release surface data from java
  45. void clear();
  46. status_t setLayerStack(uint32_t layerStack);
  47. status_t setLayer(uint32_t layer);
  48. status_t setPosition(float x, float y);
  49. status_t setSize(uint32_t w, uint32_t h);
  50. status_t hide();
  51. status_t show();
  52. status_t setFlags(uint32_t flags, uint32_t mask);
  53. status_t setTransparentRegionHint(const Region& transparent);
  54. status_t setAlpha(float alpha=1.0f);
  55. status_t setMatrix(float dsdx, float dtdx, float dsdy, float dtdy);
  56. status_t setCrop(const Rect& crop);
  57. static status_t writeSurfaceToParcel(
  58. const sp<SurfaceControl>& control, Parcel* parcel);
  59. sp<Surface> getSurface() const;
  60. status_t clearLayerFrameStats() const;
  61. status_t getLayerFrameStats(FrameStats* outStats) const;
  62. status_t setBlur(float blur = 0);
  63. status_t setBlurMaskSurface(const sp<SurfaceControl>& maskSurface);
  64. status_t setBlurMaskSampling(uint32_t blurMaskSampling);
  65. status_t setBlurMaskAlphaThreshold(float alpha);
  66. private:
  67. // can't be copied
  68. SurfaceControl& operator = (SurfaceControl& rhs);
  69. SurfaceControl(const SurfaceControl& rhs);
  70. friend class SurfaceComposerClient;
  71. friend class Surface;
  72. SurfaceControl(
  73. const sp<SurfaceComposerClient>& client,
  74. const sp<IBinder>& handle,
  75. const sp<IGraphicBufferProducer>& gbp);
  76. ~SurfaceControl();
  77. status_t validate() const;
  78. void destroy();
  79. sp<SurfaceComposerClient> mClient;
  80. sp<IBinder> mHandle;
  81. sp<IGraphicBufferProducer> mGraphicBufferProducer;
  82. mutable Mutex mLock;
  83. mutable sp<Surface> mSurfaceData;
  84. };
  85. }; // namespace android
  86. #endif // ANDROID_GUI_SURFACE_CONTROL_H