SlideShare una empresa de Scribd logo
1 de 13
SurfaceFlingerService
(서피스플링거서비스초기화)




                          박철희

                      1
1.Surfaceflinger 전체 구조


                                                     SurfaceFlinger


                                       Client                                      NaitveWindow
  App          SurfacecomposerClient

                                         layer1     OpenGL ES
                     Graphic buffer                 API                           NativeBuffer
                                                                                  Front buffer
                                                                  *EGL
                                         layer2
                                                                                  NativeBuffer

                                          layer3                                   back buffer


Android          mmap으로
                 mapping                                                        mapping

kernel

                                                   FrameBuffer
    Graphic buffer
    공유 메모리
                                                   Front buffer                     Lcd Pannel
                            ……




                                                   back buffer



                                                                         *EGL:Embedded Graphic Library
                                                                                    2
2.SurfaceFlinger 클래스의 인스턴스 생성

 Systemserver.java
 public class SystemServer {
   public static void main(String[] args) {
      System.loadLibrary("android_servers");
       init1(args);
    }
    native public static void init1(String[] args);
 }

  Com_android_server_systemserser.cpp
  static JNINativeMethod gMethods[] = {
     /* name, signature, funcPtr */
     { "init1", "([Ljava/lang/String;)V", (void*) android_server_SystemServer_init1 },
  };

  static void android_server_SystemServer_init1(JNIEnv* env, jobject clazz)
  {
     system_init();
  }



  System_init.cpp
  extern "C" status_t system_init()
  {
    SurfaceFlinger::instantiate();
    SensorService::instantiate();
     jclass clazz = env->FindClass("com/android/server/SystemServer");
     jmethodID methodId = env->GetStaticMethodID(clazz, "init2", "()V");
     env->CallStaticVoidMethod(clazz, methodId);
  }
                                                                                         3
2.SurfaceFlinger 클래스의 인스턴스 생성

                                                           Pthread_create
                                                 2                                3

                                                              Thread

                                         Run()                              _threadLoop()

                Refbase
                                                                 4 1회호출                     5   반복호출
                                    1


                                                     SurfaceFlinger

                          onFirstRef()               ReadyToRun()                ThreadLoop()


RefBase.cpp
void RefBase::incStrong(const void* id) const{

const_cast<RefBase*>(this)->onFirstRef();
}


SurfaceFlinger..cpp
void SurfaceFlinger::onFirstRef()
{
  run("SurfaceFlinger", PRIORITY_URGENT_DISPLAY);
1 // Wait for the main thread to be done with its initialization
  mReadyToRunBarrier.wait();  ReadyToRun 함수에서 mReadyToRunBarrier.open()가 불릴때 까지 기다린다.
}
                                                                                     4
2.SurfaceFlinger 클래스의 인스턴스 생성
Threads.cpp
status_t Thread::run(const char* name, int32_t priority, size_t stack){

res = androidCreateRawThreadEtc
             (_threadLoop,this, name, priority, stack, &mThread);
}
           2

 int androidCreateRawThreadEtc(){

 int result = pthread_create(&thread, &attr,
                (android_pthread_entry)entryFunction, userData);

 }                3


 int Thread::_threadLoop(void* user)
 {
   do {
       bool result;
       if (first) {
           first = false;
           self->mStatus = self->readyToRun();      4
        }
        else{
          result = self->threadLoop();   5
         }
      }
 }


                                                                          5
2.SurfaceFlinger 클래스의 인스턴스 생성-readyToRun()

 SurfacefFlinger.cpp
 status_t SurfaceFlinger::readyToRun()
 (
   1.메인 디스 플레이 초기화
    // initialize the main display
        GraphicPlane& plane(graphicPlane(dpy));
        DisplayHardware* const hw = new DisplayHardware(this, dpy);
        plane.setDisplayHardware(hw);
   2. 디스 플레이 공유 메모리 생성
    // create the shared control-block
    mServerHeap = new MemoryHeapBase(4096, MemoryHeapBase::READ_ONLY, "SurfaceFlinger read-only heap");
    mServerCblk = static_cast<surface_flinger_cblk_t*>(mServerHeap->getBase());
    new(mServerCblk) surface_flinger_cblk_t;
   3. initialize the shared control block
    mServerCblk->connected |= 1<<dpy;
    display_cblk_t* dcblk = mServerCblk->displays + dpy;
    memset(dcblk, 0, sizeof(display_cblk_t));
   4.open GL ES 초기화
     // Initialize OpenGL|ES
    glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
    glPixelStorei(GL_PACK_ALIGNMENT, 4);
    glEnableClientState(GL_VERTEX_ARRAY);
   5.onfirstref()에서 기다리고 있는 thread에 signal 보냄.
     mReadyToRunBarrier.open();
   6.부트 애니메이션 시작
   // start boot animation
    property_set("ctl.start", "bootanim");  /system/bin/bootanimation 프로세스 실행.
 }



                                                                                                6
