Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 310 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Android GUI architecture - relation between Surface/view/window/canvas

#1
=========================

UPDATE: After several days googling and [experiments][1], I have found the answers for most of those dumb questions. See the answers I submitted.

=========

What is the responsibility of Android Window?

Here are some questions:

- Is it responsible for collecting and dispatching the input?
- What is the relationship between the view and window? Same as the relationship between surface and window in DFB?
- What is the relationship between an activity and window? Will each Activity has a window?
- Is it possible to create a window from application ? And when it is necessary?
- Does Android support multi-window?


EDIT: Add more questions:

1. What is responsibilities of various class , such as Window, View, Canvas, Surface and how they collaborate with each other?

2. How many windows usually an Activity have?

3.Will all the views in one Activity will be attached to Window?
What does attach mean?

4. Every window have surface? Every Canvas has surface?

5. View is responsible for focus/keyEvent/ manager, while Cavus is only responsible for "drawing" operation.

6. WindowManager is responsible for Window stacking? How that is related with SurfaceFlinger?

7. View doesn't own a Surface , the Window the view contained owns?

8. The View draw itself using canvas got by calling surface.lockCanvas().

9. When onDraw(Canvas) will be called? How & who pass the canvas parameters?

10. Does Canvas has size? Will Window's surface always be full screen?


EDIT again:

After watching this wonderful presentatin provided by Romain Guy , several questions are resolved and add several more :)


1. Will every Activity has one ViewRoot and thus one Window?
2. Is there any need to create a window explictly? and Will the surface for the window always be full screen?
3. Will status bar be in another Window?
4. What is the size of the surface? Will that always be full screen?



[1]:

[To see links please register here]

Reply

#2
Appreciating that you asked all those questions.
1) AFAIK every Activity has alteast one ViewRoot and every ViewRoot has atleast one window
2) There is no need to create window explicitly and I think it should always be full window .. although not sure about this
3) Yes it can be, we can place status bar in another windows
4) Not is can be part of window, not always covers full screen.

Please correct my understanding if I stated anything wrong here.
Reply

#3
> Is Window responsible for collecting and dispatching the input?

No. ViewRoot is responsible for this.

> What is the relationship between the view and window? Same as the
> relationship between surface and window in DFB?

?

> What is the relationship between an activity and window? Will each activity have a window?

Yes, most of the time. However, a SurfaceView has its own window. So, if an Activity has a SurfaceView it will have more than one Window.

> Is it possible to create a window from application? And when it is necessary?

Not necessary.

> Does Android support multi-window?

Sure. Using HierachyView you can clearly see that there is more than one Window exists in the system.

> 1.What are the responsibilities of various classes, such as `Window`, `View`, `Canvas`, `Surface`, and how do they collaborate with each other?
> 2.How many windows usually an Activity have?

Usually one.

> 3.Will all the views in one Activity will be attached to a window? What does attach mean?
> 4.Does every window have a surface? Does every canvas have a surface?

Every Window has a surface and `Surface` uses `Canvas` to draw on the surface.

> 5.View is responsible for managing focus/key events, while Canvas is only responsible for "drawing" operation?

YES.

> 6.`WindowManager` is responsible for Window stacking? How does that relate to `SurfaceFlinger`?

Not Sure of WindowManager's responsibility. (TODO)

`SurfaceFlinger` is used to compose the Surface that is associated with different Window/Activity.

> 7.View doesn't own a Surface, the Window the view contained owns?

View will draw on surface using Canvas. The window the view is attached to owns the surface.

This could be understood by implement a customize view, when you should override the `onDraw(Canvas)` method in your derived class.

> 8.The View draws itself using canvas got by calling surface.lockCanvas()?

YES.

> 9.When and how is `onDraw(Canvas)` called, and who passes the canvas parameters?

`onDraw()` will be called by the `RootView` and when invalidate is called. The canvas parameter is passed from the RootView.

> 10.Does Canvas have a size? Will a Window's surface always be full screen?

I cannot say for sure. But when I create a customize view, the size of the canvas got from onDraw(Canvas) is full screen.

However, in my understanding, for performance sake, the Surface for the window should not always be full screen. But this assumption has not been verified. For example, the statusBar window should not be full screen.

> 1.Will every `Activity` have one `ViewRoot` and thus one `Window`?

YES.

> 2.Is there any need to create a window explicitly? Will the surface for the window always be full screen?

No need to create the Window explicitly per se.

> 3.Will status bar be in another Window?

YES.

> 4.What is the size of the surface? Will that always be full screen?
Reply

#4
[![Android: Window, Surface, Canvas, and Bitmap concept][1]][1]


Here is a very basic and simple conceptual overview of how interaction happens among the Window, Surface, Canvas, and Bitmap.
Look at [this answer][2] by [hackbod][3], great explanation.


[1]:

[2]:

[To see links please register here]

[3]:

[To see links please register here]

Reply

#5
for the question

> What is the relationship between an activity and window? Will each Activity has a window?

disagree with @pierrotlefou ,cause in google [doc](

[To see links please register here]

) SurfaceView provides a dedicated surface, rather than Window.

> The surface is Z ordered so that it is behind the window holding its SurfaceView; the SurfaceView punches a hole in its window to allow its surface to be displayed.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through