SurfaceFlingerFactory.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright 2018 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. #pragma once
  17. #include <cinttypes>
  18. #include <functional>
  19. #include <memory>
  20. #include <string>
  21. #include <cutils/compiler.h>
  22. #include <utils/StrongPointer.h>
  23. namespace android {
  24. typedef int32_t PixelFormat;
  25. class BufferQueueLayer;
  26. class BufferStateLayer;
  27. class ColorLayer;
  28. class ContainerLayer;
  29. class DisplayDevice;
  30. class DispSync;
  31. class EventControlThread;
  32. class GraphicBuffer;
  33. class HWComposer;
  34. class IGraphicBufferConsumer;
  35. class IGraphicBufferProducer;
  36. class MessageQueue;
  37. class Scheduler;
  38. class StartPropertySetThread;
  39. class SurfaceFlinger;
  40. class SurfaceInterceptor;
  41. class TimeStats;
  42. struct DisplayDeviceCreationArgs;
  43. struct LayerCreationArgs;
  44. namespace compositionengine {
  45. class CompositionEngine;
  46. } // namespace compositionengine
  47. namespace scheduler {
  48. class PhaseOffsets;
  49. } // namespace scheduler
  50. namespace surfaceflinger {
  51. class NativeWindowSurface;
  52. // The interface that SurfaceFlinger uses to create all of the implementations
  53. // of each interface.
  54. class Factory {
  55. public:
  56. virtual std::unique_ptr<DispSync> createDispSync(const char* name, bool hasSyncFramework,
  57. int64_t dispSyncPresentTimeOffset) = 0;
  58. virtual std::unique_ptr<EventControlThread> createEventControlThread(
  59. std::function<void(bool)> setVSyncEnabled) = 0;
  60. virtual std::unique_ptr<HWComposer> createHWComposer(const std::string& serviceName) = 0;
  61. virtual std::unique_ptr<MessageQueue> createMessageQueue() = 0;
  62. virtual std::unique_ptr<scheduler::PhaseOffsets> createPhaseOffsets() = 0;
  63. virtual std::unique_ptr<Scheduler> createScheduler(
  64. std::function<void(bool)> callback,
  65. const scheduler::RefreshRateConfigs& refreshRateConfig) = 0;
  66. virtual std::unique_ptr<SurfaceInterceptor> createSurfaceInterceptor(SurfaceFlinger*) = 0;
  67. virtual sp<StartPropertySetThread> createStartPropertySetThread(
  68. bool timestampPropertyValue) = 0;
  69. virtual sp<DisplayDevice> createDisplayDevice(DisplayDeviceCreationArgs&&) = 0;
  70. virtual sp<GraphicBuffer> createGraphicBuffer(uint32_t width, uint32_t height,
  71. PixelFormat format, uint32_t layerCount,
  72. uint64_t usage, std::string requestorName) = 0;
  73. virtual void createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
  74. sp<IGraphicBufferConsumer>* outConsumer,
  75. bool consumerIsSurfaceFlinger) = 0;
  76. virtual std::unique_ptr<surfaceflinger::NativeWindowSurface> createNativeWindowSurface(
  77. const sp<IGraphicBufferProducer>&) = 0;
  78. virtual std::unique_ptr<compositionengine::CompositionEngine> createCompositionEngine() = 0;
  79. virtual sp<BufferQueueLayer> createBufferQueueLayer(const LayerCreationArgs& args) = 0;
  80. virtual sp<BufferStateLayer> createBufferStateLayer(const LayerCreationArgs& args) = 0;
  81. virtual sp<ColorLayer> createColorLayer(const LayerCreationArgs& args) = 0;
  82. virtual sp<ContainerLayer> createContainerLayer(const LayerCreationArgs& args) = 0;
  83. virtual std::shared_ptr<TimeStats> createTimeStats() = 0;
  84. protected:
  85. ~Factory() = default;
  86. };
  87. ANDROID_API sp<SurfaceFlinger> createSurfaceFlinger();
  88. } // namespace surfaceflinger
  89. } // namespace android