3.메인 디스플레이 초기화

 1.GraphicPlane& plane(graphicPlane(dpy));
 디스플레이의 정보를 가지는 graphicplane calss를 생성하고 , 0번째 요소를 메인 디스플레이로 설정한다.


  GraphicPlane& plane(graphicPlane(dpy)); //dpy=0;


 GraphicPlane& SurfaceFlinger::graphicPlane(int dpy)
 {
   return const_cast<GraphicPlane&>(const_cast<SurfaceFlinger const *>(this)->graphicPlane(dpy));
 }

     const GraphicPlane& SurfaceFlinger::graphicPlane(int dpy) const
     {
       const GraphicPlane& plane(mGraphicPlanes[dpy]);
       return plane;
     }

 2. DisplayHardware* const hw = new DisplayHardware(this, dpy);
 DisplayHardware를 생성하고, EGL 네이티브 윈도우를 생성하고 초기화 한다.


 DisplayHardware::DisplayHardware(..): DisplayHardwareBase(flinger, dpy),mFlinger(flinger), mFlags(0), mHwc(0)
 {
   init(dpy);
 }

 void DisplayHardware::init(uint32_t dpy)
 {
   mNativeWindow = new FramebufferNativeWindow(); Native window 생성

     //EGL 초기화 수행
 }
                                                                                                                 7
3.메인 디스플레이 초기화

FramebufferNativeWindow::FramebufferNativeWindow()
{
 if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0)
  { gralloc.msm8960.so 를 load해서

  err = framebuffer_open(module, &fbDev);
  framebuffer device를 open하고 framebuffer에 접근할 수 있는 변수를 fbDev에 저장한다.

                         static inline int framebuffer_open(const struct hw_module_t* module,
                               struct framebuffer_device_t** device) {
                            return module->methods->open(module,
                                  GRALLOC_HARDWARE_FB0, (struct hw_device_t**)device);
                         }                   "fb0"

   err = gralloc_open(module, &grDev);
   그래픽 버퍼 할당 device를 open하고 ,device에 접근 할 수 있는 변수를 grDev에 저장한다.

                          tatic inline int gralloc_open(const struct hw_module_t* module,
                                 struct alloc_device_t** device) {
                             return module->methods->open(module,
                                    GRALLOC_HARDWARE_GPU0, (struct hw_device_t**)device);
                          }                  “gpu0”


    for (i = 0; i < mNumBuffers; i++)
    {
                buffers[i] = new NativeBuffer( fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB);
    }
    framebuffer를 가리키는 Nativebuffer 구조체를 생성한다.
                                                                                          Nativebuffer의 그래픽 버퍼가
                                                                                          프레임 버퍼에 매핑되어 있다는 의미
                                                                                                  8
3.메인 디스플레이 초기화

for (i = 0; i < mNumBuffers; i++)                              프레임 버퍼에 메모리를 할당한다는 의미
{
             err = grDev->alloc(grDev,
                   fbDev->width, fbDev->height, fbDev->format,
                   GRALLOC_USAGE_HW_FB, &buffers[i]->handle, &buffers[i]->stride);
}
 Nativebuffer 와 mapping된 framebuffer에 메모리를 할당한다.


ANativeWindow::setSwapInterval = setSwapInterval;  int FramebufferNativeWindow::lockBuffer(..){
ANativeWindow::dequeueBuffer = dequeueBuffer;       framebuffer_device_t* fb = self->fbDev;
ANativeWindow::lockBuffer = lockBuffer;            fb-> lockBuffer(fb, index);
ANativeWindow::queueBuffer = queueBuffer;          }
  …
NativeWindow method와 framebuffer method를 mapping한다.
}

  3. plane.setDisplayHardware(hw);
  생성한 displayHardware의 정보들을 GraphicPlane class에 설정해 준다.(withd,height,orientation)


 void GraphicPlane::setDisplayHardware(DisplayHardware *hw)
 {
    mHw = hw;
   const float w = hw->getWidth();
    const float h = hw->getHeight();
    GraphicPlane::orientationToTransfrom(displayOrientation, w, h,&mDisplayTransform);
 }



                                                                                                  9
4.디스플레이 공유 메모리 생성 및 초기화

1. mServerHeap = new MemoryHeapBase(4096, MemoryHeapBase::READ_ONLY, "SurfaceFlinger read-only heap");
  디스플레이의 정보를 공유할 디스플레이 공유 메모리 생성
2. mServerCblk = static_cast<surface_flinger_cblk_t*>(mServerHeap->getBase());
  생성된 공유 메모리의 시작점을 얻어 옴.
3. new(mServerCblk) surface_flinger_cblk_t;
  시작점에 surface_flinger_cblk_t를 생성하고, mServerCblk 멤버 변수가 가리킴.
4. mServerCblk->connected |= 1<<dpy;
  connected 변수에 연결된 display의 식별번호를 저장(1개인 경우 0x00000001, 두개인 경우 0x00000011)
