2009-03-04 03:31:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-08-02 21:01:42 +00:00
|
|
|
#ifndef ANDROID_DISPLAY_DEVICE_H
|
|
|
|
#define ANDROID_DISPLAY_DEVICE_H
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <ui/PixelFormat.h>
|
|
|
|
#include <ui/Region.h>
|
|
|
|
|
|
|
|
#include <EGL/egl.h>
|
2009-04-10 21:24:30 +00:00
|
|
|
#include <EGL/eglext.h>
|
|
|
|
|
2012-07-25 05:46:10 +00:00
|
|
|
#include <utils/Mutex.h>
|
|
|
|
#include <utils/Timers.h>
|
|
|
|
|
2012-06-21 00:51:20 +00:00
|
|
|
#include "Transform.h"
|
2010-06-26 01:02:21 +00:00
|
|
|
|
2012-08-05 04:39:11 +00:00
|
|
|
struct ANativeWindow;
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
namespace android {
|
|
|
|
|
2012-07-26 01:56:13 +00:00
|
|
|
class DisplayInfo;
|
2012-06-08 00:52:54 +00:00
|
|
|
class FramebufferSurface;
|
2012-07-25 05:46:10 +00:00
|
|
|
class LayerBase;
|
|
|
|
class SurfaceFlinger;
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2012-08-05 08:23:51 +00:00
|
|
|
class DisplayDevice : public LightRefBase<DisplayDevice>
|
2009-03-04 03:31:44 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-07-31 19:38:26 +00:00
|
|
|
// region in layer-stack space
|
|
|
|
mutable Region dirtyRegion;
|
|
|
|
// region in screen space
|
|
|
|
mutable Region swapRegion;
|
|
|
|
// region in screen space
|
|
|
|
Region undefinedRegion;
|
2012-04-04 05:09:52 +00:00
|
|
|
|
2012-08-03 01:32:23 +00:00
|
|
|
enum {
|
|
|
|
DISPLAY_ID_MAIN = 0,
|
2012-08-09 23:29:12 +00:00
|
|
|
DISPLAY_ID_HDMI = 1,
|
|
|
|
DISPLAY_ID_COUNT
|
2012-08-03 01:32:23 +00:00
|
|
|
};
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
enum {
|
2012-07-31 19:38:26 +00:00
|
|
|
PARTIAL_UPDATES = 0x00020000, // video driver feature
|
|
|
|
SWAP_RECTANGLE = 0x00080000,
|
2009-03-04 03:31:44 +00:00
|
|
|
};
|
|
|
|
|
2012-08-01 06:09:07 +00:00
|
|
|
DisplayDevice(
|
2009-03-04 03:31:44 +00:00
|
|
|
const sp<SurfaceFlinger>& flinger,
|
2012-07-12 21:25:33 +00:00
|
|
|
int dpy,
|
2012-08-03 03:11:05 +00:00
|
|
|
const sp<ANativeWindow>& nativeWindow,
|
|
|
|
const sp<FramebufferSurface>& framebufferSurface,
|
2012-07-12 21:25:33 +00:00
|
|
|
EGLConfig config);
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2012-08-05 08:23:51 +00:00
|
|
|
~DisplayDevice();
|
2012-08-03 01:32:23 +00:00
|
|
|
|
|
|
|
// whether this is a valid object. An invalid DisplayDevice is returned
|
|
|
|
// when an non existing id is requested
|
|
|
|
bool isValid() const;
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
// Flip the front and back buffers if the back buffer is "dirty". Might
|
|
|
|
// be instantaneous, might involve copying the frame buffer around.
|
|
|
|
void flip(const Region& dirty) const;
|
|
|
|
|
|
|
|
int getWidth() const;
|
|
|
|
int getHeight() const;
|
|
|
|
PixelFormat getFormat() const;
|
|
|
|
uint32_t getFlags() const;
|
2012-04-04 05:09:52 +00:00
|
|
|
|
2012-07-12 21:25:33 +00:00
|
|
|
EGLSurface getEGLSurface() const;
|
2012-07-11 20:48:17 +00:00
|
|
|
|
|
|
|
void setVisibleLayersSortedByZ(const Vector< sp<LayerBase> >& layers);
|
|
|
|
Vector< sp<LayerBase> > getVisibleLayersSortedByZ() const;
|
|
|
|
bool getSecureLayerVisible() const;
|
|
|
|
|
2012-06-21 00:51:20 +00:00
|
|
|
status_t setOrientation(int orientation);
|
2012-08-09 01:51:15 +00:00
|
|
|
void setLayerStack(uint32_t stack);
|
|
|
|
|
2012-06-21 00:51:20 +00:00
|
|
|
int getOrientation() const { return mOrientation; }
|
|
|
|
const Transform& getTransform() const { return mGlobalTransform; }
|
2012-07-31 19:38:26 +00:00
|
|
|
uint32_t getLayerStack() const { return mLayerStack; }
|
2012-08-09 01:35:12 +00:00
|
|
|
int32_t getDisplayId() const { return mId; }
|
2012-07-31 19:38:26 +00:00
|
|
|
|
2009-09-17 23:18:16 +00:00
|
|
|
status_t compositionComplete() const;
|
|
|
|
|
2011-09-21 00:21:56 +00:00
|
|
|
Rect getBounds() const {
|
2012-06-21 00:51:20 +00:00
|
|
|
return Rect(mDisplayWidth, mDisplayHeight);
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
2011-09-21 00:21:56 +00:00
|
|
|
inline Rect bounds() const { return getBounds(); }
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2012-08-05 07:40:46 +00:00
|
|
|
static void makeCurrent(const sp<const DisplayDevice>& hw, EGLContext ctx);
|
2012-08-01 02:01:53 +00:00
|
|
|
|
2012-08-02 21:01:42 +00:00
|
|
|
/* ------------------------------------------------------------------------
|
|
|
|
* blank / unplank management
|
|
|
|
*/
|
|
|
|
void releaseScreen() const;
|
|
|
|
void acquireScreen() const;
|
|
|
|
bool isScreenAcquired() const;
|
|
|
|
bool canDraw() const;
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------
|
|
|
|
* Debugging
|
|
|
|
*/
|
|
|
|
uint32_t getPageFlipCount() const;
|
|
|
|
void dump(String8& res) const;
|
|
|
|
|
2012-08-03 01:32:23 +00:00
|
|
|
inline bool operator < (const DisplayDevice& rhs) const {
|
|
|
|
return mId < rhs.mId;
|
|
|
|
}
|
2012-08-02 21:01:42 +00:00
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
private:
|
2012-07-12 21:25:33 +00:00
|
|
|
void init(EGLConfig config);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Constants, set during initialization
|
|
|
|
*/
|
2011-08-01 23:32:21 +00:00
|
|
|
sp<SurfaceFlinger> mFlinger;
|
2012-08-03 01:32:23 +00:00
|
|
|
int32_t mId;
|
2012-08-02 21:01:42 +00:00
|
|
|
|
2012-07-12 21:25:33 +00:00
|
|
|
// ANativeWindow this display is rendering into
|
2012-08-05 04:39:11 +00:00
|
|
|
sp<ANativeWindow> mNativeWindow;
|
2012-08-02 21:01:42 +00:00
|
|
|
|
2012-07-12 21:25:33 +00:00
|
|
|
// set if mNativeWindow is a FramebufferSurface
|
|
|
|
sp<FramebufferSurface> mFramebufferSurface;
|
|
|
|
|
2009-03-04 03:31:44 +00:00
|
|
|
EGLDisplay mDisplay;
|
|
|
|
EGLSurface mSurface;
|
|
|
|
EGLContext mContext;
|
2012-06-21 00:51:20 +00:00
|
|
|
int mDisplayWidth;
|
|
|
|
int mDisplayHeight;
|
2009-03-04 03:31:44 +00:00
|
|
|
PixelFormat mFormat;
|
|
|
|
uint32_t mFlags;
|
2009-04-10 21:24:30 +00:00
|
|
|
mutable uint32_t mPageFlipCount;
|
2012-04-26 23:11:59 +00:00
|
|
|
|
2012-07-12 21:25:33 +00:00
|
|
|
/*
|
|
|
|
* Can only accessed from the main thread, these members
|
|
|
|
* don't need synchronization.
|
|
|
|
*/
|
2012-08-02 21:01:42 +00:00
|
|
|
|
2012-07-11 20:48:17 +00:00
|
|
|
// list of visible layers on that display
|
|
|
|
Vector< sp<LayerBase> > mVisibleLayersSortedByZ;
|
2012-08-02 21:01:42 +00:00
|
|
|
|
2012-07-11 20:48:17 +00:00
|
|
|
// Whether we have a visible secure layer on this display
|
|
|
|
bool mSecureLayerVisible;
|
|
|
|
|
2012-08-02 21:01:42 +00:00
|
|
|
// Whether the screen is blanked;
|
|
|
|
mutable int mScreenAcquired;
|
|
|
|
|
2010-08-11 00:14:02 +00:00
|
|
|
|
2012-08-02 21:01:42 +00:00
|
|
|
/*
|
|
|
|
* Transaction state
|
|
|
|
*/
|
2012-06-21 00:51:20 +00:00
|
|
|
static status_t orientationToTransfrom(int orientation, int w, int h,
|
|
|
|
Transform* tr);
|
2012-07-25 04:08:59 +00:00
|
|
|
Transform mGlobalTransform;
|
|
|
|
int mOrientation;
|
2012-07-31 19:38:26 +00:00
|
|
|
uint32_t mLayerStack;
|
2009-03-04 03:31:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace android
|
|
|
|
|
2012-08-02 21:01:42 +00:00
|
|
|
#endif // ANDROID_DISPLAY_DEVICE_H
|