Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72f49dc1 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6269144 from f098f119 to rvc-release

Change-Id: Ie0818f0f2332252d5f93451fc466c107a30484f9
parents 3e37eea5 f098f119
Loading
Loading
Loading
Loading

include/ui/FatVector.h

deleted120000 → 0
+0 −1
Original line number Original line Diff line number Diff line
../../libs/ui/include/ui/FatVector.h
 No newline at end of file
+11 −32
Original line number Original line Diff line number Diff line
@@ -30,24 +30,10 @@


namespace android {
namespace android {


namespace {
static const sp<IBinder>& getClientId() {

#if defined(__BRILLO__)
// Because Brillo has no application model, security policy is managed
// statically (at build time) with SELinux controls.
// As a consequence, it also never runs the AppOpsManager service.
const int APP_OPS_MANAGER_UNAVAILABLE_MODE = AppOpsManager::MODE_ALLOWED;
#else
const int APP_OPS_MANAGER_UNAVAILABLE_MODE = AppOpsManager::MODE_IGNORED;
#endif  // defined(__BRILLO__)

}  // namespace

static String16 _appops("appops");
    static pthread_mutex_t gClientIdMutex = PTHREAD_MUTEX_INITIALIZER;
    static pthread_mutex_t gClientIdMutex = PTHREAD_MUTEX_INITIALIZER;
    static sp<IBinder> gClientId;
    static sp<IBinder> gClientId;


static const sp<IBinder>& getClientId() {
    pthread_mutex_lock(&gClientIdMutex);
    pthread_mutex_lock(&gClientIdMutex);
    if (gClientId == nullptr) {
    if (gClientId == nullptr) {
        gClientId = new BBinder();
        gClientId = new BBinder();
@@ -56,22 +42,13 @@ static const sp<IBinder>& getClientId() {
    return gClientId;
    return gClientId;
}
}


thread_local uint64_t notedAppOpsInThisBinderTransaction[2];
thread_local int32_t uidOfThisBinderTransaction = -1;

// Whether an appop should be collected: 0 == not initialized, 1 == don't note, 2 == note
uint8_t appOpsToNote[AppOpsManager::_NUM_OP] = {0};

AppOpsManager::AppOpsManager()
AppOpsManager::AppOpsManager()
{
{
}
}


#if defined(__BRILLO__)
// There is no AppOpsService on Brillo
sp<IAppOpsService> AppOpsManager::getService() { return NULL; }
#else
sp<IAppOpsService> AppOpsManager::getService()
sp<IAppOpsService> AppOpsManager::getService()
{
{
    static String16 _appops("appops");


    std::lock_guard<Mutex> scoped_lock(mLock);
    std::lock_guard<Mutex> scoped_lock(mLock);
    int64_t startTime = 0;
    int64_t startTime = 0;
@@ -96,14 +73,13 @@ sp<IAppOpsService> AppOpsManager::getService()
    }
    }
    return service;
    return service;
}
}
#endif  // defined(__BRILLO__)


int32_t AppOpsManager::checkOp(int32_t op, int32_t uid, const String16& callingPackage)
int32_t AppOpsManager::checkOp(int32_t op, int32_t uid, const String16& callingPackage)
{
{
    sp<IAppOpsService> service = getService();
    sp<IAppOpsService> service = getService();
    return service != nullptr
    return service != nullptr
            ? service->checkOperation(op, uid, callingPackage)
            ? service->checkOperation(op, uid, callingPackage)
            : APP_OPS_MANAGER_UNAVAILABLE_MODE;
            : AppOpsManager::MODE_IGNORED;
}
}


int32_t AppOpsManager::checkAudioOpNoThrow(int32_t op, int32_t usage, int32_t uid,
int32_t AppOpsManager::checkAudioOpNoThrow(int32_t op, int32_t usage, int32_t uid,
@@ -111,7 +87,7 @@ int32_t AppOpsManager::checkAudioOpNoThrow(int32_t op, int32_t usage, int32_t ui
    sp<IAppOpsService> service = getService();
    sp<IAppOpsService> service = getService();
    return service != nullptr
    return service != nullptr
           ? service->checkAudioOperation(op, usage, uid, callingPackage)
           ? service->checkAudioOperation(op, usage, uid, callingPackage)
           : APP_OPS_MANAGER_UNAVAILABLE_MODE;
           : AppOpsManager::MODE_IGNORED;
}
}


int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPackage) {
int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPackage) {
@@ -125,7 +101,7 @@ int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPa
    int32_t mode = service != nullptr
    int32_t mode = service != nullptr
            ? service->noteOperation(op, uid, callingPackage, featureId, shouldCollectNotes(op),
            ? service->noteOperation(op, uid, callingPackage, featureId, shouldCollectNotes(op),
                    message)
                    message)
            : APP_OPS_MANAGER_UNAVAILABLE_MODE;
            : AppOpsManager::MODE_IGNORED;


    return mode;
    return mode;
}
}
@@ -143,7 +119,7 @@ int32_t AppOpsManager::startOpNoThrow(int32_t op, int32_t uid, const String16& c
    int32_t mode = service != nullptr
    int32_t mode = service != nullptr
            ? service->startOperation(getClientId(), op, uid, callingPackage,
            ? service->startOperation(getClientId(), op, uid, callingPackage,
                    featureId, startIfModeDefault, shouldCollectNotes(op), message)
                    featureId, startIfModeDefault, shouldCollectNotes(op), message)
            : APP_OPS_MANAGER_UNAVAILABLE_MODE;
            : AppOpsManager::MODE_IGNORED;


    return mode;
    return mode;
}
}
@@ -192,6 +168,9 @@ void AppOpsManager::setCameraAudioRestriction(int32_t mode) {


// check it the appops needs to be collected and cache result
// check it the appops needs to be collected and cache result
bool AppOpsManager::shouldCollectNotes(int32_t opcode) {
bool AppOpsManager::shouldCollectNotes(int32_t opcode) {
    // Whether an appop should be collected: 0 == not initialized, 1 == don't note, 2 == note
    static uint8_t appOpsToNote[AppOpsManager::_NUM_OP] = {0};

    if (appOpsToNote[opcode] == 0) {
    if (appOpsToNote[opcode] == 0) {
        if (getService()->shouldCollectNotes(opcode)) {
        if (getService()->shouldCollectNotes(opcode)) {
            appOpsToNote[opcode] = 2;
            appOpsToNote[opcode] = 2;
+0 −9
Original line number Original line Diff line number Diff line
@@ -381,15 +381,6 @@ GLESRenderEngine::GLESRenderEngine(const RenderEngineCreationArgs& args, EGLDisp
        LOG_ALWAYS_FATAL_IF(!success, "can't make default context current");
        LOG_ALWAYS_FATAL_IF(!success, "can't make default context current");
    }
    }


    const uint16_t protTexData[] = {0};
    glGenTextures(1, &mProtectedTexName);
    glBindTexture(GL_TEXTURE_2D, mProtectedTexName);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, protTexData);

    // mColorBlindnessCorrection = M;
    // mColorBlindnessCorrection = M;


    if (mUseColorManagement) {
    if (mUseColorManagement) {
+0 −1
Original line number Original line Diff line number Diff line
@@ -178,7 +178,6 @@ private:
    EGLSurface mDummySurface;
    EGLSurface mDummySurface;
    EGLContext mProtectedEGLContext;
    EGLContext mProtectedEGLContext;
    EGLSurface mProtectedDummySurface;
    EGLSurface mProtectedDummySurface;
    GLuint mProtectedTexName;
    GLint mMaxViewportDims[2];
    GLint mMaxViewportDims[2];
    GLint mMaxTextureSize;
    GLint mMaxTextureSize;
    GLuint mVpWidth;
    GLuint mVpWidth;
+46 −48
Original line number Original line Diff line number Diff line
@@ -67,20 +67,19 @@ const Region Region::INVALID_REGION(Rect::INVALID_RECT);
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------


Region::Region() {
Region::Region() {
    mStorage.push_back(Rect(0, 0));
    mStorage.add(Rect(0,0));
}
}


Region::Region(const Region& rhs)
Region::Region(const Region& rhs)
    : mStorage(rhs.mStorage)
{
{
    mStorage.clear();
    mStorage.insert(mStorage.begin(), rhs.mStorage.begin(), rhs.mStorage.end());
#if defined(VALIDATE_REGIONS)
#if defined(VALIDATE_REGIONS)
    validate(rhs, "rhs copy-ctor");
    validate(rhs, "rhs copy-ctor");
#endif
#endif
}
}


Region::Region(const Rect& rhs) {
Region::Region(const Rect& rhs) {
    mStorage.push_back(rhs);
    mStorage.add(rhs);
}
}


Region::~Region()
Region::~Region()
@@ -101,8 +100,8 @@ Region::~Region()
 * final, correctly ordered region buffer. Each rectangle will be compared with the span directly
 * final, correctly ordered region buffer. Each rectangle will be compared with the span directly
 * above it, and subdivided to resolve any remaining T-junctions.
 * above it, and subdivided to resolve any remaining T-junctions.
 */
 */
static void reverseRectsResolvingJunctions(const Rect* begin, const Rect* end, FatVector<Rect>& dst,
static void reverseRectsResolvingJunctions(const Rect* begin, const Rect* end,
                                           int spanDirection) {
        Vector<Rect>& dst, int spanDirection) {
    dst.clear();
    dst.clear();


    const Rect* current = end - 1;
    const Rect* current = end - 1;
@@ -110,7 +109,7 @@ static void reverseRectsResolvingJunctions(const Rect* begin, const Rect* end, F


    // add first span immediately
    // add first span immediately
    do {
    do {
        dst.push_back(*current);
        dst.add(*current);
        current--;
        current--;
    } while (current->top == lastTop && current >= begin);
    } while (current->top == lastTop && current >= begin);


@@ -148,12 +147,12 @@ static void reverseRectsResolvingJunctions(const Rect* begin, const Rect* end, F
                if (prev.right <= left) break;
                if (prev.right <= left) break;


                if (prev.right > left && prev.right < right) {
                if (prev.right > left && prev.right < right) {
                    dst.push_back(Rect(prev.right, top, right, bottom));
                    dst.add(Rect(prev.right, top, right, bottom));
                    right = prev.right;
                    right = prev.right;
                }
                }


                if (prev.left > left && prev.left < right) {
                if (prev.left > left && prev.left < right) {
                    dst.push_back(Rect(prev.left, top, right, bottom));
                    dst.add(Rect(prev.left, top, right, bottom));
                    right = prev.left;
                    right = prev.left;
                }
                }


@@ -167,12 +166,12 @@ static void reverseRectsResolvingJunctions(const Rect* begin, const Rect* end, F
                if (prev.left >= right) break;
                if (prev.left >= right) break;


                if (prev.left > left && prev.left < right) {
                if (prev.left > left && prev.left < right) {
                    dst.push_back(Rect(left, top, prev.left, bottom));
                    dst.add(Rect(left, top, prev.left, bottom));
                    left = prev.left;
                    left = prev.left;
                }
                }


                if (prev.right > left && prev.right < right) {
                if (prev.right > left && prev.right < right) {
                    dst.push_back(Rect(left, top, prev.right, bottom));
                    dst.add(Rect(left, top, prev.right, bottom));
                    left = prev.right;
                    left = prev.right;
                }
                }
                // if an entry in the previous span is too far left, nothing further right in the
                // if an entry in the previous span is too far left, nothing further right in the
@@ -184,7 +183,7 @@ static void reverseRectsResolvingJunctions(const Rect* begin, const Rect* end, F
        }
        }


        if (left < right) {
        if (left < right) {
            dst.push_back(Rect(left, top, right, bottom));
            dst.add(Rect(left, top, right, bottom));
        }
        }


        current--;
        current--;
@@ -202,14 +201,13 @@ Region Region::createTJunctionFreeRegion(const Region& r) {
    if (r.isEmpty()) return r;
    if (r.isEmpty()) return r;
    if (r.isRect()) return r;
    if (r.isRect()) return r;


    FatVector<Rect> reversed;
    Vector<Rect> reversed;
    reverseRectsResolvingJunctions(r.begin(), r.end(), reversed, direction_RTL);
    reverseRectsResolvingJunctions(r.begin(), r.end(), reversed, direction_RTL);


    Region outputRegion;
    Region outputRegion;
    reverseRectsResolvingJunctions(reversed.data(), reversed.data() + reversed.size(),
    reverseRectsResolvingJunctions(reversed.begin(), reversed.end(),
            outputRegion.mStorage, direction_LTR);
            outputRegion.mStorage, direction_LTR);
    outputRegion.mStorage.push_back(
    outputRegion.mStorage.add(r.getBounds()); // to make region valid, mStorage must end with bounds
            r.getBounds()); // to make region valid, mStorage must end with bounds


#if defined(VALIDATE_REGIONS)
#if defined(VALIDATE_REGIONS)
    validate(outputRegion, "T-Junction free region");
    validate(outputRegion, "T-Junction free region");
@@ -224,8 +222,7 @@ Region& Region::operator = (const Region& rhs)
    validate(*this, "this->operator=");
    validate(*this, "this->operator=");
    validate(rhs, "rhs.operator=");
    validate(rhs, "rhs.operator=");
#endif
#endif
    mStorage.clear();
    mStorage = rhs.mStorage;
    mStorage.insert(mStorage.begin(), rhs.mStorage.begin(), rhs.mStorage.end());
    return *this;
    return *this;
}
}


@@ -234,7 +231,7 @@ Region& Region::makeBoundsSelf()
    if (mStorage.size() >= 2) {
    if (mStorage.size() >= 2) {
        const Rect bounds(getBounds());
        const Rect bounds(getBounds());
        mStorage.clear();
        mStorage.clear();
        mStorage.push_back(bounds);
        mStorage.add(bounds);
    }
    }
    return *this;
    return *this;
}
}
@@ -258,25 +255,25 @@ bool Region::contains(int x, int y) const {
void Region::clear()
void Region::clear()
{
{
    mStorage.clear();
    mStorage.clear();
    mStorage.push_back(Rect(0, 0));
    mStorage.add(Rect(0,0));
}
}


void Region::set(const Rect& r)
void Region::set(const Rect& r)
{
{
    mStorage.clear();
    mStorage.clear();
    mStorage.push_back(r);
    mStorage.add(r);
}
}


void Region::set(int32_t w, int32_t h)
void Region::set(int32_t w, int32_t h)
{
{
    mStorage.clear();
    mStorage.clear();
    mStorage.push_back(Rect(w, h));
    mStorage.add(Rect(w, h));
}
}


void Region::set(uint32_t w, uint32_t h)
void Region::set(uint32_t w, uint32_t h)
{
{
    mStorage.clear();
    mStorage.clear();
    mStorage.push_back(Rect(w, h));
    mStorage.add(Rect(w, h));
}
}


bool Region::isTriviallyEqual(const Region& region) const {
bool Region::isTriviallyEqual(const Region& region) const {
@@ -302,7 +299,8 @@ bool Region::hasSameRects(const Region& other) const {
void Region::addRectUnchecked(int l, int t, int r, int b)
void Region::addRectUnchecked(int l, int t, int r, int b)
{
{
    Rect rect(l,t,r,b);
    Rect rect(l,t,r,b);
    mStorage.insert(mStorage.end() - 1, rect);
    size_t where = mStorage.size() - 1;
    mStorage.insertAt(rect, where, 1);
}
}


// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
@@ -352,7 +350,7 @@ Region& Region::translateSelf(int x, int y) {


Region& Region::scaleSelf(float sx, float sy) {
Region& Region::scaleSelf(float sx, float sy) {
    size_t count = mStorage.size();
    size_t count = mStorage.size();
    Rect* rects = mStorage.data();
    Rect* rects = mStorage.editArray();
    while (count) {
    while (count) {
        rects->left = static_cast<int32_t>(static_cast<float>(rects->left) * sx + 0.5f);
        rects->left = static_cast<int32_t>(static_cast<float>(rects->left) * sx + 0.5f);
        rects->right = static_cast<int32_t>(static_cast<float>(rects->right) * sx + 0.5f);
        rects->right = static_cast<int32_t>(static_cast<float>(rects->right) * sx + 0.5f);
@@ -457,10 +455,10 @@ const Region Region::operation(const Region& rhs, int dx, int dy, uint32_t op) c
class Region::rasterizer : public region_operator<Rect>::region_rasterizer
class Region::rasterizer : public region_operator<Rect>::region_rasterizer
{
{
    Rect bounds;
    Rect bounds;
    FatVector<Rect>& storage;
    Vector<Rect>& storage;
    Rect* head;
    Rect* head;
    Rect* tail;
    Rect* tail;
    FatVector<Rect> span;
    Vector<Rect> span;
    Rect* cur;
    Rect* cur;
public:
public:
    explicit rasterizer(Region& reg)
    explicit rasterizer(Region& reg)
@@ -487,8 +485,8 @@ Region::rasterizer::~rasterizer()
        flushSpan();
        flushSpan();
    }
    }
    if (storage.size()) {
    if (storage.size()) {
        bounds.top = storage.front().top;
        bounds.top = storage.itemAt(0).top;
        bounds.bottom = storage.back().bottom;
        bounds.bottom = storage.top().bottom;
        if (storage.size() == 1) {
        if (storage.size() == 1) {
            storage.clear();
            storage.clear();
        }
        }
@@ -496,7 +494,7 @@ Region::rasterizer::~rasterizer()
        bounds.left  = 0;
        bounds.left  = 0;
        bounds.right = 0;
        bounds.right = 0;
    }
    }
    storage.push_back(bounds);
    storage.add(bounds);
}
}


void Region::rasterizer::operator()(const Rect& rect)
void Region::rasterizer::operator()(const Rect& rect)
@@ -511,15 +509,15 @@ void Region::rasterizer::operator()(const Rect& rect)
            return;
            return;
        }
        }
    }
    }
    span.push_back(rect);
    span.add(rect);
    cur = span.data() + (span.size() - 1);
    cur = span.editArray() + (span.size() - 1);
}
}


void Region::rasterizer::flushSpan()
void Region::rasterizer::flushSpan()
{
{
    bool merge = false;
    bool merge = false;
    if (tail-head == ssize_t(span.size())) {
    if (tail-head == ssize_t(span.size())) {
        Rect const* p = span.data();
        Rect const* p = span.editArray();
        Rect const* q = head;
        Rect const* q = head;
        if (p->top == q->bottom) {
        if (p->top == q->bottom) {
            merge = true;
            merge = true;
@@ -534,17 +532,17 @@ void Region::rasterizer::flushSpan()
        }
        }
    }
    }
    if (merge) {
    if (merge) {
        const int bottom = span.front().bottom;
        const int bottom = span[0].bottom;
        Rect* r = head;
        Rect* r = head;
        while (r != tail) {
        while (r != tail) {
            r->bottom = bottom;
            r->bottom = bottom;
            r++;
            r++;
        }
        }
    } else {
    } else {
        bounds.left = min(span.front().left, bounds.left);
        bounds.left = min(span.itemAt(0).left, bounds.left);
        bounds.right = max(span.back().right, bounds.right);
        bounds.right = max(span.top().right, bounds.right);
        storage.insert(storage.end(), span.begin(), span.end());
        storage.appendVector(span);
        tail = storage.data() + storage.size();
        tail = storage.editArray() + storage.size();
        head = tail - span.size();
        head = tail - span.size();
    }
    }
    span.clear();
    span.clear();
@@ -552,7 +550,7 @@ void Region::rasterizer::flushSpan()


bool Region::validate(const Region& reg, const char* name, bool silent)
bool Region::validate(const Region& reg, const char* name, bool silent)
{
{
    if (reg.mStorage.empty()) {
    if (reg.mStorage.isEmpty()) {
        ALOGE_IF(!silent, "%s: mStorage is empty, which is never valid", name);
        ALOGE_IF(!silent, "%s: mStorage is empty, which is never valid", name);
        // return immediately as the code below assumes mStorage is non-empty
        // return immediately as the code below assumes mStorage is non-empty
        return false;
        return false;
@@ -691,7 +689,8 @@ void Region::boolean_operation(uint32_t op, Region& dst,
    }
    }
    sk_dst.op(sk_lhs, sk_rhs, sk_op);
    sk_dst.op(sk_lhs, sk_rhs, sk_op);


    if (sk_dst.empty() && dst.empty()) return;
    if (sk_dst.isEmpty() && dst.isEmpty())
        return;
    
    
    bool same = true;
    bool same = true;
    Region::const_iterator head = dst.begin();
    Region::const_iterator head = dst.begin();
@@ -787,7 +786,7 @@ void Region::translate(Region& reg, int dx, int dy)
        validate(reg, "translate (before)");
        validate(reg, "translate (before)");
#endif
#endif
        size_t count = reg.mStorage.size();
        size_t count = reg.mStorage.size();
        Rect* rects = reg.mStorage.data();
        Rect* rects = reg.mStorage.editArray();
        while (count) {
        while (count) {
            rects->offsetBy(dx, dy);
            rects->offsetBy(dx, dy);
            rects++;
            rects++;
@@ -867,25 +866,24 @@ status_t Region::unflatten(void const* buffer, size_t size) {
        ALOGE("Region::unflatten() failed, invalid region");
        ALOGE("Region::unflatten() failed, invalid region");
        return BAD_VALUE;
        return BAD_VALUE;
    }
    }
    mStorage.clear();
    mStorage = result.mStorage;
    mStorage.insert(mStorage.begin(), result.mStorage.begin(), result.mStorage.end());
    return NO_ERROR;
    return NO_ERROR;
}
}


// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------


Region::const_iterator Region::begin() const {
Region::const_iterator Region::begin() const {
    return mStorage.data();
    return mStorage.array();
}
}


Region::const_iterator Region::end() const {
Region::const_iterator Region::end() const {
    // Workaround for b/77643177
    // Workaround for b/77643177
    // mStorage should never be empty, but somehow it is and it's causing
    // mStorage should never be empty, but somehow it is and it's causing
    // an abort in ubsan
    // an abort in ubsan
    if (mStorage.empty()) return mStorage.data();
    if (mStorage.isEmpty()) return mStorage.array();


    size_t numRects = isRect() ? 1 : mStorage.size() - 1;
    size_t numRects = isRect() ? 1 : mStorage.size() - 1;
    return mStorage.data() + numRects;
    return mStorage.array() + numRects;
}
}


Rect const* Region::getArray(size_t* count) const {
Rect const* Region::getArray(size_t* count) const {
Loading