5. display_cblk_t* dcblk = mServerCblk->displays + dpy;
   memset(dcblk, 0, sizeof(display_cblk_t));
   dcblk->w         = plane.getWidth();
   dcblk->h         = plane.getHeight();
   dcblk->format      = f;
   dcblk->orientation = ISurfaceComposer::eOrientationDefault;
   display_cblk_t 를 생성하고 displayhardware 구조체 value로 초기화 함.


                          디스플레이 공유 메모리

                            surface_flinger_cblk_t                   surfaceflinger

                                  connected                           mServerCblk
                         Dislay_cblk_t dcblk

                           w,h:프레임 버퍼 너비,높이
                                  Density,fps
                               Format,orientation
                                  Xdpi,ydpi


                                                                                              10
참고. Android HAL 구조 분석(Framebuffer_open 분석)

1.Android HAL의 일반적인 구조

                    xxx_module_t                                                                Xxx_device_t


                   hw_module_t                                                                  hw_device_t
                                                                                            Module
         id       Xxx_HARDWARE_MODULE_I
                  D                                                                         close
       methods                                                         생성                              Xxx_close



                                          Xxx_module_methods
                                   open    Xxx_device_open

  Struct xxx_module_t HAL_MODULE_INFO_SYM={                    Static int xxx_device_open(…){
    common:{
       tag:HARDWARE_MODULE_TAG,                                xxx_device_t *dev;
       version_major:1,                                        dev=(xxx_device_t *)malloc(sizeof(xxx_device_t));
       version_minor:0,
       id:xxx_HARDWARE_MODULD_ID,                              dev->common.module=<hw_module_t>(module);
       name:”xxx module”                                       Dev->close=xxx_close
       author:”xxx”
       methods :&xxx_module_medthods                           *device=&dev->device.common;
       }
  }                                                            }

  Static struct hw_module_methods_t xxx_module_methods={
       open:xxx_device_open
   };

                                                                                                      11
참고. Android HAL 구조 분석(Framebuffer_open 분석)

2.framebuffer_open 분석
    if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0)
      {
         err = framebuffer_open(module, &fbDev);             struct private_module_t HAL_MODULE_INFO_SYM = {
    }                                                           base: {
                                                                  common: {
                                                                     tag: HARDWARE_MODULE_TAG,
                                                                     version_major: 1,
static inline int framebuffer_open(const struct hw_module_t*
                                                                     version_minor: 0,
module,
                                                                     id: GRALLOC_HARDWARE_MODULE_ID,
       struct framebuffer_device_t** device) {
                                                                     name: "Graphics Memory Allocator Module",
   return module->methods->open(module,
                                                                     author: "The Android Open Source Project",
          GRALLOC_HARDWARE_FB0, (struct
                                                                     methods: &gralloc_module_methods,
hw_device_t**)device);
                                                                     dso: 0,
}
                                                                     reserved: {0},
                                                                  },


                                                              static struct hw_module_methods_t gralloc_module_methods = {
                                                                 open: gralloc_device_open
                                                              };


int gralloc_device_open(const hw_module_t* module, const char* name,hw_device_t** device)
{
 status = fb_device_open(module, name, device);
}

int fb_device_open(hw_module_t const* module, const char* name,hw_device_t** device){
fb_context_t *dev = (fb_context_t*)malloc(sizeof(*dev));
dev->device.common.module = const_cast<hw_module_t*>(module); dev->device.setSwapInterval = fb_setSwapInterval;
dev->device.common.close = fb_close;                         dev->device.post       = fb_post;
                                                                                                        12
참고. Android HAL 구조 분석(Framebuffer_open 분석)




               private_module_t                                          fb_context_t


             hw_module_t                                                  hw_device_t
                                                                      Module
    id       GRALLOC_HARDWARE_MODULE_
             ID                                                        close
   methods                                                  생성                   fb_close

                                                                 setSwapInterval fb_setSwapInterval

                                                                       post       fb_post
                                  gralloc_module_methods
                            open      gralloc_device_open            dev->device.width;
                                                                     dev->device.height;
                                                                     dev->device.format




                                                                                  13

Más contenido relacionado

La actualidad más candente

T-121-5300 (2008) User Interface Design 10 - UIML
T-121-5300 (2008) User Interface Design 10 - UIMLT-121-5300 (2008) User Interface Design 10 - UIML
T-121-5300 (2008) User Interface Design 10 - UIMLmniemi
 
The OpenCL C++ Wrapper 1.2 Reference Card
The OpenCL C++ Wrapper 1.2 Reference CardThe OpenCL C++ Wrapper 1.2 Reference Card
The OpenCL C++ Wrapper 1.2 Reference CardThe Khronos Group Inc.
 
What's New In Python 2.6
What's New In Python 2.6What's New In Python 2.6
What's New In Python 2.6Richard Jones
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf Conference
 
4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)
4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)
4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)PROIDEA
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuningAOE
 

