libui: Enable -Weverything and -Werror
Enables -Weverything and -Werror, with just a few exceptions for warnings we can't (or shouldn't need to) work around. Change-Id: I470a267e9b1c373f2d5c960f005c3b0e02b2db63
This commit is contained in:
parent
456d35b34f
commit
303b9a5123
|
@ -65,7 +65,7 @@ public:
|
||||||
// before the fence signals then -ETIME is returned. A timeout of
|
// before the fence signals then -ETIME is returned. A timeout of
|
||||||
// TIMEOUT_NEVER may be used to indicate that the call should wait
|
// TIMEOUT_NEVER may be used to indicate that the call should wait
|
||||||
// indefinitely for the fence to signal.
|
// indefinitely for the fence to signal.
|
||||||
status_t wait(unsigned int timeout);
|
status_t wait(int timeout);
|
||||||
|
|
||||||
// waitForever is a convenience function for waiting forever for a fence to
|
// waitForever is a convenience function for waiting forever for a fence to
|
||||||
// signal (just like wait(TIMEOUT_NEVER)), but issuing an error to the
|
// signal (just like wait(TIMEOUT_NEVER)), but issuing an error to the
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
USAGE_SW_READ_RARELY = GRALLOC_USAGE_SW_READ_RARELY,
|
USAGE_SW_READ_RARELY = GRALLOC_USAGE_SW_READ_RARELY,
|
||||||
USAGE_SW_READ_OFTEN = GRALLOC_USAGE_SW_READ_OFTEN,
|
USAGE_SW_READ_OFTEN = GRALLOC_USAGE_SW_READ_OFTEN,
|
||||||
USAGE_SW_READ_MASK = GRALLOC_USAGE_SW_READ_MASK,
|
USAGE_SW_READ_MASK = GRALLOC_USAGE_SW_READ_MASK,
|
||||||
|
|
||||||
USAGE_SW_WRITE_NEVER = GRALLOC_USAGE_SW_WRITE_NEVER,
|
USAGE_SW_WRITE_NEVER = GRALLOC_USAGE_SW_WRITE_NEVER,
|
||||||
USAGE_SW_WRITE_RARELY = GRALLOC_USAGE_SW_WRITE_RARELY,
|
USAGE_SW_WRITE_RARELY = GRALLOC_USAGE_SW_WRITE_RARELY,
|
||||||
USAGE_SW_WRITE_OFTEN = GRALLOC_USAGE_SW_WRITE_OFTEN,
|
USAGE_SW_WRITE_OFTEN = GRALLOC_USAGE_SW_WRITE_OFTEN,
|
||||||
|
@ -72,11 +72,13 @@ public:
|
||||||
GraphicBuffer();
|
GraphicBuffer();
|
||||||
|
|
||||||
// creates w * h buffer
|
// creates w * h buffer
|
||||||
GraphicBuffer(int w, int h, PixelFormat format, int usage);
|
GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
|
||||||
|
uint32_t inUsage);
|
||||||
|
|
||||||
// create a buffer from an existing handle
|
// create a buffer from an existing handle
|
||||||
GraphicBuffer(int w, int h, PixelFormat format, int usage,
|
GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
|
||||||
int stride, native_handle_t* handle, bool keepOwnership);
|
uint32_t inUsage, uint32_t inStride, native_handle_t* inHandle,
|
||||||
|
bool keepOwnership);
|
||||||
|
|
||||||
// create a buffer from an existing ANativeWindowBuffer
|
// create a buffer from an existing ANativeWindowBuffer
|
||||||
GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership);
|
GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership);
|
||||||
|
@ -84,26 +86,31 @@ public:
|
||||||
// return status
|
// return status
|
||||||
status_t initCheck() const;
|
status_t initCheck() const;
|
||||||
|
|
||||||
int getWidth() const { return width; }
|
uint32_t getWidth() const { return static_cast<uint32_t>(width); }
|
||||||
int getHeight() const { return height; }
|
uint32_t getHeight() const { return static_cast<uint32_t>(height); }
|
||||||
int getStride() const { return stride; }
|
uint32_t getStride() const { return static_cast<uint32_t>(stride); }
|
||||||
int getUsage() const { return usage; }
|
uint32_t getUsage() const { return static_cast<uint32_t>(usage); }
|
||||||
PixelFormat getPixelFormat() const { return format; }
|
PixelFormat getPixelFormat() const { return format; }
|
||||||
Rect getBounds() const { return Rect(width, height); }
|
Rect getBounds() const { return Rect(width, height); }
|
||||||
uint64_t getId() const { return mId; }
|
uint64_t getId() const { return mId; }
|
||||||
|
|
||||||
status_t reallocate(int w, int h, PixelFormat f, int usage);
|
status_t reallocate(uint32_t inWidth, uint32_t inHeight,
|
||||||
|
PixelFormat inFormat, uint32_t inUsage);
|
||||||
|
|
||||||
status_t lock(uint32_t usage, void** vaddr);
|
status_t lock(uint32_t inUsage, void** vaddr);
|
||||||
status_t lock(uint32_t usage, const Rect& rect, void** vaddr);
|
status_t lock(uint32_t inUsage, const Rect& rect, void** vaddr);
|
||||||
// For HAL_PIXEL_FORMAT_YCbCr_420_888
|
// For HAL_PIXEL_FORMAT_YCbCr_420_888
|
||||||
status_t lockYCbCr(uint32_t usage, android_ycbcr *ycbcr);
|
status_t lockYCbCr(uint32_t inUsage, android_ycbcr *ycbcr);
|
||||||
status_t lockYCbCr(uint32_t usage, const Rect& rect, android_ycbcr *ycbcr);
|
status_t lockYCbCr(uint32_t inUsage, const Rect& rect,
|
||||||
|
android_ycbcr *ycbcr);
|
||||||
status_t unlock();
|
status_t unlock();
|
||||||
status_t lockAsync(uint32_t usage, void** vaddr, int fenceFd);
|
status_t lockAsync(uint32_t inUsage, void** vaddr, int fenceFd);
|
||||||
status_t lockAsync(uint32_t usage, const Rect& rect, void** vaddr, int fenceFd);
|
status_t lockAsync(uint32_t inUsage, const Rect& rect, void** vaddr,
|
||||||
status_t lockAsyncYCbCr(uint32_t usage, android_ycbcr *ycbcr, int fenceFd);
|
int fenceFd);
|
||||||
status_t lockAsyncYCbCr(uint32_t usage, const Rect& rect, android_ycbcr *ycbcr, int fenceFd);
|
status_t lockAsyncYCbCr(uint32_t inUsage, android_ycbcr *ycbcr,
|
||||||
|
int fenceFd);
|
||||||
|
status_t lockAsyncYCbCr(uint32_t inUsage, const Rect& rect,
|
||||||
|
android_ycbcr *ycbcr, int fenceFd);
|
||||||
status_t unlockAsync(int *fenceFd);
|
status_t unlockAsync(int *fenceFd);
|
||||||
|
|
||||||
ANativeWindowBuffer* getNativeBuffer() const;
|
ANativeWindowBuffer* getNativeBuffer() const;
|
||||||
|
@ -143,8 +150,8 @@ private:
|
||||||
GraphicBuffer& operator = (const GraphicBuffer& rhs);
|
GraphicBuffer& operator = (const GraphicBuffer& rhs);
|
||||||
const GraphicBuffer& operator = (const GraphicBuffer& rhs) const;
|
const GraphicBuffer& operator = (const GraphicBuffer& rhs) const;
|
||||||
|
|
||||||
status_t initSize(uint32_t w, uint32_t h, PixelFormat format,
|
status_t initSize(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
|
||||||
uint32_t usage);
|
uint32_t inUsage);
|
||||||
|
|
||||||
void free_handle();
|
void free_handle();
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
**
|
**
|
||||||
** Copyright 2009, The Android Open Source Project
|
** Copyright 2009, The Android Open Source Project
|
||||||
**
|
**
|
||||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
** you may not use this file except in compliance with the License.
|
** you may not use this file except in compliance with the License.
|
||||||
** You may obtain a copy of the License at
|
** You may obtain a copy of the License at
|
||||||
**
|
**
|
||||||
** http://www.apache.org/licenses/LICENSE-2.0
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
**
|
**
|
||||||
** Unless required by applicable law or agreed to in writing, software
|
** Unless required by applicable law or agreed to in writing, software
|
||||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
** See the License for the specific language governing permissions and
|
** See the License for the specific language governing permissions and
|
||||||
** limitations under the License.
|
** limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -45,14 +45,14 @@ public:
|
||||||
USAGE_SW_READ_RARELY = GRALLOC_USAGE_SW_READ_RARELY,
|
USAGE_SW_READ_RARELY = GRALLOC_USAGE_SW_READ_RARELY,
|
||||||
USAGE_SW_READ_OFTEN = GRALLOC_USAGE_SW_READ_OFTEN,
|
USAGE_SW_READ_OFTEN = GRALLOC_USAGE_SW_READ_OFTEN,
|
||||||
USAGE_SW_READ_MASK = GRALLOC_USAGE_SW_READ_MASK,
|
USAGE_SW_READ_MASK = GRALLOC_USAGE_SW_READ_MASK,
|
||||||
|
|
||||||
USAGE_SW_WRITE_NEVER = GRALLOC_USAGE_SW_WRITE_NEVER,
|
USAGE_SW_WRITE_NEVER = GRALLOC_USAGE_SW_WRITE_NEVER,
|
||||||
USAGE_SW_WRITE_RARELY = GRALLOC_USAGE_SW_WRITE_RARELY,
|
USAGE_SW_WRITE_RARELY = GRALLOC_USAGE_SW_WRITE_RARELY,
|
||||||
USAGE_SW_WRITE_OFTEN = GRALLOC_USAGE_SW_WRITE_OFTEN,
|
USAGE_SW_WRITE_OFTEN = GRALLOC_USAGE_SW_WRITE_OFTEN,
|
||||||
USAGE_SW_WRITE_MASK = GRALLOC_USAGE_SW_WRITE_MASK,
|
USAGE_SW_WRITE_MASK = GRALLOC_USAGE_SW_WRITE_MASK,
|
||||||
|
|
||||||
USAGE_SOFTWARE_MASK = USAGE_SW_READ_MASK|USAGE_SW_WRITE_MASK,
|
USAGE_SOFTWARE_MASK = USAGE_SW_READ_MASK|USAGE_SW_WRITE_MASK,
|
||||||
|
|
||||||
USAGE_HW_TEXTURE = GRALLOC_USAGE_HW_TEXTURE,
|
USAGE_HW_TEXTURE = GRALLOC_USAGE_HW_TEXTURE,
|
||||||
USAGE_HW_RENDER = GRALLOC_USAGE_HW_RENDER,
|
USAGE_HW_RENDER = GRALLOC_USAGE_HW_RENDER,
|
||||||
USAGE_HW_2D = GRALLOC_USAGE_HW_2D,
|
USAGE_HW_2D = GRALLOC_USAGE_HW_2D,
|
||||||
|
@ -60,10 +60,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline GraphicBufferAllocator& get() { return getInstance(); }
|
static inline GraphicBufferAllocator& get() { return getInstance(); }
|
||||||
|
|
||||||
|
|
||||||
status_t alloc(uint32_t w, uint32_t h, PixelFormat format, int usage,
|
status_t alloc(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage,
|
||||||
buffer_handle_t* handle, int32_t* stride);
|
buffer_handle_t* handle, uint32_t* stride);
|
||||||
|
|
||||||
status_t free(buffer_handle_t handle);
|
status_t free(buffer_handle_t handle);
|
||||||
|
|
||||||
|
@ -72,21 +71,21 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct alloc_rec_t {
|
struct alloc_rec_t {
|
||||||
uint32_t w;
|
uint32_t width;
|
||||||
uint32_t h;
|
uint32_t height;
|
||||||
uint32_t s;
|
uint32_t stride;
|
||||||
PixelFormat format;
|
PixelFormat format;
|
||||||
uint32_t usage;
|
uint32_t usage;
|
||||||
size_t size;
|
size_t size;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Mutex sLock;
|
static Mutex sLock;
|
||||||
static KeyedVector<buffer_handle_t, alloc_rec_t> sAllocList;
|
static KeyedVector<buffer_handle_t, alloc_rec_t> sAllocList;
|
||||||
|
|
||||||
friend class Singleton<GraphicBufferAllocator>;
|
friend class Singleton<GraphicBufferAllocator>;
|
||||||
GraphicBufferAllocator();
|
GraphicBufferAllocator();
|
||||||
~GraphicBufferAllocator();
|
~GraphicBufferAllocator();
|
||||||
|
|
||||||
alloc_device_t *mAllocDev;
|
alloc_device_t *mAllocDev;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,23 +41,24 @@ public:
|
||||||
status_t registerBuffer(buffer_handle_t handle);
|
status_t registerBuffer(buffer_handle_t handle);
|
||||||
|
|
||||||
status_t unregisterBuffer(buffer_handle_t handle);
|
status_t unregisterBuffer(buffer_handle_t handle);
|
||||||
|
|
||||||
status_t lock(buffer_handle_t handle,
|
status_t lock(buffer_handle_t handle,
|
||||||
int usage, const Rect& bounds, void** vaddr);
|
uint32_t usage, const Rect& bounds, void** vaddr);
|
||||||
|
|
||||||
status_t lockYCbCr(buffer_handle_t handle,
|
status_t lockYCbCr(buffer_handle_t handle,
|
||||||
int usage, const Rect& bounds, android_ycbcr *ycbcr);
|
uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr);
|
||||||
|
|
||||||
status_t unlock(buffer_handle_t handle);
|
status_t unlock(buffer_handle_t handle);
|
||||||
|
|
||||||
status_t lockAsync(buffer_handle_t handle,
|
status_t lockAsync(buffer_handle_t handle,
|
||||||
int usage, const Rect& bounds, void** vaddr, int fenceFd);
|
uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd);
|
||||||
|
|
||||||
status_t lockAsyncYCbCr(buffer_handle_t handle,
|
status_t lockAsyncYCbCr(buffer_handle_t handle,
|
||||||
int usage, const Rect& bounds, android_ycbcr *ycbcr, int fenceFd);
|
uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr,
|
||||||
|
int fenceFd);
|
||||||
|
|
||||||
status_t unlockAsync(buffer_handle_t handle, int *fenceFd);
|
status_t unlockAsync(buffer_handle_t handle, int *fenceFd);
|
||||||
|
|
||||||
// dumps information about the mapping of this handle
|
// dumps information about the mapping of this handle
|
||||||
void dump(buffer_handle_t handle);
|
void dump(buffer_handle_t handle);
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,6 @@
|
||||||
#ifndef UI_PIXELFORMAT_H
|
#ifndef UI_PIXELFORMAT_H
|
||||||
#define UI_PIXELFORMAT_H
|
#define UI_PIXELFORMAT_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <utils/Errors.h>
|
|
||||||
#include <hardware/hardware.h>
|
#include <hardware/hardware.h>
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
@ -69,8 +66,8 @@ enum {
|
||||||
|
|
||||||
typedef int32_t PixelFormat;
|
typedef int32_t PixelFormat;
|
||||||
|
|
||||||
ssize_t bytesPerPixel(PixelFormat format);
|
uint32_t bytesPerPixel(PixelFormat format);
|
||||||
ssize_t bitsPerPixel(PixelFormat format);
|
uint32_t bitsPerPixel(PixelFormat format);
|
||||||
|
|
||||||
}; // namespace android
|
}; // namespace android
|
||||||
|
|
||||||
|
|
|
@ -55,11 +55,11 @@ public:
|
||||||
|
|
||||||
// the region becomes its bounds
|
// the region becomes its bounds
|
||||||
Region& makeBoundsSelf();
|
Region& makeBoundsSelf();
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void set(const Rect& r);
|
void set(const Rect& r);
|
||||||
void set(uint32_t w, uint32_t h);
|
void set(int32_t w, int32_t h);
|
||||||
|
|
||||||
Region& orSelf(const Rect& rhs);
|
Region& orSelf(const Rect& rhs);
|
||||||
Region& xorSelf(const Rect& rhs);
|
Region& xorSelf(const Rect& rhs);
|
||||||
Region& andSelf(const Rect& rhs);
|
Region& andSelf(const Rect& rhs);
|
||||||
|
@ -110,14 +110,14 @@ public:
|
||||||
inline Region& operator -= (const Region& rhs);
|
inline Region& operator -= (const Region& rhs);
|
||||||
inline Region& operator += (const Point& pt);
|
inline Region& operator += (const Point& pt);
|
||||||
|
|
||||||
|
|
||||||
// returns true if the regions share the same underlying storage
|
// returns true if the regions share the same underlying storage
|
||||||
bool isTriviallyEqual(const Region& region) const;
|
bool isTriviallyEqual(const Region& region) const;
|
||||||
|
|
||||||
|
|
||||||
/* various ways to access the rectangle list */
|
/* various ways to access the rectangle list */
|
||||||
|
|
||||||
|
|
||||||
// STL-like iterators
|
// STL-like iterators
|
||||||
typedef Rect const* const_iterator;
|
typedef Rect const* const_iterator;
|
||||||
const_iterator begin() const;
|
const_iterator begin() const;
|
||||||
|
@ -133,7 +133,7 @@ public:
|
||||||
SharedBuffer const* getSharedBuffer(size_t* count) const;
|
SharedBuffer const* getSharedBuffer(size_t* count) const;
|
||||||
|
|
||||||
/* no user serviceable parts here... */
|
/* no user serviceable parts here... */
|
||||||
|
|
||||||
// add a rectangle to the internal list. This rectangle must
|
// add a rectangle to the internal list. This rectangle must
|
||||||
// be sorted in Y and X and must not make the region invalid.
|
// be sorted in Y and X and must not make the region invalid.
|
||||||
void addRectUnchecked(int l, int t, int r, int b);
|
void addRectUnchecked(int l, int t, int r, int b);
|
||||||
|
@ -149,7 +149,7 @@ public:
|
||||||
private:
|
private:
|
||||||
class rasterizer;
|
class rasterizer;
|
||||||
friend class rasterizer;
|
friend class rasterizer;
|
||||||
|
|
||||||
Region& operationSelf(const Rect& r, int op);
|
Region& operationSelf(const Rect& r, int op);
|
||||||
Region& operationSelf(const Region& r, int op);
|
Region& operationSelf(const Region& r, int op);
|
||||||
Region& operationSelf(const Region& r, int dx, int dy, int op);
|
Region& operationSelf(const Region& r, int dx, int dy, int op);
|
||||||
|
@ -172,7 +172,7 @@ private:
|
||||||
|
|
||||||
static bool validate(const Region& reg,
|
static bool validate(const Region& reg,
|
||||||
const char* name, bool silent = false);
|
const char* name, bool silent = false);
|
||||||
|
|
||||||
// mStorage is a (manually) sorted array of Rects describing the region
|
// mStorage is a (manually) sorted array of Rects describing the region
|
||||||
// with an extra Rect as the last element which is set to the
|
// with an extra Rect as the last element which is set to the
|
||||||
// bounds of the region. However, if the region is
|
// bounds of the region. However, if the region is
|
||||||
|
|
|
@ -16,7 +16,19 @@ LOCAL_PATH := $(call my-dir)
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_CLANG := true
|
LOCAL_CLANG := true
|
||||||
LOCAL_CPPFLAGS := -std=c++11
|
LOCAL_CPPFLAGS := -std=c++1y -Weverything -Werror
|
||||||
|
|
||||||
|
# The static constructors and destructors in this library have not been noted to
|
||||||
|
# introduce significant overheads
|
||||||
|
LOCAL_CPPFLAGS += -Wno-exit-time-destructors
|
||||||
|
LOCAL_CPPFLAGS += -Wno-global-constructors
|
||||||
|
|
||||||
|
# We only care about compiling as C++14
|
||||||
|
LOCAL_CPPFLAGS += -Wno-c++98-compat-pedantic
|
||||||
|
|
||||||
|
# We use four-character constants for the GraphicBuffer header, and don't care
|
||||||
|
# that they're non-portable as long as they're consistent within one execution
|
||||||
|
LOCAL_CPPFLAGS += -Wno-four-char-constants
|
||||||
|
|
||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := \
|
||||||
Fence.cpp \
|
Fence.cpp \
|
||||||
|
|
|
@ -18,10 +18,13 @@
|
||||||
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
|
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
|
||||||
//#define LOG_NDEBUG 0
|
//#define LOG_NDEBUG 0
|
||||||
|
|
||||||
// This is needed for stdint.h to define INT64_MAX in C++
|
// We would eliminate the non-conforming zero-length array, but we can't since
|
||||||
#define __STDC_LIMIT_MACROS
|
// this is effectively included from the Linux kernel
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wzero-length-array"
|
||||||
#include <sync/sync.h>
|
#include <sync/sync.h>
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
#include <ui/Fence.h>
|
#include <ui/Fence.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
@ -45,7 +48,7 @@ Fence::~Fence() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t Fence::wait(unsigned int timeout) {
|
status_t Fence::wait(int timeout) {
|
||||||
ATRACE_CALL();
|
ATRACE_CALL();
|
||||||
if (mFenceFd == -1) {
|
if (mFenceFd == -1) {
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
|
@ -59,7 +62,7 @@ status_t Fence::waitForever(const char* logname) {
|
||||||
if (mFenceFd == -1) {
|
if (mFenceFd == -1) {
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
unsigned int warningTimeout = 3000;
|
int warningTimeout = 3000;
|
||||||
int err = sync_wait(mFenceFd, warningTimeout);
|
int err = sync_wait(mFenceFd, warningTimeout);
|
||||||
if (err < 0 && errno == ETIME) {
|
if (err < 0 && errno == ETIME) {
|
||||||
ALOGE("%s: fence %d didn't signal in %u ms", logname, mFenceFd,
|
ALOGE("%s: fence %d didn't signal in %u ms", logname, mFenceFd,
|
||||||
|
@ -138,7 +141,7 @@ status_t Fence::flatten(void*& buffer, size_t& size, int*& fds, size_t& count) c
|
||||||
if (size < getFlattenedSize() || count < getFdCount()) {
|
if (size < getFlattenedSize() || count < getFdCount()) {
|
||||||
return NO_MEMORY;
|
return NO_MEMORY;
|
||||||
}
|
}
|
||||||
FlattenableUtils::write(buffer, size, (uint32_t)getFdCount());
|
FlattenableUtils::write(buffer, size, getFdCount());
|
||||||
if (isValid()) {
|
if (isValid()) {
|
||||||
*fds++ = mFenceFd;
|
*fds++ = mFenceFd;
|
||||||
count--;
|
count--;
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
**
|
**
|
||||||
** Copyright 2007 The Android Open Source Project
|
** Copyright 2007 The Android Open Source Project
|
||||||
**
|
**
|
||||||
** Licensed under the Apache License Version 2.0(the "License");
|
** Licensed under the Apache License Version 2.0(the "License");
|
||||||
** you may not use this file except in compliance with the License.
|
** you may not use this file except in compliance with the License.
|
||||||
** You may obtain a copy of the License at
|
** You may obtain a copy of the License at
|
||||||
**
|
**
|
||||||
** http://www.apache.org/licenses/LICENSE-2.0
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
**
|
**
|
||||||
** Unless required by applicable law or agreed to in writing software
|
** Unless required by applicable law or agreed to in writing software
|
||||||
** distributed under the License is distributed on an "AS IS" BASIS
|
** distributed under the License is distributed on an "AS IS" BASIS
|
||||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
|
||||||
** See the License for the specific language governing permissions and
|
** See the License for the specific language governing permissions and
|
||||||
** limitations under the License.
|
** limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -43,11 +43,11 @@
|
||||||
namespace android {
|
namespace android {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class NativeBuffer
|
class NativeBuffer final
|
||||||
: public ANativeObjectBase<
|
: public ANativeObjectBase<
|
||||||
ANativeWindowBuffer,
|
ANativeWindowBuffer,
|
||||||
NativeBuffer,
|
NativeBuffer,
|
||||||
LightRefBase<NativeBuffer> >
|
LightRefBase<NativeBuffer>>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NativeBuffer(int w, int h, int f, int u) : BASE() {
|
NativeBuffer(int w, int h, int f, int u) : BASE() {
|
||||||
|
@ -57,24 +57,23 @@ public:
|
||||||
ANativeWindowBuffer::usage = u;
|
ANativeWindowBuffer::usage = u;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
friend class LightRefBase<NativeBuffer>;
|
friend class LightRefBase<NativeBuffer>;
|
||||||
~NativeBuffer() { }; // this class cannot be overloaded
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This implements the (main) framebuffer management. This class is used
|
* This implements the (main) framebuffer management. This class is used
|
||||||
* mostly by SurfaceFlinger, but also by command line GL application.
|
* mostly by SurfaceFlinger, but also by command line GL application.
|
||||||
*
|
*
|
||||||
* In fact this is an implementation of ANativeWindow on top of
|
* In fact this is an implementation of ANativeWindow on top of
|
||||||
* the framebuffer.
|
* the framebuffer.
|
||||||
*
|
*
|
||||||
* Currently it is pretty simple, it manages only two buffers (the front and
|
* Currently it is pretty simple, it manages only two buffers (the front and
|
||||||
* back buffer).
|
* back buffer).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FramebufferNativeWindow::FramebufferNativeWindow()
|
FramebufferNativeWindow::FramebufferNativeWindow()
|
||||||
: BASE(), fbDev(0), grDev(0), mUpdateOnDemand(false)
|
: BASE(), fbDev(0), grDev(0), mUpdateOnDemand(false)
|
||||||
{
|
{
|
||||||
hw_module_t const* module;
|
hw_module_t const* module;
|
||||||
|
@ -84,16 +83,16 @@ FramebufferNativeWindow::FramebufferNativeWindow()
|
||||||
int i;
|
int i;
|
||||||
err = framebuffer_open(module, &fbDev);
|
err = framebuffer_open(module, &fbDev);
|
||||||
ALOGE_IF(err, "couldn't open framebuffer HAL (%s)", strerror(-err));
|
ALOGE_IF(err, "couldn't open framebuffer HAL (%s)", strerror(-err));
|
||||||
|
|
||||||
err = gralloc_open(module, &grDev);
|
err = gralloc_open(module, &grDev);
|
||||||
ALOGE_IF(err, "couldn't open gralloc HAL (%s)", strerror(-err));
|
ALOGE_IF(err, "couldn't open gralloc HAL (%s)", strerror(-err));
|
||||||
|
|
||||||
// bail out if we can't initialize the modules
|
// bail out if we can't initialize the modules
|
||||||
if (!fbDev || !grDev)
|
if (!fbDev || !grDev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mUpdateOnDemand = (fbDev->setUpdateRect != 0);
|
mUpdateOnDemand = (fbDev->setUpdateRect != 0);
|
||||||
|
|
||||||
// initialize the buffer FIFO
|
// initialize the buffer FIFO
|
||||||
if(fbDev->numFramebuffers >= MIN_NUM_FRAME_BUFFERS &&
|
if(fbDev->numFramebuffers >= MIN_NUM_FRAME_BUFFERS &&
|
||||||
fbDev->numFramebuffers <= MAX_NUM_FRAME_BUFFERS){
|
fbDev->numFramebuffers <= MAX_NUM_FRAME_BUFFERS){
|
||||||
|
@ -116,36 +115,37 @@ FramebufferNativeWindow::FramebufferNativeWindow()
|
||||||
*((uint32_t *)&fbDev->format) = FRAMEBUFFER_FORCE_FORMAT;
|
*((uint32_t *)&fbDev->format) = FRAMEBUFFER_FORCE_FORMAT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < mNumBuffers; i++)
|
for (i = 0; i < mNumBuffers; i++) {
|
||||||
{
|
buffers[i] = new NativeBuffer(
|
||||||
buffers[i] = new NativeBuffer(
|
static_cast<int>(fbDev->width),
|
||||||
fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB);
|
static_cast<int>(fbDev->height),
|
||||||
|
fbDev->format, GRALLOC_USAGE_HW_FB);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < mNumBuffers; i++)
|
for (i = 0; i < mNumBuffers; i++) {
|
||||||
{
|
err = grDev->alloc(grDev,
|
||||||
err = grDev->alloc(grDev,
|
static_cast<int>(fbDev->width),
|
||||||
fbDev->width, fbDev->height, fbDev->format,
|
static_cast<int>(fbDev->height),
|
||||||
GRALLOC_USAGE_HW_FB, &buffers[i]->handle, &buffers[i]->stride);
|
fbDev->format, GRALLOC_USAGE_HW_FB,
|
||||||
|
&buffers[i]->handle, &buffers[i]->stride);
|
||||||
|
|
||||||
ALOGE_IF(err, "fb buffer %d allocation failed w=%d, h=%d, err=%s",
|
ALOGE_IF(err, "fb buffer %d allocation failed w=%d, h=%d, err=%s",
|
||||||
i, fbDev->width, fbDev->height, strerror(-err));
|
i, fbDev->width, fbDev->height, strerror(-err));
|
||||||
|
|
||||||
if (err)
|
if (err) {
|
||||||
{
|
mNumBuffers = i;
|
||||||
mNumBuffers = i;
|
mNumFreeBuffers = i;
|
||||||
mNumFreeBuffers = i;
|
mBufferHead = mNumBuffers-1;
|
||||||
mBufferHead = mNumBuffers-1;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags;
|
const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags;
|
||||||
const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi;
|
const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi;
|
||||||
const_cast<float&>(ANativeWindow::ydpi) = fbDev->ydpi;
|
const_cast<float&>(ANativeWindow::ydpi) = fbDev->ydpi;
|
||||||
const_cast<int&>(ANativeWindow::minSwapInterval) =
|
const_cast<int&>(ANativeWindow::minSwapInterval) =
|
||||||
fbDev->minSwapInterval;
|
fbDev->minSwapInterval;
|
||||||
const_cast<int&>(ANativeWindow::maxSwapInterval) =
|
const_cast<int&>(ANativeWindow::maxSwapInterval) =
|
||||||
fbDev->maxSwapInterval;
|
fbDev->maxSwapInterval;
|
||||||
} else {
|
} else {
|
||||||
ALOGE("Couldn't get gralloc module");
|
ALOGE("Couldn't get gralloc module");
|
||||||
|
@ -162,7 +162,7 @@ FramebufferNativeWindow::FramebufferNativeWindow()
|
||||||
ANativeWindow::queueBuffer_DEPRECATED = queueBuffer_DEPRECATED;
|
ANativeWindow::queueBuffer_DEPRECATED = queueBuffer_DEPRECATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
FramebufferNativeWindow::~FramebufferNativeWindow()
|
FramebufferNativeWindow::~FramebufferNativeWindow()
|
||||||
{
|
{
|
||||||
if (grDev) {
|
if (grDev) {
|
||||||
for(int i = 0; i < mNumBuffers; i++) {
|
for(int i = 0; i < mNumBuffers; i++) {
|
||||||
|
@ -178,7 +178,7 @@ FramebufferNativeWindow::~FramebufferNativeWindow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t FramebufferNativeWindow::setUpdateRectangle(const Rect& r)
|
status_t FramebufferNativeWindow::setUpdateRectangle(const Rect& r)
|
||||||
{
|
{
|
||||||
if (!mUpdateOnDemand) {
|
if (!mUpdateOnDemand) {
|
||||||
return INVALID_OPERATION;
|
return INVALID_OPERATION;
|
||||||
|
@ -195,7 +195,7 @@ status_t FramebufferNativeWindow::compositionComplete()
|
||||||
}
|
}
|
||||||
|
|
||||||
int FramebufferNativeWindow::setSwapInterval(
|
int FramebufferNativeWindow::setSwapInterval(
|
||||||
ANativeWindow* window, int interval)
|
ANativeWindow* window, int interval)
|
||||||
{
|
{
|
||||||
framebuffer_device_t* fb = getSelf(window)->fbDev;
|
framebuffer_device_t* fb = getSelf(window)->fbDev;
|
||||||
return fb->setSwapInterval(fb, interval);
|
return fb->setSwapInterval(fb, interval);
|
||||||
|
@ -219,7 +219,7 @@ int FramebufferNativeWindow::getCurrentBufferIndex() const
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FramebufferNativeWindow::dequeueBuffer_DEPRECATED(ANativeWindow* window,
|
int FramebufferNativeWindow::dequeueBuffer_DEPRECATED(ANativeWindow* window,
|
||||||
ANativeWindowBuffer** buffer)
|
ANativeWindowBuffer** buffer)
|
||||||
{
|
{
|
||||||
int fenceFd = -1;
|
int fenceFd = -1;
|
||||||
|
@ -234,7 +234,7 @@ int FramebufferNativeWindow::dequeueBuffer_DEPRECATED(ANativeWindow* window,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window,
|
int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window,
|
||||||
ANativeWindowBuffer** buffer, int* fenceFd)
|
ANativeWindowBuffer** buffer, int* fenceFd)
|
||||||
{
|
{
|
||||||
FramebufferNativeWindow* self = getSelf(window);
|
FramebufferNativeWindow* self = getSelf(window);
|
||||||
|
@ -249,7 +249,7 @@ int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window,
|
||||||
while (self->mNumFreeBuffers < 2) {
|
while (self->mNumFreeBuffers < 2) {
|
||||||
self->mCondition.wait(self->mutex);
|
self->mCondition.wait(self->mutex);
|
||||||
}
|
}
|
||||||
ALOG_ASSERT(self->buffers[index] != self->front);
|
ALOG_ASSERT(self->buffers[index] != self->front, "");
|
||||||
|
|
||||||
// get this buffer
|
// get this buffer
|
||||||
self->mNumFreeBuffers--;
|
self->mNumFreeBuffers--;
|
||||||
|
@ -261,19 +261,19 @@ int FramebufferNativeWindow::dequeueBuffer(ANativeWindow* window,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FramebufferNativeWindow::lockBuffer_DEPRECATED(ANativeWindow* /*window*/,
|
int FramebufferNativeWindow::lockBuffer_DEPRECATED(ANativeWindow* /*window*/,
|
||||||
ANativeWindowBuffer* /*buffer*/)
|
ANativeWindowBuffer* /*buffer*/)
|
||||||
{
|
{
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FramebufferNativeWindow::queueBuffer_DEPRECATED(ANativeWindow* window,
|
int FramebufferNativeWindow::queueBuffer_DEPRECATED(ANativeWindow* window,
|
||||||
ANativeWindowBuffer* buffer)
|
ANativeWindowBuffer* buffer)
|
||||||
{
|
{
|
||||||
return queueBuffer(window, buffer, -1);
|
return queueBuffer(window, buffer, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FramebufferNativeWindow::queueBuffer(ANativeWindow* window,
|
int FramebufferNativeWindow::queueBuffer(ANativeWindow* window,
|
||||||
ANativeWindowBuffer* buffer, int fenceFd)
|
ANativeWindowBuffer* buffer, int fenceFd)
|
||||||
{
|
{
|
||||||
FramebufferNativeWindow* self = getSelf(window);
|
FramebufferNativeWindow* self = getSelf(window);
|
||||||
|
@ -293,17 +293,17 @@ int FramebufferNativeWindow::queueBuffer(ANativeWindow* window,
|
||||||
}
|
}
|
||||||
|
|
||||||
int FramebufferNativeWindow::query(const ANativeWindow* window,
|
int FramebufferNativeWindow::query(const ANativeWindow* window,
|
||||||
int what, int* value)
|
int what, int* value)
|
||||||
{
|
{
|
||||||
const FramebufferNativeWindow* self = getSelf(window);
|
const FramebufferNativeWindow* self = getSelf(window);
|
||||||
Mutex::Autolock _l(self->mutex);
|
Mutex::Autolock _l(self->mutex);
|
||||||
framebuffer_device_t* fb = self->fbDev;
|
framebuffer_device_t* fb = self->fbDev;
|
||||||
switch (what) {
|
switch (what) {
|
||||||
case NATIVE_WINDOW_WIDTH:
|
case NATIVE_WINDOW_WIDTH:
|
||||||
*value = fb->width;
|
*value = static_cast<int>(fb->width);
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
case NATIVE_WINDOW_HEIGHT:
|
case NATIVE_WINDOW_HEIGHT:
|
||||||
*value = fb->height;
|
*value = static_cast<int>(fb->height);
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
case NATIVE_WINDOW_FORMAT:
|
case NATIVE_WINDOW_FORMAT:
|
||||||
*value = fb->format;
|
*value = fb->format;
|
||||||
|
@ -315,10 +315,10 @@ int FramebufferNativeWindow::query(const ANativeWindow* window,
|
||||||
*value = 0;
|
*value = 0;
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
case NATIVE_WINDOW_DEFAULT_WIDTH:
|
case NATIVE_WINDOW_DEFAULT_WIDTH:
|
||||||
*value = fb->width;
|
*value = static_cast<int>(fb->width);
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
case NATIVE_WINDOW_DEFAULT_HEIGHT:
|
case NATIVE_WINDOW_DEFAULT_HEIGHT:
|
||||||
*value = fb->height;
|
*value = static_cast<int>(fb->height);
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
case NATIVE_WINDOW_TRANSFORM_HINT:
|
case NATIVE_WINDOW_TRANSFORM_HINT:
|
||||||
*value = 0;
|
*value = 0;
|
||||||
|
@ -359,7 +359,8 @@ int FramebufferNativeWindow::perform(ANativeWindow* /*window*/,
|
||||||
}; // namespace android
|
}; // namespace android
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
using namespace android;
|
using android::sp;
|
||||||
|
using android::FramebufferNativeWindow;
|
||||||
|
|
||||||
EGLNativeWindowType android_createDisplaySurface(void)
|
EGLNativeWindowType android_createDisplaySurface(void)
|
||||||
{
|
{
|
||||||
|
@ -370,5 +371,5 @@ EGLNativeWindowType android_createDisplaySurface(void)
|
||||||
sp<FramebufferNativeWindow> ref(w);
|
sp<FramebufferNativeWindow> ref(w);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (EGLNativeWindowType)w;
|
return static_cast<EGLNativeWindowType>(w);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,8 @@ GraphicBuffer::GraphicBuffer()
|
||||||
handle = NULL;
|
handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicBuffer::GraphicBuffer(int w, int h, PixelFormat reqFormat, int reqUsage)
|
GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight,
|
||||||
|
PixelFormat inFormat, uint32_t inUsage)
|
||||||
: BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()),
|
: BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()),
|
||||||
mInitCheck(NO_ERROR), mId(getUniqueId())
|
mInitCheck(NO_ERROR), mId(getUniqueId())
|
||||||
{
|
{
|
||||||
|
@ -63,20 +64,21 @@ GraphicBuffer::GraphicBuffer(int w, int h, PixelFormat reqFormat, int reqUsage)
|
||||||
format =
|
format =
|
||||||
usage = 0;
|
usage = 0;
|
||||||
handle = NULL;
|
handle = NULL;
|
||||||
mInitCheck = initSize(w, h, reqFormat, reqUsage);
|
mInitCheck = initSize(inWidth, inHeight, inFormat, inUsage);
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicBuffer::GraphicBuffer(int w, int h, PixelFormat inFormat, int inUsage,
|
GraphicBuffer::GraphicBuffer(uint32_t inWidth, uint32_t inHeight,
|
||||||
int inStride, native_handle_t* inHandle, bool keepOwnership)
|
PixelFormat inFormat, uint32_t inUsage, uint32_t inStride,
|
||||||
|
native_handle_t* inHandle, bool keepOwnership)
|
||||||
: BASE(), mOwner(keepOwnership ? ownHandle : ownNone),
|
: BASE(), mOwner(keepOwnership ? ownHandle : ownNone),
|
||||||
mBufferMapper(GraphicBufferMapper::get()),
|
mBufferMapper(GraphicBufferMapper::get()),
|
||||||
mInitCheck(NO_ERROR), mId(getUniqueId())
|
mInitCheck(NO_ERROR), mId(getUniqueId())
|
||||||
{
|
{
|
||||||
width = w;
|
width = static_cast<int>(inWidth);
|
||||||
height = h;
|
height = static_cast<int>(inHeight);
|
||||||
stride = inStride;
|
stride = static_cast<int>(inStride);
|
||||||
format = inFormat;
|
format = inFormat;
|
||||||
usage = inUsage;
|
usage = static_cast<int>(inUsage);
|
||||||
handle = inHandle;
|
handle = inHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,12 +131,17 @@ ANativeWindowBuffer* GraphicBuffer::getNativeBuffer() const
|
||||||
const_cast<GraphicBuffer*>(this));
|
const_cast<GraphicBuffer*>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBuffer::reallocate(int w, int h, PixelFormat f, int reqUsage)
|
status_t GraphicBuffer::reallocate(uint32_t inWidth, uint32_t inHeight,
|
||||||
|
PixelFormat inFormat, uint32_t inUsage)
|
||||||
{
|
{
|
||||||
if (mOwner != ownData)
|
if (mOwner != ownData)
|
||||||
return INVALID_OPERATION;
|
return INVALID_OPERATION;
|
||||||
|
|
||||||
if (handle && w==width && h==height && f==format && reqUsage==usage)
|
if (handle &&
|
||||||
|
static_cast<int>(inWidth) == width &&
|
||||||
|
static_cast<int>(inHeight) == height &&
|
||||||
|
inFormat == format &&
|
||||||
|
static_cast<int>(inUsage) == usage)
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
|
|
||||||
if (handle) {
|
if (handle) {
|
||||||
|
@ -142,61 +149,64 @@ status_t GraphicBuffer::reallocate(int w, int h, PixelFormat f, int reqUsage)
|
||||||
allocator.free(handle);
|
allocator.free(handle);
|
||||||
handle = 0;
|
handle = 0;
|
||||||
}
|
}
|
||||||
return initSize(w, h, f, reqUsage);
|
return initSize(inWidth, inHeight, inFormat, inUsage);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBuffer::initSize(uint32_t w, uint32_t h, PixelFormat format,
|
status_t GraphicBuffer::initSize(uint32_t inWidth, uint32_t inHeight,
|
||||||
uint32_t reqUsage)
|
PixelFormat inFormat, uint32_t inUsage)
|
||||||
{
|
{
|
||||||
GraphicBufferAllocator& allocator = GraphicBufferAllocator::get();
|
GraphicBufferAllocator& allocator = GraphicBufferAllocator::get();
|
||||||
status_t err = allocator.alloc(w, h, format, reqUsage, &handle, &stride);
|
uint32_t outStride = 0;
|
||||||
|
status_t err = allocator.alloc(inWidth, inHeight, inFormat, inUsage,
|
||||||
|
&handle, &outStride);
|
||||||
if (err == NO_ERROR) {
|
if (err == NO_ERROR) {
|
||||||
this->width = w;
|
width = static_cast<int>(inWidth);
|
||||||
this->height = h;
|
height = static_cast<int>(inHeight);
|
||||||
this->format = format;
|
format = inFormat;
|
||||||
this->usage = reqUsage;
|
usage = static_cast<int>(inUsage);
|
||||||
|
stride = static_cast<int>(outStride);
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBuffer::lock(uint32_t usage, void** vaddr)
|
status_t GraphicBuffer::lock(uint32_t inUsage, void** vaddr)
|
||||||
{
|
{
|
||||||
const Rect lockBounds(width, height);
|
const Rect lockBounds(width, height);
|
||||||
status_t res = lock(usage, lockBounds, vaddr);
|
status_t res = lock(inUsage, lockBounds, vaddr);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBuffer::lock(uint32_t usage, const Rect& rect, void** vaddr)
|
status_t GraphicBuffer::lock(uint32_t inUsage, const Rect& rect, void** vaddr)
|
||||||
{
|
{
|
||||||
if (rect.left < 0 || rect.right > this->width ||
|
if (rect.left < 0 || rect.right > width ||
|
||||||
rect.top < 0 || rect.bottom > this->height) {
|
rect.top < 0 || rect.bottom > height) {
|
||||||
ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
|
ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
|
||||||
rect.left, rect.top, rect.right, rect.bottom,
|
rect.left, rect.top, rect.right, rect.bottom,
|
||||||
this->width, this->height);
|
width, height);
|
||||||
return BAD_VALUE;
|
return BAD_VALUE;
|
||||||
}
|
}
|
||||||
status_t res = getBufferMapper().lock(handle, usage, rect, vaddr);
|
status_t res = getBufferMapper().lock(handle, inUsage, rect, vaddr);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBuffer::lockYCbCr(uint32_t usage, android_ycbcr *ycbcr)
|
status_t GraphicBuffer::lockYCbCr(uint32_t inUsage, android_ycbcr* ycbcr)
|
||||||
{
|
{
|
||||||
const Rect lockBounds(width, height);
|
const Rect lockBounds(width, height);
|
||||||
status_t res = lockYCbCr(usage, lockBounds, ycbcr);
|
status_t res = lockYCbCr(inUsage, lockBounds, ycbcr);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBuffer::lockYCbCr(uint32_t usage, const Rect& rect,
|
status_t GraphicBuffer::lockYCbCr(uint32_t inUsage, const Rect& rect,
|
||||||
android_ycbcr *ycbcr)
|
android_ycbcr* ycbcr)
|
||||||
{
|
{
|
||||||
if (rect.left < 0 || rect.right > this->width ||
|
if (rect.left < 0 || rect.right > width ||
|
||||||
rect.top < 0 || rect.bottom > this->height) {
|
rect.top < 0 || rect.bottom > height) {
|
||||||
ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
|
ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
|
||||||
rect.left, rect.top, rect.right, rect.bottom,
|
rect.left, rect.top, rect.right, rect.bottom,
|
||||||
this->width, this->height);
|
width, height);
|
||||||
return BAD_VALUE;
|
return BAD_VALUE;
|
||||||
}
|
}
|
||||||
status_t res = getBufferMapper().lockYCbCr(handle, usage, rect, ycbcr);
|
status_t res = getBufferMapper().lockYCbCr(handle, inUsage, rect, ycbcr);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,43 +216,48 @@ status_t GraphicBuffer::unlock()
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBuffer::lockAsync(uint32_t usage, void** vaddr, int fenceFd)
|
status_t GraphicBuffer::lockAsync(uint32_t inUsage, void** vaddr, int fenceFd)
|
||||||
{
|
{
|
||||||
const Rect lockBounds(width, height);
|
const Rect lockBounds(width, height);
|
||||||
status_t res = lockAsync(usage, lockBounds, vaddr, fenceFd);
|
status_t res = lockAsync(inUsage, lockBounds, vaddr, fenceFd);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBuffer::lockAsync(uint32_t usage, const Rect& rect, void** vaddr, int fenceFd)
|
status_t GraphicBuffer::lockAsync(uint32_t inUsage, const Rect& rect,
|
||||||
|
void** vaddr, int fenceFd)
|
||||||
{
|
{
|
||||||
if (rect.left < 0 || rect.right > this->width ||
|
if (rect.left < 0 || rect.right > width ||
|
||||||
rect.top < 0 || rect.bottom > this->height) {
|
rect.top < 0 || rect.bottom > height) {
|
||||||
ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
|
ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
|
||||||
rect.left, rect.top, rect.right, rect.bottom,
|
rect.left, rect.top, rect.right, rect.bottom,
|
||||||
this->width, this->height);
|
width, height);
|
||||||
return BAD_VALUE;
|
return BAD_VALUE;
|
||||||
}
|
}
|
||||||
status_t res = getBufferMapper().lockAsync(handle, usage, rect, vaddr, fenceFd);
|
status_t res = getBufferMapper().lockAsync(handle, inUsage, rect, vaddr,
|
||||||
|
fenceFd);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBuffer::lockAsyncYCbCr(uint32_t usage, android_ycbcr *ycbcr, int fenceFd)
|
status_t GraphicBuffer::lockAsyncYCbCr(uint32_t inUsage, android_ycbcr* ycbcr,
|
||||||
|
int fenceFd)
|
||||||
{
|
{
|
||||||
const Rect lockBounds(width, height);
|
const Rect lockBounds(width, height);
|
||||||
status_t res = lockAsyncYCbCr(usage, lockBounds, ycbcr, fenceFd);
|
status_t res = lockAsyncYCbCr(inUsage, lockBounds, ycbcr, fenceFd);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBuffer::lockAsyncYCbCr(uint32_t usage, const Rect& rect, android_ycbcr *ycbcr, int fenceFd)
|
status_t GraphicBuffer::lockAsyncYCbCr(uint32_t inUsage, const Rect& rect,
|
||||||
|
android_ycbcr* ycbcr, int fenceFd)
|
||||||
{
|
{
|
||||||
if (rect.left < 0 || rect.right > this->width ||
|
if (rect.left < 0 || rect.right > width ||
|
||||||
rect.top < 0 || rect.bottom > this->height) {
|
rect.top < 0 || rect.bottom > height) {
|
||||||
ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
|
ALOGE("locking pixels (%d,%d,%d,%d) outside of buffer (w=%d, h=%d)",
|
||||||
rect.left, rect.top, rect.right, rect.bottom,
|
rect.left, rect.top, rect.right, rect.bottom,
|
||||||
this->width, this->height);
|
width, height);
|
||||||
return BAD_VALUE;
|
return BAD_VALUE;
|
||||||
}
|
}
|
||||||
status_t res = getBufferMapper().lockAsyncYCbCr(handle, usage, rect, ycbcr, fenceFd);
|
status_t res = getBufferMapper().lockAsyncYCbCr(handle, inUsage, rect,
|
||||||
|
ycbcr, fenceFd);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,11 +268,11 @@ status_t GraphicBuffer::unlockAsync(int *fenceFd)
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GraphicBuffer::getFlattenedSize() const {
|
size_t GraphicBuffer::getFlattenedSize() const {
|
||||||
return (10 + (handle ? handle->numInts : 0))*sizeof(int);
|
return static_cast<size_t>(10 + (handle ? handle->numInts : 0)) * sizeof(int);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GraphicBuffer::getFdCount() const {
|
size_t GraphicBuffer::getFdCount() const {
|
||||||
return handle ? handle->numFds : 0;
|
return static_cast<size_t>(handle ? handle->numFds : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBuffer::flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const {
|
status_t GraphicBuffer::flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const {
|
||||||
|
@ -282,16 +297,17 @@ status_t GraphicBuffer::flatten(void*& buffer, size_t& size, int*& fds, size_t&
|
||||||
if (handle) {
|
if (handle) {
|
||||||
buf[8] = handle->numFds;
|
buf[8] = handle->numFds;
|
||||||
buf[9] = handle->numInts;
|
buf[9] = handle->numInts;
|
||||||
native_handle_t const* const h = handle;
|
memcpy(fds, handle->data,
|
||||||
memcpy(fds, h->data, h->numFds*sizeof(int));
|
static_cast<size_t>(handle->numFds) * sizeof(int));
|
||||||
memcpy(&buf[10], h->data + h->numFds, h->numInts*sizeof(int));
|
memcpy(&buf[10], handle->data + handle->numFds,
|
||||||
|
static_cast<size_t>(handle->numInts) * sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = reinterpret_cast<void*>(static_cast<int*>(buffer) + sizeNeeded);
|
buffer = reinterpret_cast<void*>(static_cast<int*>(buffer) + sizeNeeded);
|
||||||
size -= sizeNeeded;
|
size -= sizeNeeded;
|
||||||
if (handle) {
|
if (handle) {
|
||||||
fds += handle->numFds;
|
fds += handle->numFds;
|
||||||
count -= handle->numFds;
|
count -= static_cast<size_t>(handle->numFds);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
|
@ -304,8 +320,8 @@ status_t GraphicBuffer::unflatten(
|
||||||
int const* buf = static_cast<int const*>(buffer);
|
int const* buf = static_cast<int const*>(buffer);
|
||||||
if (buf[0] != 'GBFR') return BAD_TYPE;
|
if (buf[0] != 'GBFR') return BAD_TYPE;
|
||||||
|
|
||||||
const size_t numFds = buf[8];
|
const size_t numFds = static_cast<size_t>(buf[8]);
|
||||||
const size_t numInts = buf[9];
|
const size_t numInts = static_cast<size_t>(buf[9]);
|
||||||
|
|
||||||
const size_t maxNumber = UINT_MAX / sizeof(int);
|
const size_t maxNumber = UINT_MAX / sizeof(int);
|
||||||
if (numFds >= maxNumber || numInts >= (maxNumber - 10)) {
|
if (numFds >= maxNumber || numInts >= (maxNumber - 10)) {
|
||||||
|
@ -333,15 +349,16 @@ status_t GraphicBuffer::unflatten(
|
||||||
stride = buf[3];
|
stride = buf[3];
|
||||||
format = buf[4];
|
format = buf[4];
|
||||||
usage = buf[5];
|
usage = buf[5];
|
||||||
native_handle* h = native_handle_create(numFds, numInts);
|
native_handle* h = native_handle_create(
|
||||||
|
static_cast<int>(numFds), static_cast<int>(numInts));
|
||||||
if (!h) {
|
if (!h) {
|
||||||
width = height = stride = format = usage = 0;
|
width = height = stride = format = usage = 0;
|
||||||
handle = NULL;
|
handle = NULL;
|
||||||
ALOGE("unflatten: native_handle_create failed");
|
ALOGE("unflatten: native_handle_create failed");
|
||||||
return NO_MEMORY;
|
return NO_MEMORY;
|
||||||
}
|
}
|
||||||
memcpy(h->data, fds, numFds*sizeof(int));
|
memcpy(h->data, fds, numFds * sizeof(int));
|
||||||
memcpy(h->data + numFds, &buf[10], numInts*sizeof(int));
|
memcpy(h->data + numFds, &buf[10], numInts * sizeof(int));
|
||||||
handle = h;
|
handle = h;
|
||||||
} else {
|
} else {
|
||||||
width = height = stride = format = usage = 0;
|
width = height = stride = format = usage = 0;
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/*
|
/*
|
||||||
**
|
**
|
||||||
** Copyright 2009, The Android Open Source Project
|
** Copyright 2009, The Android Open Source Project
|
||||||
**
|
**
|
||||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
** you may not use this file except in compliance with the License.
|
** you may not use this file except in compliance with the License.
|
||||||
** You may obtain a copy of the License at
|
** You may obtain a copy of the License at
|
||||||
**
|
**
|
||||||
** http://www.apache.org/licenses/LICENSE-2.0
|
** http://www.apache.org/licenses/LICENSE-2.0
|
||||||
**
|
**
|
||||||
** Unless required by applicable law or agreed to in writing, software
|
** Unless required by applicable law or agreed to in writing, software
|
||||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
** See the License for the specific language governing permissions and
|
** See the License for the specific language governing permissions and
|
||||||
** limitations under the License.
|
** limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -66,11 +66,11 @@ void GraphicBufferAllocator::dump(String8& result) const
|
||||||
if (rec.size) {
|
if (rec.size) {
|
||||||
snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %8X | 0x%08x\n",
|
snprintf(buffer, SIZE, "%10p: %7.2f KiB | %4u (%4u) x %4u | %8X | 0x%08x\n",
|
||||||
list.keyAt(i), rec.size/1024.0f,
|
list.keyAt(i), rec.size/1024.0f,
|
||||||
rec.w, rec.s, rec.h, rec.format, rec.usage);
|
rec.width, rec.stride, rec.height, rec.format, rec.usage);
|
||||||
} else {
|
} else {
|
||||||
snprintf(buffer, SIZE, "%10p: unknown | %4u (%4u) x %4u | %8X | 0x%08x\n",
|
snprintf(buffer, SIZE, "%10p: unknown | %4u (%4u) x %4u | %8X | 0x%08x\n",
|
||||||
list.keyAt(i),
|
list.keyAt(i),
|
||||||
rec.w, rec.s, rec.h, rec.format, rec.usage);
|
rec.width, rec.stride, rec.height, rec.format, rec.usage);
|
||||||
}
|
}
|
||||||
result.append(buffer);
|
result.append(buffer);
|
||||||
total += rec.size;
|
total += rec.size;
|
||||||
|
@ -90,39 +90,40 @@ void GraphicBufferAllocator::dumpToSystemLog()
|
||||||
ALOGD("%s", s.string());
|
ALOGD("%s", s.string());
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBufferAllocator::alloc(uint32_t w, uint32_t h, PixelFormat format,
|
status_t GraphicBufferAllocator::alloc(uint32_t width, uint32_t height,
|
||||||
int usage, buffer_handle_t* handle, int32_t* stride)
|
PixelFormat format, uint32_t usage, buffer_handle_t* handle,
|
||||||
|
uint32_t* stride)
|
||||||
{
|
{
|
||||||
ATRACE_CALL();
|
ATRACE_CALL();
|
||||||
|
|
||||||
// make sure to not allocate a N x 0 or 0 x N buffer, since this is
|
// make sure to not allocate a N x 0 or 0 x N buffer, since this is
|
||||||
// allowed from an API stand-point allocate a 1x1 buffer instead.
|
// allowed from an API stand-point allocate a 1x1 buffer instead.
|
||||||
if (!w || !h)
|
if (!width || !height)
|
||||||
w = h = 1;
|
width = height = 1;
|
||||||
|
|
||||||
// we have a h/w allocator and h/w buffer is requested
|
// we have a h/w allocator and h/w buffer is requested
|
||||||
status_t err;
|
status_t err;
|
||||||
|
|
||||||
err = mAllocDev->alloc(mAllocDev, w, h, format, usage, handle, stride);
|
int outStride = 0;
|
||||||
|
err = mAllocDev->alloc(mAllocDev, static_cast<int>(width),
|
||||||
|
static_cast<int>(height), format, static_cast<int>(usage), handle,
|
||||||
|
&outStride);
|
||||||
|
*stride = static_cast<uint32_t>(outStride);
|
||||||
|
|
||||||
ALOGW_IF(err, "alloc(%u, %u, %d, %08x, ...) failed %d (%s)",
|
ALOGW_IF(err, "alloc(%u, %u, %d, %08x, ...) failed %d (%s)",
|
||||||
w, h, format, usage, err, strerror(-err));
|
width, height, format, usage, err, strerror(-err));
|
||||||
|
|
||||||
if (err == NO_ERROR) {
|
if (err == NO_ERROR) {
|
||||||
Mutex::Autolock _l(sLock);
|
Mutex::Autolock _l(sLock);
|
||||||
KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList);
|
KeyedVector<buffer_handle_t, alloc_rec_t>& list(sAllocList);
|
||||||
int bpp = bytesPerPixel(format);
|
uint32_t bpp = bytesPerPixel(format);
|
||||||
if (bpp < 0) {
|
|
||||||
// probably a HAL custom format. in any case, we don't know
|
|
||||||
// what its pixel size is.
|
|
||||||
bpp = 0;
|
|
||||||
}
|
|
||||||
alloc_rec_t rec;
|
alloc_rec_t rec;
|
||||||
rec.w = w;
|
rec.width = width;
|
||||||
rec.h = h;
|
rec.height = height;
|
||||||
rec.s = *stride;
|
rec.stride = *stride;
|
||||||
rec.format = format;
|
rec.format = format;
|
||||||
rec.usage = usage;
|
rec.usage = usage;
|
||||||
rec.size = h * stride[0] * bpp;
|
rec.size = static_cast<size_t>(height * (*stride) * bpp);
|
||||||
list.add(*handle, rec);
|
list.add(*handle, rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,12 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
// We would eliminate the non-conforming zero-length array, but we can't since
|
||||||
|
// this is effectively included from the Linux kernel
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wzero-length-array"
|
||||||
#include <sync/sync.h>
|
#include <sync/sync.h>
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
#include <utils/Errors.h>
|
#include <utils/Errors.h>
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
@ -44,7 +49,7 @@ GraphicBufferMapper::GraphicBufferMapper()
|
||||||
int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
|
int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
|
||||||
ALOGE_IF(err, "FATAL: can't find the %s module", GRALLOC_HARDWARE_MODULE_ID);
|
ALOGE_IF(err, "FATAL: can't find the %s module", GRALLOC_HARDWARE_MODULE_ID);
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
mAllocMod = (gralloc_module_t const *)module;
|
mAllocMod = reinterpret_cast<gralloc_module_t const *>(module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,13 +77,13 @@ status_t GraphicBufferMapper::unregisterBuffer(buffer_handle_t handle)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBufferMapper::lock(buffer_handle_t handle,
|
status_t GraphicBufferMapper::lock(buffer_handle_t handle,
|
||||||
int usage, const Rect& bounds, void** vaddr)
|
uint32_t usage, const Rect& bounds, void** vaddr)
|
||||||
{
|
{
|
||||||
ATRACE_CALL();
|
ATRACE_CALL();
|
||||||
status_t err;
|
status_t err;
|
||||||
|
|
||||||
err = mAllocMod->lock(mAllocMod, handle, usage,
|
err = mAllocMod->lock(mAllocMod, handle, static_cast<int>(usage),
|
||||||
bounds.left, bounds.top, bounds.width(), bounds.height(),
|
bounds.left, bounds.top, bounds.width(), bounds.height(),
|
||||||
vaddr);
|
vaddr);
|
||||||
|
|
||||||
|
@ -87,12 +92,12 @@ status_t GraphicBufferMapper::lock(buffer_handle_t handle,
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBufferMapper::lockYCbCr(buffer_handle_t handle,
|
status_t GraphicBufferMapper::lockYCbCr(buffer_handle_t handle,
|
||||||
int usage, const Rect& bounds, android_ycbcr *ycbcr)
|
uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr)
|
||||||
{
|
{
|
||||||
ATRACE_CALL();
|
ATRACE_CALL();
|
||||||
status_t err;
|
status_t err;
|
||||||
|
|
||||||
err = mAllocMod->lock_ycbcr(mAllocMod, handle, usage,
|
err = mAllocMod->lock_ycbcr(mAllocMod, handle, static_cast<int>(usage),
|
||||||
bounds.left, bounds.top, bounds.width(), bounds.height(),
|
bounds.left, bounds.top, bounds.width(), bounds.height(),
|
||||||
ycbcr);
|
ycbcr);
|
||||||
|
|
||||||
|
@ -112,19 +117,19 @@ status_t GraphicBufferMapper::unlock(buffer_handle_t handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBufferMapper::lockAsync(buffer_handle_t handle,
|
status_t GraphicBufferMapper::lockAsync(buffer_handle_t handle,
|
||||||
int usage, const Rect& bounds, void** vaddr, int fenceFd)
|
uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd)
|
||||||
{
|
{
|
||||||
ATRACE_CALL();
|
ATRACE_CALL();
|
||||||
status_t err;
|
status_t err;
|
||||||
|
|
||||||
if (mAllocMod->common.module_api_version >= GRALLOC_MODULE_API_VERSION_0_3) {
|
if (mAllocMod->common.module_api_version >= GRALLOC_MODULE_API_VERSION_0_3) {
|
||||||
err = mAllocMod->lockAsync(mAllocMod, handle, usage,
|
err = mAllocMod->lockAsync(mAllocMod, handle, static_cast<int>(usage),
|
||||||
bounds.left, bounds.top, bounds.width(), bounds.height(),
|
bounds.left, bounds.top, bounds.width(), bounds.height(),
|
||||||
vaddr, fenceFd);
|
vaddr, fenceFd);
|
||||||
} else {
|
} else {
|
||||||
sync_wait(fenceFd, -1);
|
sync_wait(fenceFd, -1);
|
||||||
close(fenceFd);
|
close(fenceFd);
|
||||||
err = mAllocMod->lock(mAllocMod, handle, usage,
|
err = mAllocMod->lock(mAllocMod, handle, static_cast<int>(usage),
|
||||||
bounds.left, bounds.top, bounds.width(), bounds.height(),
|
bounds.left, bounds.top, bounds.width(), bounds.height(),
|
||||||
vaddr);
|
vaddr);
|
||||||
}
|
}
|
||||||
|
@ -134,19 +139,19 @@ status_t GraphicBufferMapper::lockAsync(buffer_handle_t handle,
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t GraphicBufferMapper::lockAsyncYCbCr(buffer_handle_t handle,
|
status_t GraphicBufferMapper::lockAsyncYCbCr(buffer_handle_t handle,
|
||||||
int usage, const Rect& bounds, android_ycbcr *ycbcr, int fenceFd)
|
uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr, int fenceFd)
|
||||||
{
|
{
|
||||||
ATRACE_CALL();
|
ATRACE_CALL();
|
||||||
status_t err;
|
status_t err;
|
||||||
|
|
||||||
if (mAllocMod->common.module_api_version >= GRALLOC_MODULE_API_VERSION_0_3) {
|
if (mAllocMod->common.module_api_version >= GRALLOC_MODULE_API_VERSION_0_3) {
|
||||||
err = mAllocMod->lockAsync_ycbcr(mAllocMod, handle, usage,
|
err = mAllocMod->lockAsync_ycbcr(mAllocMod, handle,
|
||||||
bounds.left, bounds.top, bounds.width(), bounds.height(),
|
static_cast<int>(usage), bounds.left, bounds.top,
|
||||||
ycbcr, fenceFd);
|
bounds.width(), bounds.height(), ycbcr, fenceFd);
|
||||||
} else {
|
} else {
|
||||||
sync_wait(fenceFd, -1);
|
sync_wait(fenceFd, -1);
|
||||||
close(fenceFd);
|
close(fenceFd);
|
||||||
err = mAllocMod->lock_ycbcr(mAllocMod, handle, usage,
|
err = mAllocMod->lock_ycbcr(mAllocMod, handle, static_cast<int>(usage),
|
||||||
bounds.left, bounds.top, bounds.width(), bounds.height(),
|
bounds.left, bounds.top, bounds.width(), bounds.height(),
|
||||||
ycbcr);
|
ycbcr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ui/PixelFormat.h>
|
#include <ui/PixelFormat.h>
|
||||||
#include <hardware/hardware.h>
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
namespace android {
|
namespace android {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
ssize_t bytesPerPixel(PixelFormat format) {
|
uint32_t bytesPerPixel(PixelFormat format) {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case PIXEL_FORMAT_RGBA_8888:
|
case PIXEL_FORMAT_RGBA_8888:
|
||||||
case PIXEL_FORMAT_RGBX_8888:
|
case PIXEL_FORMAT_RGBX_8888:
|
||||||
|
@ -36,10 +35,10 @@ ssize_t bytesPerPixel(PixelFormat format) {
|
||||||
case PIXEL_FORMAT_RGBA_4444:
|
case PIXEL_FORMAT_RGBA_4444:
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
return BAD_VALUE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t bitsPerPixel(PixelFormat format) {
|
uint32_t bitsPerPixel(PixelFormat format) {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case PIXEL_FORMAT_RGBA_8888:
|
case PIXEL_FORMAT_RGBA_8888:
|
||||||
case PIXEL_FORMAT_RGBX_8888:
|
case PIXEL_FORMAT_RGBX_8888:
|
||||||
|
@ -52,7 +51,7 @@ ssize_t bitsPerPixel(PixelFormat format) {
|
||||||
case PIXEL_FORMAT_RGBA_4444:
|
case PIXEL_FORMAT_RGBA_4444:
|
||||||
return 16;
|
return 16;
|
||||||
}
|
}
|
||||||
return BAD_VALUE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
|
@ -102,8 +102,8 @@ static void reverseRectsResolvingJunctions(const Rect* begin, const Rect* end,
|
||||||
current--;
|
current--;
|
||||||
} while (current->top == lastTop && current >= begin);
|
} while (current->top == lastTop && current >= begin);
|
||||||
|
|
||||||
unsigned int beginLastSpan = -1;
|
int beginLastSpan = -1;
|
||||||
unsigned int endLastSpan = -1;
|
int endLastSpan = -1;
|
||||||
int top = -1;
|
int top = -1;
|
||||||
int bottom = -1;
|
int bottom = -1;
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ static void reverseRectsResolvingJunctions(const Rect* begin, const Rect* end,
|
||||||
} else {
|
} else {
|
||||||
beginLastSpan = endLastSpan + 1;
|
beginLastSpan = endLastSpan + 1;
|
||||||
}
|
}
|
||||||
endLastSpan = dst.size() - 1;
|
endLastSpan = static_cast<int>(dst.size()) - 1;
|
||||||
|
|
||||||
top = current->top;
|
top = current->top;
|
||||||
bottom = current->bottom;
|
bottom = current->bottom;
|
||||||
|
@ -126,8 +126,12 @@ static void reverseRectsResolvingJunctions(const Rect* begin, const Rect* end,
|
||||||
int left = current->left;
|
int left = current->left;
|
||||||
int right = current->right;
|
int right = current->right;
|
||||||
|
|
||||||
for (unsigned int prevIndex = beginLastSpan; prevIndex <= endLastSpan; prevIndex++) {
|
for (int prevIndex = beginLastSpan; prevIndex <= endLastSpan; prevIndex++) {
|
||||||
const Rect* prev = &dst[prevIndex];
|
// prevIndex can't be -1 here because if endLastSpan is set to a
|
||||||
|
// value greater than -1 (allowing the loop to execute),
|
||||||
|
// beginLastSpan (and therefore prevIndex) will also be increased
|
||||||
|
const Rect* prev = &dst[static_cast<size_t>(prevIndex)];
|
||||||
|
|
||||||
if (spanDirection == direction_RTL) {
|
if (spanDirection == direction_RTL) {
|
||||||
// iterating over previous span RTL, quit if it's too far left
|
// iterating over previous span RTL, quit if it's too far left
|
||||||
if (prev->right <= left) break;
|
if (prev->right <= left) break;
|
||||||
|
@ -250,10 +254,10 @@ void Region::set(const Rect& r)
|
||||||
mStorage.add(r);
|
mStorage.add(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Region::set(uint32_t w, uint32_t h)
|
void Region::set(int32_t w, int32_t h)
|
||||||
{
|
{
|
||||||
mStorage.clear();
|
mStorage.clear();
|
||||||
mStorage.add(Rect(w,h));
|
mStorage.add(Rect(w, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Region::isTriviallyEqual(const Region& region) const {
|
bool Region::isTriviallyEqual(const Region& region) const {
|
||||||
|
@ -404,7 +408,7 @@ const Region Region::operation(const Region& rhs, int dx, int dy, int op) const
|
||||||
|
|
||||||
// This is our region rasterizer, which merges rects and spans together
|
// This is our region rasterizer, which merges rects and spans together
|
||||||
// to obtain an optimal region.
|
// to obtain an optimal region.
|
||||||
class Region::rasterizer : public region_operator<Rect>::region_rasterizer
|
class Region::rasterizer : public region_operator<Rect>::region_rasterizer
|
||||||
{
|
{
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
Vector<Rect>& storage;
|
Vector<Rect>& storage;
|
||||||
|
@ -413,81 +417,92 @@ class Region::rasterizer : public region_operator<Rect>::region_rasterizer
|
||||||
Vector<Rect> span;
|
Vector<Rect> span;
|
||||||
Rect* cur;
|
Rect* cur;
|
||||||
public:
|
public:
|
||||||
rasterizer(Region& reg)
|
rasterizer(Region& reg)
|
||||||
: bounds(INT_MAX, 0, INT_MIN, 0), storage(reg.mStorage), head(), tail(), cur() {
|
: bounds(INT_MAX, 0, INT_MIN, 0), storage(reg.mStorage), head(), tail(), cur() {
|
||||||
storage.clear();
|
storage.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
~rasterizer() {
|
virtual ~rasterizer();
|
||||||
if (span.size()) {
|
|
||||||
flushSpan();
|
virtual void operator()(const Rect& rect);
|
||||||
}
|
|
||||||
if (storage.size()) {
|
|
||||||
bounds.top = storage.itemAt(0).top;
|
|
||||||
bounds.bottom = storage.top().bottom;
|
|
||||||
if (storage.size() == 1) {
|
|
||||||
storage.clear();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
bounds.left = 0;
|
|
||||||
bounds.right = 0;
|
|
||||||
}
|
|
||||||
storage.add(bounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void operator()(const Rect& rect) {
|
|
||||||
//ALOGD(">>> %3d, %3d, %3d, %3d",
|
|
||||||
// rect.left, rect.top, rect.right, rect.bottom);
|
|
||||||
if (span.size()) {
|
|
||||||
if (cur->top != rect.top) {
|
|
||||||
flushSpan();
|
|
||||||
} else if (cur->right == rect.left) {
|
|
||||||
cur->right = rect.right;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
span.add(rect);
|
|
||||||
cur = span.editArray() + (span.size() - 1);
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static inline T min(T rhs, T lhs) { return rhs < lhs ? rhs : lhs; }
|
static inline T min(T rhs, T lhs) { return rhs < lhs ? rhs : lhs; }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static inline T max(T rhs, T lhs) { return rhs > lhs ? rhs : lhs; }
|
static inline T max(T rhs, T lhs) { return rhs > lhs ? rhs : lhs; }
|
||||||
void flushSpan() {
|
|
||||||
bool merge = false;
|
void flushSpan();
|
||||||
if (tail-head == ssize_t(span.size())) {
|
|
||||||
Rect const* p = span.editArray();
|
|
||||||
Rect const* q = head;
|
|
||||||
if (p->top == q->bottom) {
|
|
||||||
merge = true;
|
|
||||||
while (q != tail) {
|
|
||||||
if ((p->left != q->left) || (p->right != q->right)) {
|
|
||||||
merge = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
p++, q++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (merge) {
|
|
||||||
const int bottom = span[0].bottom;
|
|
||||||
Rect* r = head;
|
|
||||||
while (r != tail) {
|
|
||||||
r->bottom = bottom;
|
|
||||||
r++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
bounds.left = min(span.itemAt(0).left, bounds.left);
|
|
||||||
bounds.right = max(span.top().right, bounds.right);
|
|
||||||
storage.appendVector(span);
|
|
||||||
tail = storage.editArray() + storage.size();
|
|
||||||
head = tail - span.size();
|
|
||||||
}
|
|
||||||
span.clear();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Region::rasterizer::~rasterizer()
|
||||||
|
{
|
||||||
|
if (span.size()) {
|
||||||
|
flushSpan();
|
||||||
|
}
|
||||||
|
if (storage.size()) {
|
||||||
|
bounds.top = storage.itemAt(0).top;
|
||||||
|
bounds.bottom = storage.top().bottom;
|
||||||
|
if (storage.size() == 1) {
|
||||||
|
storage.clear();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bounds.left = 0;
|
||||||
|
bounds.right = 0;
|
||||||
|
}
|
||||||
|
storage.add(bounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Region::rasterizer::operator()(const Rect& rect)
|
||||||
|
{
|
||||||
|
//ALOGD(">>> %3d, %3d, %3d, %3d",
|
||||||
|
// rect.left, rect.top, rect.right, rect.bottom);
|
||||||
|
if (span.size()) {
|
||||||
|
if (cur->top != rect.top) {
|
||||||
|
flushSpan();
|
||||||
|
} else if (cur->right == rect.left) {
|
||||||
|
cur->right = rect.right;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
span.add(rect);
|
||||||
|
cur = span.editArray() + (span.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Region::rasterizer::flushSpan()
|
||||||
|
{
|
||||||
|
bool merge = false;
|
||||||
|
if (tail-head == ssize_t(span.size())) {
|
||||||
|
Rect const* p = span.editArray();
|
||||||
|
Rect const* q = head;
|
||||||
|
if (p->top == q->bottom) {
|
||||||
|
merge = true;
|
||||||
|
while (q != tail) {
|
||||||
|
if ((p->left != q->left) || (p->right != q->right)) {
|
||||||
|
merge = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p++, q++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (merge) {
|
||||||
|
const int bottom = span[0].bottom;
|
||||||
|
Rect* r = head;
|
||||||
|
while (r != tail) {
|
||||||
|
r->bottom = bottom;
|
||||||
|
r++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bounds.left = min(span.itemAt(0).left, bounds.left);
|
||||||
|
bounds.right = max(span.top().right, bounds.right);
|
||||||
|
storage.appendVector(span);
|
||||||
|
tail = storage.editArray() + storage.size();
|
||||||
|
head = tail - span.size();
|
||||||
|
}
|
||||||
|
span.clear();
|
||||||
|
}
|
||||||
|
|
||||||
bool Region::validate(const Region& reg, const char* name, bool silent)
|
bool Region::validate(const Region& reg, const char* name, bool silent)
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
@ -786,10 +801,8 @@ Region::const_iterator Region::end() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect const* Region::getArray(size_t* count) const {
|
Rect const* Region::getArray(size_t* count) const {
|
||||||
const_iterator const b(begin());
|
if (count) *count = static_cast<size_t>(end() - begin());
|
||||||
const_iterator const e(end());
|
return begin();
|
||||||
if (count) *count = e-b;
|
|
||||||
return b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedBuffer const* Region::getSharedBuffer(size_t* count) const {
|
SharedBuffer const* Region::getSharedBuffer(size_t* count) const {
|
||||||
|
@ -806,29 +819,22 @@ SharedBuffer const* Region::getSharedBuffer(size_t* count) const {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void Region::dump(String8& out, const char* what, uint32_t flags) const
|
void Region::dump(String8& out, const char* what, uint32_t /* flags */) const
|
||||||
{
|
{
|
||||||
(void)flags;
|
|
||||||
const_iterator head = begin();
|
const_iterator head = begin();
|
||||||
const_iterator const tail = end();
|
const_iterator const tail = end();
|
||||||
|
|
||||||
size_t SIZE = 256;
|
out.appendFormat(" Region %s (this=%p, count=%" PRIdPTR ")\n",
|
||||||
char buffer[SIZE];
|
what, this, tail - head);
|
||||||
|
|
||||||
snprintf(buffer, SIZE, " Region %s (this=%p, count=%" PRIdPTR ")\n",
|
|
||||||
what, this, tail-head);
|
|
||||||
out.append(buffer);
|
|
||||||
while (head != tail) {
|
while (head != tail) {
|
||||||
snprintf(buffer, SIZE, " [%3d, %3d, %3d, %3d]\n",
|
out.appendFormat(" [%3d, %3d, %3d, %3d]\n", head->left, head->top,
|
||||||
head->left, head->top, head->right, head->bottom);
|
head->right, head->bottom);
|
||||||
out.append(buffer);
|
++head;
|
||||||
head++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Region::dump(const char* what, uint32_t flags) const
|
void Region::dump(const char* what, uint32_t /* flags */) const
|
||||||
{
|
{
|
||||||
(void)flags;
|
|
||||||
const_iterator head = begin();
|
const_iterator head = begin();
|
||||||
const_iterator const tail = end();
|
const_iterator const tail = end();
|
||||||
ALOGD(" Region %s (this=%p, count=%" PRIdPTR ")\n", what, this, tail-head);
|
ALOGD(" Region %s (this=%p, count=%" PRIdPTR ")\n", what, this, tail-head);
|
||||||
|
|
|
@ -18,8 +18,11 @@
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
|
#ifdef FRAMEBUFFER_FORCE_FORMAT
|
||||||
|
// We need the two-level macro to stringify the contents of a macro argument
|
||||||
#define STRINGIFY(x) #x
|
#define STRINGIFY(x) #x
|
||||||
#define TOSTRING(x) STRINGIFY(x)
|
#define TOSTRING(x) STRINGIFY(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
void appendUiConfigString(String8& configStr)
|
void appendUiConfigString(String8& configStr)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue