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

Commit 86655d91 authored by The Android Automerger's avatar The Android Automerger
Browse files

Merge branch 'eclair' into eclair-release

parents e16fe294 9baef73c
Loading
Loading
Loading
Loading
+4 −19
Original line number Diff line number Diff line
@@ -597,14 +597,6 @@ public final class BluetoothAdapter {
    /**
     * Picks RFCOMM channels until none are left.
     * Avoids reserved channels.
     * Ideally we would pick random channels, but in the current implementation
     * we start with the channel that is the hash of the UUID, and try every
     * available channel from there. This means that in most cases a given
     * uuid will use the same channel. This is a workaround for a Bluez SDP
     * bug where we are not updating the cache when the channel changes for a
     * uuid.
     * TODO: Fix the Bluez SDP caching bug, and go back to random channel
     * selection
     */
    private static class RfcommChannelPicker {
        private static final int[] RESERVED_RFCOMM_CHANNELS =  new int[] {
@@ -637,20 +629,13 @@ public final class BluetoothAdapter {
            }
            mUuid = uuid;
        }
        /* Returns next channel, or -1 if we're out */
        /* Returns next random channel, or -1 if we're out */
        public int nextChannel() {
            int channel = mUuid.hashCode();  // always pick the same channel to try first
            Integer channelInt;
            while (mChannels.size() > 0) {
                channelInt = new Integer(channel);
                if (mChannels.remove(channelInt)) {
                    return channel;
                }
                channel = (channel % BluetoothSocket.MAX_RFCOMM_CHANNEL) + 1;
            }

            if (mChannels.size() == 0) {
                return -1;
            }
            return mChannels.remove(sRandom.nextInt(mChannels.size()));
        }
    }

    /**
+21 −0
Original line number Diff line number Diff line
#include "GraphicsJNI.h"
#include "SkMaskFilter.h"
#include "SkBlurMaskFilter.h"
#include "SkTableMaskFilter.h"

#include <jni.h>

@@ -39,6 +40,19 @@ public:
        ThrowIAE_IfNull(env, filter);
        return filter;
    }

    static SkMaskFilter* createTable(JNIEnv* env, jobject, jbyteArray jtable) {
        AutoJavaByteArray autoTable(env, jtable, 256);
        return new SkTableMaskFilter((const uint8_t*)autoTable.ptr());
    }

    static SkMaskFilter* createClipTable(JNIEnv* env, jobject, int min, int max) {
        return SkTableMaskFilter::CreateClip(min, max);
    }

    static SkMaskFilter* createGammaTable(JNIEnv* env, jobject, float gamma) {
        return SkTableMaskFilter::CreateGamma(gamma);
    }
};

static JNINativeMethod gMaskFilterMethods[] = {
@@ -53,6 +67,12 @@ static JNINativeMethod gEmbossMaskFilterMethods[] = {
    { "nativeConstructor",  "([FFFF)I", (void*)SkMaskFilterGlue::createEmboss    }
};

static JNINativeMethod gTableMaskFilterMethods[] = {
    { "nativeNewTable", "([B)I", (void*)SkMaskFilterGlue::createTable    },
    { "nativeNewClip",  "(II)I", (void*)SkMaskFilterGlue::createClipTable    },
    { "nativeNewGamma", "(F)I", (void*)SkMaskFilterGlue::createGammaTable    }
};

#include <android_runtime/AndroidRuntime.h>

#define REG(env, name, array)                                                                       \
@@ -67,6 +87,7 @@ int register_android_graphics_MaskFilter(JNIEnv* env)
    REG(env, "android/graphics/MaskFilter", gMaskFilterMethods);
    REG(env, "android/graphics/BlurMaskFilter", gBlurMaskFilterMethods);
    REG(env, "android/graphics/EmbossMaskFilter", gEmbossMaskFilterMethods);
    REG(env, "android/graphics/TableMaskFilter", gTableMaskFilterMethods);
    
    return 0;
}
+46 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2006 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.graphics;

/**
 * @hide
 */
public class TableMaskFilter extends MaskFilter {

    public TableMaskFilter(byte[] table) {
        if (table.length < 256) {
            throw new RuntimeException("table.length must be >= 256");
        }
        native_instance = nativeNewTable(table);
    }
    
    private TableMaskFilter(int ni) {
        native_instance = ni;
    }
    
    public static TableMaskFilter CreateClipTable(int min, int max) {
        return new TableMaskFilter(nativeNewClip(min, max));
    }
    
    public static TableMaskFilter CreateGammaTable(float gamma) {
        return new TableMaskFilter(nativeNewGamma(gamma));
    }

    private static native int nativeNewTable(byte[] table);
    private static native int nativeNewClip(int min, int max);
    private static native int nativeNewGamma(float gamma);
}
+4 −3
Original line number Diff line number Diff line
@@ -42,7 +42,8 @@ LayerBlur::LayerBlur(SurfaceFlinger* flinger, DisplayID display,
        const sp<Client>& client, int32_t i)
    : LayerBaseClient(flinger, display, client, i), mCacheDirty(true),
          mRefreshCache(true), mCacheAge(0), mTextureName(-1U),
mWidthScale(1.0f), mHeightScale(1.0f)
          mWidthScale(1.0f), mHeightScale(1.0f),
          mBlurFormat(GGL_PIXEL_FORMAT_RGB_565)
{
}

+37 −24
Original line number Diff line number Diff line
@@ -33,14 +33,13 @@
#include "SurfaceFlinger.h"
#include "DisplayHardware/DisplayHardware.h"

#include "gralloc_priv.h"   // needed for msm / copybit

namespace android {

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

const uint32_t LayerBuffer::typeInfo = LayerBaseClient::typeInfo | 0x20;
const char* const LayerBuffer::typeID = "LayerBuffer";
gralloc_module_t const* LayerBuffer::sGrallocModule = 0;

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

@@ -60,6 +59,16 @@ void LayerBuffer::onFirstRef()
    LayerBaseClient::onFirstRef();
    mSurface = new SurfaceLayerBuffer(mFlinger, clientIndex(),
            const_cast<LayerBuffer *>(this));

    hw_module_t const* module = (hw_module_t const*)sGrallocModule;
    if (!module) {
        // NOTE: technically there is a race here, but it shouldn't
        // cause any problem since hw_get_module() always returns
        // the same value.
        if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) {
            sGrallocModule = (gralloc_module_t const *)module;
        }
    }
}

sp<LayerBaseClient::Surface> LayerBuffer::createSurface() const
@@ -243,7 +252,17 @@ LayerBuffer::Buffer::Buffer(const ISurface::BufferHeap& buffers, ssize_t offset)
    : mBufferHeap(buffers)
{
    NativeBuffer& src(mNativeBuffer);
    src.img.handle = 0;

    gralloc_module_t const * module = LayerBuffer::getGrallocModule();
    if (module && module->perform) {
        int err = module->perform(module,
                GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER,
                buffers.heap->heapID(), buffers.heap->getSize(),
                offset, buffers.heap->base(),
                &src.img.handle);

        if (err == NO_ERROR) {
            src.crop.l = 0;
            src.crop.t = 0;
            src.crop.r = buffers.w;
@@ -253,20 +272,16 @@ LayerBuffer::Buffer::Buffer(const ISurface::BufferHeap& buffers, ssize_t offset)
            src.img.h       = buffers.ver_stride ?: buffers.h;
            src.img.format  = buffers.format;
            src.img.base    = (void*)(intptr_t(buffers.heap->base()) + offset);

    // FIXME: gross hack, we should never access private_handle_t from here,
    // but this is needed by msm drivers
    private_handle_t* hnd = new private_handle_t(
            buffers.heap->heapID(), buffers.heap->getSize(), 0);
    hnd->offset = offset;
    src.img.handle = hnd;
        }
    }
}

LayerBuffer::Buffer::~Buffer()
{
    NativeBuffer& src(mNativeBuffer);
    if (src.img.handle)
        delete (private_handle_t*)src.img.handle;
    if (src.img.handle) {
        native_handle_delete(src.img.handle);
    }
}

// ============================================================================
@@ -437,9 +452,7 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const
    }

    if (err != NO_ERROR) {
        // OpenGL fall-back
        GLuint w = 0;
        GLuint h = 0;
        // slower fallback
        GGLSurface t;
        t.version = sizeof(GGLSurface);
        t.width  = src.crop.r;
Loading