La actualidad más candente (17)

OpenGL 4.5 Reference Card
OpenGL 4.5 Reference CardOpenGL 4.5 Reference Card
OpenGL 4.5 Reference Card
 
OpenCL 2.0 Reference Card
OpenCL 2.0 Reference CardOpenCL 2.0 Reference Card
OpenCL 2.0 Reference Card
 
OpenCL 2.1 Reference Guide
OpenCL 2.1 Reference GuideOpenCL 2.1 Reference Guide
OpenCL 2.1 Reference Guide
 
T-121-5300 (2008) User Interface Design 10 - UIML
T-121-5300 (2008) User Interface Design 10 - UIMLT-121-5300 (2008) User Interface Design 10 - UIML
T-121-5300 (2008) User Interface Design 10 - UIML
 
OpenCL 1.1 Reference Card
OpenCL 1.1 Reference CardOpenCL 1.1 Reference Card
OpenCL 1.1 Reference Card
 
The OpenCL C++ Wrapper 1.2 Reference Card
The OpenCL C++ Wrapper 1.2 Reference CardThe OpenCL C++ Wrapper 1.2 Reference Card
The OpenCL C++ Wrapper 1.2 Reference Card
 
OpenVG 1.1 Reference Card
OpenVG 1.1 Reference Card OpenVG 1.1 Reference Card
OpenVG 1.1 Reference Card
 
What's New In Python 2.6
What's New In Python 2.6What's New In Python 2.6
What's New In Python 2.6
 
OpenCL Reference Card
OpenCL Reference CardOpenCL Reference Card
OpenCL Reference Card
 
C++ aptitude
C++ aptitudeC++ aptitude
C++ aptitude
 
OpenCL 1.2 Reference Card
OpenCL 1.2 Reference CardOpenCL 1.2 Reference Card
OpenCL 1.2 Reference Card
 
EGL 1.4 Reference Card
EGL 1.4 Reference CardEGL 1.4 Reference Card
EGL 1.4 Reference Card
 
Email Using Plsql
Email Using PlsqlEmail Using Plsql
Email Using Plsql
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
 
4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)
4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)
4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)
 
Email Program By Marcelo
Email Program By MarceloEmail Program By Marcelo
Email Program By Marcelo
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
 

Destacado

Surface flingerservice(서피스플링거서비스초기화 jb)
Surface flingerservice(서피스플링거서비스초기화 jb)Surface flingerservice(서피스플링거서비스초기화 jb)
Surface flingerservice(서피스플링거서비스초기화 jb)fefe7270
 
Surface flingerservice(서피스 상태 변경 및 출력 요청)
Surface flingerservice(서피스 상태 변경 및 출력 요청)Surface flingerservice(서피스 상태 변경 및 출력 요청)
Surface flingerservice(서피스 상태 변경 및 출력 요청)fefe7270
 
Surface flingerservice(서피스 플링거 연결)
Surface flingerservice(서피스 플링거 연결)Surface flingerservice(서피스 플링거 연결)
Surface flingerservice(서피스 플링거 연결)fefe7270
 
Surface flingerservice(서피스플링거서비스초기화 ics)
Surface flingerservice(서피스플링거서비스초기화 ics)Surface flingerservice(서피스플링거서비스초기화 ics)
Surface flingerservice(서피스플링거서비스초기화 ics)fefe7270
 
Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)
Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)
Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)fefe7270
 
Surface flingerservice(서피스 플링거 연결 jb)
Surface flingerservice(서피스 플링거 연결 jb)Surface flingerservice(서피스 플링거 연결 jb)
Surface flingerservice(서피스 플링거 연결 jb)fefe7270
 
Surface flingerservice(서피스 상태 변경 jb)
Surface flingerservice(서피스 상태 변경 jb)Surface flingerservice(서피스 상태 변경 jb)
Surface flingerservice(서피스 상태 변경 jb)fefe7270
 
Surface flingerservice(서피스 출력 요청 jb)
Surface flingerservice(서피스 출력 요청 jb)Surface flingerservice(서피스 출력 요청 jb)
Surface flingerservice(서피스 출력 요청 jb)fefe7270
 
Android audio system(audioflinger)
Android audio system(audioflinger)Android audio system(audioflinger)
Android audio system(audioflinger)fefe7270
 
Android audio system(오디오 플링거 서비스 초기화)
Android audio system(오디오 플링거 서비스 초기화)Android audio system(오디오 플링거 서비스 초기화)
Android audio system(오디오 플링거 서비스 초기화)fefe7270
 
Surface flingerservice(서피스 플링거 연결 ics)
Surface flingerservice(서피스 플링거 연결 ics)Surface flingerservice(서피스 플링거 연결 ics)
Surface flingerservice(서피스 플링거 연결 ics)fefe7270
 
Android audio system(audiopolicy_manager)
Android audio system(audiopolicy_manager)Android audio system(audiopolicy_manager)
Android audio system(audiopolicy_manager)fefe7270
 
