turn DisplayDevice into a reference-counted object
it's safer this way because this object owns an
EGLSurface which cannot be easily reference-counted.
it also gives us the ability to sub-class it, which
we might want to do soon.
Change-Id: I07358bb052dc5a13b4f2196b2c2b6e6e94c4bb4f
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index f72000f..90e5d9a 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -71,7 +71,7 @@
glGenTextures(1, &mTextureName);
}
-void Layer::onLayerDisplayed(const DisplayDevice& hw,
+void Layer::onLayerDisplayed(const sp<const DisplayDevice>& hw,
HWComposer::HWCLayerInterface* layer) {
if (layer) {
mSurfaceTexture->setReleaseFence(layer->getAndResetReleaseFenceFd());
@@ -237,7 +237,7 @@
}
void Layer::setGeometry(
- const DisplayDevice& hw,
+ const sp<const DisplayDevice>& hw,
HWComposer::HWCLayerInterface& layer)
{
LayerBaseClient::setGeometry(hw, layer);
@@ -260,7 +260,7 @@
*/
const Transform bufferOrientation(mCurrentTransform);
- const Transform tr(hw.getTransform() * s.transform * bufferOrientation);
+ const Transform tr(hw->getTransform() * s.transform * bufferOrientation);
// this gives us only the "orientation" component of the transform
const uint32_t finalTransform = tr.getOrientation();
@@ -274,7 +274,7 @@
layer.setCrop(computeBufferCrop());
}
-void Layer::setPerFrameData(const DisplayDevice& hw,
+void Layer::setPerFrameData(const sp<const DisplayDevice>& hw,
HWComposer::HWCLayerInterface& layer) {
const sp<GraphicBuffer>& buffer(mActiveBuffer);
// NOTE: buffer can be NULL if the client never drew into this
@@ -282,7 +282,7 @@
layer.setBuffer(buffer);
}
-void Layer::setAcquireFence(const DisplayDevice& hw,
+void Layer::setAcquireFence(const sp<const DisplayDevice>& hw,
HWComposer::HWCLayerInterface& layer) {
int fenceFd = -1;
@@ -301,7 +301,7 @@
layer.setAcquireFenceFd(fenceFd);
}
-void Layer::onDraw(const DisplayDevice& hw, const Region& clip) const
+void Layer::onDraw(const sp<const DisplayDevice>& hw, const Region& clip) const
{
ATRACE_CALL();
@@ -323,7 +323,7 @@
const sp<LayerBase>& layer(drawingLayers[i]);
if (layer.get() == static_cast<LayerBase const*>(this))
break;
- under.orSelf( hw.getTransform().transform(layer->visibleRegion) );
+ under.orSelf( hw->getTransform().transform(layer->visibleRegion) );
}
// if not everything below us is covered, we plug the holes!
Region holes(clip.subtract(under));
@@ -728,7 +728,6 @@
{
LayerBaseClient::dumpStats(result, buffer, SIZE);
const size_t o = mFrameLatencyOffset;
- const DisplayDevice& hw(mFlinger->getDefaultDisplayDevice());
const nsecs_t period = mFlinger->getHwComposer().getRefreshPeriod();
result.appendFormat("%lld\n", period);
for (size_t i=0 ; i<128 ; i++) {
@@ -769,8 +768,8 @@
// apply to all displays.
// This is why we use the default display here. This is not an
// oversight.
- const DisplayDevice& hw(mFlinger->getDefaultDisplayDevice());
- const Transform& planeTransform(hw.getTransform());
+ sp<const DisplayDevice> hw(mFlinger->getDefaultDisplayDevice());
+ const Transform& planeTransform(hw->getTransform());
orientation = planeTransform.getOrientation();
if (orientation & Transform::ROT_INVALID) {
orientation = 0;