diff options
Diffstat (limited to 'services/surfaceflinger/DisplayHardware')
-rw-r--r-- | services/surfaceflinger/DisplayHardware/FloatRect.h | 42 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayHardware/HWComposer.cpp | 22 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayHardware/HWComposer.h | 3 |
3 files changed, 63 insertions, 4 deletions
diff --git a/services/surfaceflinger/DisplayHardware/FloatRect.h b/services/surfaceflinger/DisplayHardware/FloatRect.h new file mode 100644 index 0000000..b08a951 --- /dev/null +++ b/services/surfaceflinger/DisplayHardware/FloatRect.h @@ -0,0 +1,42 @@ +/* + * Copyright 2013 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. + */ + +#ifndef ANDROID_SF_FLOAT_RECT +#define ANDROID_SF_FLOAT_RECT + +#include <utils/TypeHelpers.h> + +namespace android { + +class FloatRect +{ +public: + float left; + float top; + float right; + float bottom; + + inline FloatRect() { } + inline FloatRect(const Rect& other) + : left(other.left), top(other.top), right(other.right), bottom(other.bottom) { } + + inline float getWidth() const { return right - left; } + inline float getHeight() const { return bottom - top; } +}; + +}; // namespace android + +#endif // ANDROID_SF_FLOAT_RECT diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index 5082192..1cdabc4 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -24,6 +24,7 @@ #include <stdlib.h> #include <string.h> #include <sys/types.h> +#include <math.h> #include <utils/CallStack.h> #include <utils/Errors.h> @@ -880,10 +881,25 @@ public: getLayer()->transform = transform; } virtual void setFrame(const Rect& frame) { - reinterpret_cast<Rect&>(getLayer()->displayFrame) = frame; + getLayer()->displayFrame = reinterpret_cast<hwc_rect_t const&>(frame); } - virtual void setCrop(const Rect& crop) { - reinterpret_cast<Rect&>(getLayer()->sourceCrop) = crop; + virtual void setCrop(const FloatRect& crop) { + if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_3)) { + getLayer()->sourceCropf = reinterpret_cast<hwc_frect_t const&>(crop); + } else { + /* + * Since h/w composer didn't support a flot crop rect before version 1.3, + * using integer coordinates instead produces a different output from the GL code in + * Layer::drawWithOpenGL(). The difference can be large if the buffer crop to + * window size ratio is large and a window crop is defined + * (i.e.: if we scale the buffer a lot and we also crop it with a window crop). + */ + hwc_rect_t& r = getLayer()->sourceCrop; + r.left = int(ceilf(crop.left)); + r.top = int(ceilf(crop.top)); + r.right = int(floorf(crop.right)); + r.bottom= int(floorf(crop.bottom)); + } } virtual void setVisibleRegionScreen(const Region& reg) { // Region::getSharedBuffer creates a reference to the underlying diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h index a20da08..0462bcc 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.h +++ b/services/surfaceflinger/DisplayHardware/HWComposer.h @@ -47,6 +47,7 @@ namespace android { class GraphicBuffer; class Fence; +class FloatRect; class Region; class String8; class SurfaceFlinger; @@ -158,7 +159,7 @@ public: virtual void setBlending(uint32_t blending) = 0; virtual void setTransform(uint32_t transform) = 0; virtual void setFrame(const Rect& frame) = 0; - virtual void setCrop(const Rect& crop) = 0; + virtual void setCrop(const FloatRect& crop) = 0; virtual void setVisibleRegionScreen(const Region& reg) = 0; virtual void setBuffer(const sp<GraphicBuffer>& buffer) = 0; virtual void setAcquireFenceFd(int fenceFd) = 0; |