Stagefright recorder part1
Stagefright recorder part1Stagefright recorder part1
Stagefright recorder part1fefe7270
 
Android audio system(오디오 출력-트랙생성)
Android audio system(오디오 출력-트랙생성)Android audio system(오디오 출력-트랙생성)
Android audio system(오디오 출력-트랙생성)fefe7270
 
Android audio system(audioplicy_service)
Android audio system(audioplicy_service)Android audio system(audioplicy_service)
Android audio system(audioplicy_service)fefe7270
 
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveAndroid graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveBin Chen
 
Android's Multimedia Framework
Android's Multimedia FrameworkAndroid's Multimedia Framework
Android's Multimedia FrameworkOpersys inc.
 
Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)fefe7270
 

Destacado (19)

Surface flingerservice(서피스플링거서비스초기화 jb)
Surface flingerservice(서피스플링거서비스초기화 jb)Surface flingerservice(서피스플링거서비스초기화 jb)
Surface flingerservice(서피스플링거서비스초기화 jb)
 
Surface flingerservice(서피스 상태 변경 및 출력 요청)
Surface flingerservice(서피스 상태 변경 및 출력 요청)Surface flingerservice(서피스 상태 변경 및 출력 요청)
Surface flingerservice(서피스 상태 변경 및 출력 요청)
 
Surface flingerservice(서피스 플링거 연결)
Surface flingerservice(서피스 플링거 연결)Surface flingerservice(서피스 플링거 연결)
Surface flingerservice(서피스 플링거 연결)
 
Surface flingerservice(서피스플링거서비스초기화 ics)
Surface flingerservice(서피스플링거서비스초기화 ics)Surface flingerservice(서피스플링거서비스초기화 ics)
Surface flingerservice(서피스플링거서비스초기화 ics)
 
Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)
Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)
Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)
 
Surface flingerservice(서피스 플링거 연결 jb)
Surface flingerservice(서피스 플링거 연결 jb)Surface flingerservice(서피스 플링거 연결 jb)
Surface flingerservice(서피스 플링거 연결 jb)
 
Surface flingerservice(서피스 상태 변경 jb)
Surface flingerservice(서피스 상태 변경 jb)Surface flingerservice(서피스 상태 변경 jb)
Surface flingerservice(서피스 상태 변경 jb)
 
Surface flingerservice(서피스 출력 요청 jb)
Surface flingerservice(서피스 출력 요청 jb)Surface flingerservice(서피스 출력 요청 jb)
Surface flingerservice(서피스 출력 요청 jb)
 
Android audio system(audioflinger)
Android audio system(audioflinger)Android audio system(audioflinger)
Android audio system(audioflinger)
 
Android audio system(오디오 플링거 서비스 초기화)
Android audio system(오디오 플링거 서비스 초기화)Android audio system(오디오 플링거 서비스 초기화)
Android audio system(오디오 플링거 서비스 초기화)
 
Surface flingerservice(서피스 플링거 연결 ics)
Surface flingerservice(서피스 플링거 연결 ics)Surface flingerservice(서피스 플링거 연결 ics)
Surface flingerservice(서피스 플링거 연결 ics)
 
Android audio system(audiopolicy_manager)
Android audio system(audiopolicy_manager)Android audio system(audiopolicy_manager)
Android audio system(audiopolicy_manager)
 
Stagefright recorder part1
Stagefright recorder part1Stagefright recorder part1
Stagefright recorder part1
 
Android audio system(오디오 출력-트랙생성)
Android audio system(오디오 출력-트랙생성)Android audio system(오디오 출력-트랙생성)
Android audio system(오디오 출력-트랙생성)
 
Android audio system(audioplicy_service)
Android audio system(audioplicy_service)Android audio system(audioplicy_service)
Android audio system(audioplicy_service)
 
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveAndroid graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
 
Android's Multimedia Framework
Android's Multimedia FrameworkAndroid's Multimedia Framework
Android's Multimedia Framework
 
Design and Concepts of Android Graphics
Design and Concepts of Android GraphicsDesign and Concepts of Android Graphics
Design and Concepts of Android Graphics
 
Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)
 

Similar a Surface flingerservice(서피스플링거서비스초기화)

NativeBoost
NativeBoostNativeBoost
NativeBoostESUG
 
eBPF Tooling and Debugging Infrastructure
eBPF Tooling and Debugging InfrastructureeBPF Tooling and Debugging Infrastructure
eBPF Tooling and Debugging InfrastructureNetronome
 
NativeBoost
NativeBoostNativeBoost
NativeBoostESUG
 
Node.js basics
Node.js basicsNode.js basics
Node.js basicsBen Lin
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015Michiel Borkent
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Xavier Hallade
 
Дмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортДмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортSergey Platonov
 
Implementing new WebAPIs
Implementing new WebAPIsImplementing new WebAPIs
Implementing new WebAPIsJulian Viereck
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)DroidConTLV
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoinknight1128
 
Drizzles Approach To Improving Performance Of The Server
Drizzles  Approach To  Improving  Performance Of The  ServerDrizzles  Approach To  Improving  Performance Of The  Server
Drizzles Approach To Improving Performance Of The ServerPerconaPerformance
 
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...Andrey Karpov
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsAzul Systems, Inc.
 
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17LogeekNightUkraine
 
Cross Platform App Development with C++
Cross Platform App Development with C++Cross Platform App Development with C++
Cross Platform App Development with C++Joan Puig Sanz
 
Talks on adb - Day 2 (pdf version)
Talks on adb - Day 2 (pdf version)Talks on adb - Day 2 (pdf version)
Talks on adb - Day 2 (pdf version)Kangho Kim
 
sponsorAVAST-VB2014
sponsorAVAST-VB2014sponsorAVAST-VB2014
sponsorAVAST-VB2014Martin Hron
 
Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Paris Android User Group
 

Similar a Surface flingerservice(서피스플링거서비스초기화) (20)

NativeBoost
NativeBoostNativeBoost
NativeBoost
 
eBPF Tooling and Debugging Infrastructure
eBPF Tooling and Debugging InfrastructureeBPF Tooling and Debugging Infrastructure
eBPF Tooling and Debugging Infrastructure
 
NativeBoost
NativeBoostNativeBoost
NativeBoost
 
Node.js basics
Node.js basicsNode.js basics
Node.js basics
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)
 
Android ndk
Android ndkAndroid ndk
Android ndk
 
Дмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортДмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репорт
 
Implementing New Web
Implementing New WebImplementing New Web
Implementing New Web
 
Implementing new WebAPIs
Implementing new WebAPIsImplementing new WebAPIs
Implementing new WebAPIs
 
Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)Using the Android Native Development Kit (NDK)
Using the Android Native Development Kit (NDK)
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
 
Drizzles Approach To Improving Performance Of The Server
Drizzles  Approach To  Improving  Performance Of The  ServerDrizzles  Approach To  Improving  Performance Of The  Server
Drizzles Approach To Improving Performance Of The Server
 
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
PVS-Studio 5.00, a solution for developers of modern resource-intensive appl...
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
 
Cross Platform App Development with C++
Cross Platform App Development with C++Cross Platform App Development with C++
Cross Platform App Development with C++
 
Talks on adb - Day 2 (pdf version)
Talks on adb - Day 2 (pdf version)Talks on adb - Day 2 (pdf version)
Talks on adb - Day 2 (pdf version)
 
sponsorAVAST-VB2014
sponsorAVAST-VB2014sponsorAVAST-VB2014
sponsorAVAST-VB2014
 
Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014Using the android ndk - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014
 

Último

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Último (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Surface flingerservice(서피스플링거서비스초기화)

  • 2. 1.Surfaceflinger 전체 구조 SurfaceFlinger Client NaitveWindow App SurfacecomposerClient layer1 OpenGL ES Graphic buffer API NativeBuffer Front buffer *EGL layer2 NativeBuffer layer3 back buffer Android mmap으로 mapping mapping kernel FrameBuffer Graphic buffer 공유 메모리 Front buffer Lcd Pannel …… back buffer *EGL:Embedded Graphic Library 2
  • 3. 2.SurfaceFlinger 클래스의 인스턴스 생성 Systemserver.java public class SystemServer { public static void main(String[] args) { System.loadLibrary("android_servers"); init1(args); } native public static void init1(String[] args); } Com_android_server_systemserser.cpp static JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ { "init1", "([Ljava/lang/String;)V", (void*) android_server_SystemServer_init1 }, }; static void android_server_SystemServer_init1(JNIEnv* env, jobject clazz) { system_init(); } System_init.cpp extern "C" status_t system_init() { SurfaceFlinger::instantiate(); SensorService::instantiate(); jclass clazz = env->FindClass("com/android/server/SystemServer"); jmethodID methodId = env->GetStaticMethodID(clazz, "init2", "()V"); env->CallStaticVoidMethod(clazz, methodId); } 3
  • 4. 2.SurfaceFlinger 클래스의 인스턴스 생성 Pthread_create 2 3 Thread Run() _threadLoop() Refbase 4 1회호출 5 반복호출 1 SurfaceFlinger onFirstRef() ReadyToRun() ThreadLoop() RefBase.cpp void RefBase::incStrong(const void* id) const{ const_cast<RefBase*>(this)->onFirstRef(); } SurfaceFlinger..cpp void SurfaceFlinger::onFirstRef() { run("SurfaceFlinger", PRIORITY_URGENT_DISPLAY); 1 // Wait for the main thread to be done with its initialization mReadyToRunBarrier.wait();  ReadyToRun 함수에서 mReadyToRunBarrier.open()가 불릴때 까지 기다린다. } 4
  • 5. 2.SurfaceFlinger 클래스의 인스턴스 생성 Threads.cpp status_t Thread::run(const char* name, int32_t priority, size_t stack){ res = androidCreateRawThreadEtc (_threadLoop,this, name, priority, stack, &mThread); } 2 int androidCreateRawThreadEtc(){ int result = pthread_create(&thread, &attr, (android_pthread_entry)entryFunction, userData); } 3 int Thread::_threadLoop(void* user) { do { bool result; if (first) { first = false; self->mStatus = self->readyToRun(); 4 } else{ result = self->threadLoop(); 5 } } } 5
  • 6. 2.SurfaceFlinger 클래스의 인스턴스 생성-readyToRun() SurfacefFlinger.cpp status_t SurfaceFlinger::readyToRun() ( 1.메인 디스 플레이 초기화 // initialize the main display GraphicPlane& plane(graphicPlane(dpy)); DisplayHardware* const hw = new DisplayHardware(this, dpy); plane.setDisplayHardware(hw); 2. 디스 플레이 공유 메모리 생성 // create the shared control-block mServerHeap = new MemoryHeapBase(4096, MemoryHeapBase::READ_ONLY, "SurfaceFlinger read-only heap"); mServerCblk = static_cast<surface_flinger_cblk_t*>(mServerHeap->getBase()); new(mServerCblk) surface_flinger_cblk_t; 3. initialize the shared control block mServerCblk->connected |= 1<<dpy; display_cblk_t* dcblk = mServerCblk->displays + dpy; memset(dcblk, 0, sizeof(display_cblk_t)); 4.open GL ES 초기화 // Initialize OpenGL|ES glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glPixelStorei(GL_PACK_ALIGNMENT, 4); glEnableClientState(GL_VERTEX_ARRAY); 5.onfirstref()에서 기다리고 있는 thread에 signal 보냄. mReadyToRunBarrier.open(); 6.부트 애니메이션 시작 // start boot animation property_set("ctl.start", "bootanim");  /system/bin/bootanimation 프로세스 실행. } 6
  • 7. 3.메인 디스플레이 초기화 1.GraphicPlane& plane(graphicPlane(dpy)); 디스플레이의 정보를 가지는 graphicplane calss를 생성하고 , 0번째 요소를 메인 디스플레이로 설정한다. GraphicPlane& plane(graphicPlane(dpy)); //dpy=0; GraphicPlane& SurfaceFlinger::graphicPlane(int dpy) { return const_cast<GraphicPlane&>(const_cast<SurfaceFlinger const *>(this)->graphicPlane(dpy)); } const GraphicPlane& SurfaceFlinger::graphicPlane(int dpy) const { const GraphicPlane& plane(mGraphicPlanes[dpy]); return plane; } 2. DisplayHardware* const hw = new DisplayHardware(this, dpy); DisplayHardware를 생성하고, EGL 네이티브 윈도우를 생성하고 초기화 한다. DisplayHardware::DisplayHardware(..): DisplayHardwareBase(flinger, dpy),mFlinger(flinger), mFlags(0), mHwc(0) { init(dpy); } void DisplayHardware::init(uint32_t dpy) { mNativeWindow = new FramebufferNativeWindow(); Native window 생성 //EGL 초기화 수행 } 7
  • 8. 3.메인 디스플레이 초기화 FramebufferNativeWindow::FramebufferNativeWindow() { if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) { gralloc.msm8960.so 를 load해서 err = framebuffer_open(module, &fbDev); framebuffer device를 open하고 framebuffer에 접근할 수 있는 변수를 fbDev에 저장한다. static inline int framebuffer_open(const struct hw_module_t* module, struct framebuffer_device_t** device) { return module->methods->open(module, GRALLOC_HARDWARE_FB0, (struct hw_device_t**)device); } "fb0" err = gralloc_open(module, &grDev); 그래픽 버퍼 할당 device를 open하고 ,device에 접근 할 수 있는 변수를 grDev에 저장한다. tatic inline int gralloc_open(const struct hw_module_t* module, struct alloc_device_t** device) { return module->methods->open(module, GRALLOC_HARDWARE_GPU0, (struct hw_device_t**)device); } “gpu0” for (i = 0; i < mNumBuffers; i++) { buffers[i] = new NativeBuffer( fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB); } framebuffer를 가리키는 Nativebuffer 구조체를 생성한다. Nativebuffer의 그래픽 버퍼가 프레임 버퍼에 매핑되어 있다는 의미 8
  • 9. 3.메인 디스플레이 초기화 for (i = 0; i < mNumBuffers; i++) 프레임 버퍼에 메모리를 할당한다는 의미 { err = grDev->alloc(grDev, fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB, &buffers[i]->handle, &buffers[i]->stride); }  Nativebuffer 와 mapping된 framebuffer에 메모리를 할당한다. ANativeWindow::setSwapInterval = setSwapInterval; int FramebufferNativeWindow::lockBuffer(..){ ANativeWindow::dequeueBuffer = dequeueBuffer; framebuffer_device_t* fb = self->fbDev; ANativeWindow::lockBuffer = lockBuffer; fb-> lockBuffer(fb, index); ANativeWindow::queueBuffer = queueBuffer; } … NativeWindow method와 framebuffer method를 mapping한다. } 3. plane.setDisplayHardware(hw); 생성한 displayHardware의 정보들을 GraphicPlane class에 설정해 준다.(withd,height,orientation) void GraphicPlane::setDisplayHardware(DisplayHardware *hw) { mHw = hw; const float w = hw->getWidth(); const float h = hw->getHeight(); GraphicPlane::orientationToTransfrom(displayOrientation, w, h,&mDisplayTransform); } 9
  • 10. 4.디스플레이 공유 메모리 생성 및 초기화 1. mServerHeap = new MemoryHeapBase(4096, MemoryHeapBase::READ_ONLY, "SurfaceFlinger read-only heap"); 디스플레이의 정보를 공유할 디스플레이 공유 메모리 생성 2. mServerCblk = static_cast<surface_flinger_cblk_t*>(mServerHeap->getBase()); 생성된 공유 메모리의 시작점을 얻어 옴. 3. new(mServerCblk) surface_flinger_cblk_t; 시작점에 surface_flinger_cblk_t를 생성하고, mServerCblk 멤버 변수가 가리킴. 4. mServerCblk->connected |= 1<<dpy; connected 변수에 연결된 display의 식별번호를 저장(1개인 경우 0x00000001, 두개인 경우 0x00000011) 5. display_cblk_t* dcblk = mServerCblk->displays + dpy; memset(dcblk, 0, sizeof(display_cblk_t)); dcblk->w = plane.getWidth(); dcblk->h = plane.getHeight(); dcblk->format = f; dcblk->orientation = ISurfaceComposer::eOrientationDefault; display_cblk_t 를 생성하고 displayhardware 구조체 value로 초기화 함. 디스플레이 공유 메모리 surface_flinger_cblk_t surfaceflinger connected mServerCblk Dislay_cblk_t dcblk w,h:프레임 버퍼 너비,높이 Density,fps Format,orientation Xdpi,ydpi 10
  • 11. 참고. Android HAL 구조 분석(Framebuffer_open 분석) 1.Android HAL의 일반적인 구조 xxx_module_t Xxx_device_t hw_module_t hw_device_t Module id Xxx_HARDWARE_MODULE_I D close methods 생성 Xxx_close Xxx_module_methods open Xxx_device_open Struct xxx_module_t HAL_MODULE_INFO_SYM={ Static int xxx_device_open(…){ common:{ tag:HARDWARE_MODULE_TAG, xxx_device_t *dev; version_major:1, dev=(xxx_device_t *)malloc(sizeof(xxx_device_t)); version_minor:0, id:xxx_HARDWARE_MODULD_ID, dev->common.module=<hw_module_t>(module); name:”xxx module” Dev->close=xxx_close author:”xxx” methods :&xxx_module_medthods *device=&dev->device.common; } } } Static struct hw_module_methods_t xxx_module_methods={ open:xxx_device_open }; 11
  • 12. 참고. Android HAL 구조 분석(Framebuffer_open 분석) 2.framebuffer_open 분석 if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) { err = framebuffer_open(module, &fbDev); struct private_module_t HAL_MODULE_INFO_SYM = { } base: { common: { tag: HARDWARE_MODULE_TAG, version_major: 1, static inline int framebuffer_open(const struct hw_module_t* version_minor: 0, module, id: GRALLOC_HARDWARE_MODULE_ID, struct framebuffer_device_t** device) { name: "Graphics Memory Allocator Module", return module->methods->open(module, author: "The Android Open Source Project", GRALLOC_HARDWARE_FB0, (struct methods: &gralloc_module_methods, hw_device_t**)device); dso: 0, } reserved: {0}, }, static struct hw_module_methods_t gralloc_module_methods = { open: gralloc_device_open }; int gralloc_device_open(const hw_module_t* module, const char* name,hw_device_t** device) { status = fb_device_open(module, name, device); } int fb_device_open(hw_module_t const* module, const char* name,hw_device_t** device){ fb_context_t *dev = (fb_context_t*)malloc(sizeof(*dev)); dev->device.common.module = const_cast<hw_module_t*>(module); dev->device.setSwapInterval = fb_setSwapInterval; dev->device.common.close = fb_close; dev->device.post = fb_post; 12
  • 13. 참고. Android HAL 구조 분석(Framebuffer_open 분석) private_module_t fb_context_t hw_module_t hw_device_t Module id GRALLOC_HARDWARE_MODULE_ ID close methods 생성 fb_close setSwapInterval fb_setSwapInterval post fb_post gralloc_module_methods open gralloc_device_open dev->device.width; dev->device.height; dev->device.format 13