Merge "List.GetCheckItemIds no longer includes unchecked items."
diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp
index 86a6fac..7e81e90 100644
--- a/camera/libcameraservice/CameraService.cpp
+++ b/camera/libcameraservice/CameraService.cpp
@@ -29,6 +29,8 @@
#include <surfaceflinger/ISurface.h>
#include <ui/Overlay.h>
+#include <hardware/hardware.h>
+
#include <media/mediaplayer.h>
#include <media/AudioSystem.h>
#include "CameraService.h"
@@ -605,8 +607,9 @@
CameraParameters params(mHardware->getParameters());
params.getPreviewSize(&w, &h);
+ // don't use a hardcoded format here
ISurface::BufferHeap buffers(w, h, w, h,
- PIXEL_FORMAT_YCbCr_420_SP,
+ HAL_PIXEL_FORMAT_YCrCb_420_SP,
mOrientation,
0,
mHardware->getPreviewHeap());
@@ -926,8 +929,10 @@
h &= ~1;
LOGV("Snapshot image width=%d, height=%d", w, h);
}
+ // FIXME: don't use hardcoded format constants here
ISurface::BufferHeap buffers(w, h, w, h,
- PIXEL_FORMAT_YCbCr_420_SP, mOrientation, 0, mHardware->getRawHeap());
+ HAL_PIXEL_FORMAT_YCrCb_420_SP, mOrientation, 0,
+ mHardware->getRawHeap());
mSurface->registerBuffers(buffers);
}
diff --git a/common/java/com/android/common/Patterns.java b/common/java/com/android/common/Patterns.java
index 71c3a5e..3b3b038 100644
--- a/common/java/com/android/common/Patterns.java
+++ b/common/java/com/android/common/Patterns.java
@@ -24,12 +24,12 @@
*/
public class Patterns {
/**
- * Regular expression pattern to match all IANA top-level domains.
+ * Regular expression to match all IANA top-level domains.
* List accurate as of 2010/02/05. List taken from:
* http://data.iana.org/TLD/tlds-alpha-by-domain.txt
- * This pattern is auto-generated by development/tools/make-iana-tld-pattern.py
+ * This pattern is auto-generated by frameworks/base/common/tools/make-iana-tld-pattern.py
*/
- public static final Pattern TOP_LEVEL_DOMAIN = Pattern.compile(
+ public static final String TOP_LEVEL_DOMAIN_STR =
"((aero|arpa|asia|a[cdefgilmnoqrstuwxz])"
+ "|(biz|b[abdefghijmnorstvwyz])"
+ "|(cat|com|coop|c[acdfghiklmnoruvxyz])"
@@ -55,20 +55,22 @@
+ "|w[fs]"
+ "|(xn\\-\\-0zwm56d|xn\\-\\-11b5bs3a9aj6g|xn\\-\\-80akhbyknj4f|xn\\-\\-9t4b11yi5a|xn\\-\\-deba0ad|xn\\-\\-g6w251d|xn\\-\\-hgbk6aj7f53bba|xn\\-\\-hlcj6aya9esc7a|xn\\-\\-jxalpdlp|xn\\-\\-kgbechtv|xn\\-\\-zckzah)"
+ "|y[etu]"
- + "|z[amw])");
+ + "|z[amw])";
/**
- * Regular expression pattern to match RFC 1738 URLs
+ * Regular expression pattern to match all IANA top-level domains.
+ */
+ public static final Pattern TOP_LEVEL_DOMAIN =
+ Pattern.compile(TOP_LEVEL_DOMAIN_STR);
+
+ /**
+ * Regular expression to match all IANA top-level domains for WEB_URL.
* List accurate as of 2010/02/05. List taken from:
* http://data.iana.org/TLD/tlds-alpha-by-domain.txt
- * This pattern is auto-generated by development/tools/make-iana-tld-pattern.py
+ * This pattern is auto-generated by frameworks/base/common/tools/make-iana-tld-pattern.py
*/
- public static final Pattern WEB_URL = Pattern.compile(
- "((?:(http|https|Http|Https|rtsp|Rtsp):\\/\\/(?:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)"
- + "\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_"
- + "\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@)?)?"
- + "((?:(?:[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}\\.)+" // named host
- + "(?:" // plus top level domain
+ public static final String TOP_LEVEL_DOMAIN_STR_FOR_WEB_URL =
+ "(?:"
+ "(?:aero|arpa|asia|a[cdefgilmnoqrstuwxz])"
+ "|(?:biz|b[abdefghijmnorstvwyz])"
+ "|(?:cat|com|coop|c[acdfghiklmnoruvxyz])"
@@ -94,7 +96,28 @@
+ "|w[fs]"
+ "|(?:xn\\-\\-0zwm56d|xn\\-\\-11b5bs3a9aj6g|xn\\-\\-80akhbyknj4f|xn\\-\\-9t4b11yi5a|xn\\-\\-deba0ad|xn\\-\\-g6w251d|xn\\-\\-hgbk6aj7f53bba|xn\\-\\-hlcj6aya9esc7a|xn\\-\\-jxalpdlp|xn\\-\\-kgbechtv|xn\\-\\-zckzah)"
+ "|y[etu]"
- + "|z[amw]))"
+ + "|z[amw]))";
+
+ /**
+ * Good characters for Internationalized Resource Identifiers (IRI).
+ * This comprises most common used Unicode characters allowed in IRI
+ * as detailed in RFC 3987.
+ * Specifically, those two byte Unicode characters are not included.
+ */
+ public static final String GOOD_IRI_CHAR =
+ "a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";
+
+ /**
+ * Regular expression pattern to match most part of RFC 3987
+ * Internationalized URLs, aka IRIs. Commonly used Unicode characters are
+ * added.
+ */
+ public static final Pattern WEB_URL = Pattern.compile(
+ "((?:(http|https|Http|Https|rtsp|Rtsp):\\/\\/(?:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)"
+ + "\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_"
+ + "\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@)?)?"
+ + "((?:(?:[" + GOOD_IRI_CHAR + "][" + GOOD_IRI_CHAR + "\\-]{0,64}\\.)+" // named host
+ + TOP_LEVEL_DOMAIN_STR_FOR_WEB_URL
+ "|(?:(?:25[0-5]|2[0-4]" // or ip address
+ "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(?:25[0-5]|2[0-4][0-9]"
+ "|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1]"
@@ -116,7 +139,7 @@
public static final Pattern DOMAIN_NAME
= Pattern.compile(
- "(((([a-zA-Z0-9][a-zA-Z0-9\\-]*)*[a-zA-Z0-9]\\.)+"
+ "(((([" + GOOD_IRI_CHAR + "][" + GOOD_IRI_CHAR + "\\-]*)*[" + GOOD_IRI_CHAR + "]\\.)+"
+ TOP_LEVEL_DOMAIN + ")|"
+ IP_ADDRESS + ")");
diff --git a/common/java/com/android/common/speech/Recognition.java b/common/java/com/android/common/speech/Recognition.java
new file mode 100644
index 0000000..6f164a9
--- /dev/null
+++ b/common/java/com/android/common/speech/Recognition.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2010 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 com.android.common.speech;
+
+/**
+ * Utilities for voice recognition implementations.
+ *
+ * @see android.app.RecognitionService
+ */
+public class Recognition {
+
+ /**
+ * The extra key used in an intent to the speech recognizer for voice search. Not
+ * generally to be used by developers. The system search dialog uses this, for example,
+ * to set a calling package for identification by a voice search API. If this extra
+ * is set by anyone but the system process, it should be overridden by the voice search
+ * implementation.
+ */
+ public final static String EXTRA_CALLING_PACKAGE = "calling_package";
+
+ private Recognition() { } // don't instantiate
+}
diff --git a/common/tests/src/com/android/common/PatternsTest.java b/common/tests/src/com/android/common/PatternsTest.java
index 635601e..9e2ad58 100644
--- a/common/tests/src/com/android/common/PatternsTest.java
+++ b/common/tests/src/com/android/common/PatternsTest.java
@@ -68,6 +68,12 @@
t = Patterns.WEB_URL.matcher("xn--fsqu00a.xn--0zwm56d").matches();
assertTrue("Valid URL", t);
+ // Internationalized URL.
+ t = Patterns.WEB_URL.matcher("http://\uD604\uAE08\uC601\uC218\uC99D.kr").matches();
+ assertTrue("Valid URL", t);
+ t = Patterns.WEB_URL.matcher("\uD604\uAE08\uC601\uC218\uC99D.kr").matches();
+ assertTrue("Valid URL", t);
+
t = Patterns.WEB_URL.matcher("ftp://www.example.com").matches();
assertFalse("Matched invalid protocol", t);
@@ -99,6 +105,13 @@
t = Patterns.DOMAIN_NAME.matcher("mail.example.com").matches();
assertTrue("Valid domain", t);
+ t = Patterns.WEB_URL.matcher("google.me").matches();
+ assertTrue("Valid domain", t);
+
+ // Internationalized domains.
+ t = Patterns.DOMAIN_NAME.matcher("\uD604\uAE08\uC601\uC218\uC99D.kr").matches();
+ assertTrue("Valid domain", t);
+
t = Patterns.DOMAIN_NAME.matcher("__+&42.xer").matches();
assertFalse("Invalid domain", t);
}
diff --git a/common/tools/make-iana-tld-pattern.py b/common/tools/make-iana-tld-pattern.py
index ece4dcf..de81c58 100755
--- a/common/tools/make-iana-tld-pattern.py
+++ b/common/tools/make-iana-tld-pattern.py
@@ -4,43 +4,27 @@
TLD_PREFIX = r"""
/**
- * Regular expression pattern to match all IANA top-level domains.
+ * Regular expression to match all IANA top-level domains.
* List accurate as of 2010/02/05. List taken from:
* http://data.iana.org/TLD/tlds-alpha-by-domain.txt
* This pattern is auto-generated by frameworks/base/common/tools/make-iana-tld-pattern.py
*/
- public static final Pattern TOP_LEVEL_DOMAIN = Pattern.compile(
+ public static final String TOP_LEVEL_DOMAIN_STR =
"""
-TLD_SUFFIX = '");'
+TLD_SUFFIX = '";'
URL_PREFIX = r"""
/**
- * Regular expression pattern to match RFC 1738 URLs
+ * Regular expression to match all IANA top-level domains for WEB_URL.
* List accurate as of 2010/02/05. List taken from:
* http://data.iana.org/TLD/tlds-alpha-by-domain.txt
- * This pattern is auto-generated by frameworkds/base/common/tools/make-iana-tld-pattern.py
+ * This pattern is auto-generated by frameworks/base/common/tools/make-iana-tld-pattern.py
*/
- public static final Pattern WEB_URL = Pattern.compile(
- "((?:(http|https|Http|Https|rtsp|Rtsp):\\/\\/(?:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)"
- + "\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_"
- + "\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@)?)?"
- + "((?:(?:[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}\\.)+" // named host
- + "(?:" // plus top level domain
+ public static final String TOP_LEVEL_DOMAIN_STR_FOR_WEB_URL =
+ "(?:"
"""
-URL_SUFFIX = r"""
- + "|(?:(?:25[0-5]|2[0-4]" // or ip address
- + "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(?:25[0-5]|2[0-4][0-9]"
- + "|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1]"
- + "[0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}"
- + "|[1-9][0-9]|[0-9])))"
- + "(?:\\:\\d{1,5})?)" // plus option port number
- + "(\\/(?:(?:[a-zA-Z0-9\\;\\/\\?\\:\\@\\&\\=\\#\\~" // plus option query params
- + "\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_])|(?:\\%[a-fA-F0-9]{2}))*)?"
- + "(?:\\b|$)"); // and finally, a word boundary or end of
- // input. This is to stop foo.sure from
- // matching as foo.su
-"""
+URL_SUFFIX = ';'
class Bucket:
def __init__(self, baseLetter):
diff --git a/include/ui/PixelFormat.h b/include/ui/PixelFormat.h
index 6d87321b..f46f25c 100644
--- a/include/ui/PixelFormat.h
+++ b/include/ui/PixelFormat.h
@@ -30,6 +30,7 @@
#include <sys/types.h>
#include <utils/Errors.h>
#include <pixelflinger/format.h>
+#include <hardware/hardware.h>
namespace android {
@@ -57,25 +58,18 @@
// real pixel formats supported for rendering -----------------------------
- PIXEL_FORMAT_RGBA_8888 = GGL_PIXEL_FORMAT_RGBA_8888, // 4x8-bit RGBA
- PIXEL_FORMAT_RGBX_8888 = GGL_PIXEL_FORMAT_RGBX_8888, // 4x8-bit RGB0
- PIXEL_FORMAT_RGB_888 = GGL_PIXEL_FORMAT_RGB_888, // 3x8-bit RGB
- PIXEL_FORMAT_RGB_565 = GGL_PIXEL_FORMAT_RGB_565, // 16-bit RGB
- PIXEL_FORMAT_BGRA_8888 = GGL_PIXEL_FORMAT_BGRA_8888, // 4x8-bit BGRA
- PIXEL_FORMAT_RGBA_5551 = GGL_PIXEL_FORMAT_RGBA_5551, // 16-bit ARGB
- PIXEL_FORMAT_RGBA_4444 = GGL_PIXEL_FORMAT_RGBA_4444, // 16-bit ARGB
+ PIXEL_FORMAT_RGBA_8888 = HAL_PIXEL_FORMAT_RGBA_8888, // 4x8-bit RGBA
+ PIXEL_FORMAT_RGBX_8888 = HAL_PIXEL_FORMAT_RGBX_8888, // 4x8-bit RGB0
+ PIXEL_FORMAT_RGB_888 = HAL_PIXEL_FORMAT_RGB_888, // 3x8-bit RGB
+ PIXEL_FORMAT_RGB_565 = HAL_PIXEL_FORMAT_RGB_565, // 16-bit RGB
+ PIXEL_FORMAT_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888, // 4x8-bit BGRA
+ PIXEL_FORMAT_RGBA_5551 = HAL_PIXEL_FORMAT_RGBA_5551, // 16-bit ARGB
+ PIXEL_FORMAT_RGBA_4444 = HAL_PIXEL_FORMAT_RGBA_4444, // 16-bit ARGB
PIXEL_FORMAT_A_8 = GGL_PIXEL_FORMAT_A_8, // 8-bit A
PIXEL_FORMAT_L_8 = GGL_PIXEL_FORMAT_L_8, // 8-bit L (R=G=B=L)
PIXEL_FORMAT_LA_88 = GGL_PIXEL_FORMAT_LA_88, // 16-bit LA
PIXEL_FORMAT_RGB_332 = GGL_PIXEL_FORMAT_RGB_332, // 8-bit RGB
- PIXEL_FORMAT_YCbCr_422_SP= GGL_PIXEL_FORMAT_YCbCr_422_SP,
- PIXEL_FORMAT_YCbCr_420_SP= GGL_PIXEL_FORMAT_YCbCr_420_SP,
- PIXEL_FORMAT_YCbCr_422_P = GGL_PIXEL_FORMAT_YCbCr_422_P,
- PIXEL_FORMAT_YCbCr_420_P = GGL_PIXEL_FORMAT_YCbCr_420_P,
- PIXEL_FORMAT_YCbCr_422_I = GGL_PIXEL_FORMAT_YCbCr_422_I,
- PIXEL_FORMAT_YCbCr_420_I = GGL_PIXEL_FORMAT_YCbCr_420_I,
-
// New formats can be added if they're also defined in
// pixelflinger/format.h
};
@@ -97,9 +91,7 @@
RGBA = 3,
LUMINANCE = 4,
LUMINANCE_ALPHA = 5,
- Y_CB_CR_SP = 6,
- Y_CB_CR_P = 7,
- Y_CB_CR_I = 8,
+ OTHER = 0xFF
};
struct szinfo {
diff --git a/include/ui/Region.h b/include/ui/Region.h
index 2bcad5b..925fd06 100644
--- a/include/ui/Region.h
+++ b/include/ui/Region.h
@@ -21,7 +21,6 @@
#include <sys/types.h>
#include <utils/Vector.h>
-#include <binder/Parcel.h>
#include <ui/Rect.h>
@@ -39,7 +38,6 @@
Region();
Region(const Region& rhs);
explicit Region(const Rect& rhs);
- explicit Region(const Parcel& parcel);
explicit Region(const void* buffer);
~Region();
@@ -118,10 +116,6 @@
// be sorted in Y and X and must not make the region invalid.
void addRectUnchecked(int l, int t, int r, int b);
- // flatten/unflatten a region to/from a Parcel
- status_t write(Parcel& parcel) const;
- status_t read(const Parcel& parcel);
-
// flatten/unflatten a region to/from a raw buffer
ssize_t write(void* buffer, size_t size) const;
static ssize_t writeEmpty(void* buffer, size_t size);
diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp
index f38efab..c080513 100644
--- a/libs/surfaceflinger/Layer.cpp
+++ b/libs/surfaceflinger/Layer.cpp
@@ -185,20 +185,20 @@
if (res == NO_ERROR) {
int bpp = 0;
switch (t.format) {
- case GGL_PIXEL_FORMAT_RGB_565:
- case GGL_PIXEL_FORMAT_RGBA_4444:
+ case HAL_PIXEL_FORMAT_RGB_565:
+ case HAL_PIXEL_FORMAT_RGBA_4444:
bpp = 2;
break;
- case GGL_PIXEL_FORMAT_RGBA_8888:
- case GGL_PIXEL_FORMAT_RGBX_8888:
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ case HAL_PIXEL_FORMAT_RGBX_8888:
bpp = 4;
break;
- case GGL_PIXEL_FORMAT_YCbCr_422_SP:
- case GGL_PIXEL_FORMAT_YCbCr_420_SP:
- // just show the Y plane of YUV buffers
- bpp = 1;
- break;
default:
+ if (isSupportedYuvFormat(t.format)) {
+ // just show the Y plane of YUV buffers
+ bpp = 1;
+ break;
+ }
// oops, we don't handle this format!
LOGE("layer %p, texture=%d, using format %d, which is not "
"supported by the GL", this, texture->name, t.format);
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp
index 4d7bef8..5b96e9d 100644
--- a/libs/surfaceflinger/LayerBase.cpp
+++ b/libs/surfaceflinger/LayerBase.cpp
@@ -509,6 +509,21 @@
}
}
+bool LayerBase::isSupportedYuvFormat(int format) const
+{
+ switch (format) {
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+ case HAL_PIXEL_FORMAT_YCbCr_422_P:
+ case HAL_PIXEL_FORMAT_YCbCr_420_P:
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ case HAL_PIXEL_FORMAT_YCbCr_420_I:
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ return true;
+ }
+ return false;
+}
+
void LayerBase::loadTexture(Texture* texture,
const Region& dirty, const GGLSurface& t) const
{
@@ -573,21 +588,20 @@
data = t.data;
}
- if (t.format == GGL_PIXEL_FORMAT_RGB_565) {
+ if (t.format == HAL_PIXEL_FORMAT_RGB_565) {
glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGB, texture->potWidth, texture->potHeight, 0,
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data);
- } else if (t.format == GGL_PIXEL_FORMAT_RGBA_4444) {
+ } else if (t.format == HAL_PIXEL_FORMAT_RGBA_4444) {
glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA, texture->potWidth, texture->potHeight, 0,
GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data);
- } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888 ||
- t.format == GGL_PIXEL_FORMAT_RGBX_8888) {
+ } else if (t.format == HAL_PIXEL_FORMAT_RGBA_8888 ||
+ t.format == HAL_PIXEL_FORMAT_RGBX_8888) {
glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA, texture->potWidth, texture->potHeight, 0,
GL_RGBA, GL_UNSIGNED_BYTE, data);
- } else if ( t.format == GGL_PIXEL_FORMAT_YCbCr_422_SP ||
- t.format == GGL_PIXEL_FORMAT_YCbCr_420_SP) {
+ } else if (isSupportedYuvFormat(t.format)) {
// just show the Y plane of YUV buffers
glTexImage2D(GL_TEXTURE_2D, 0,
GL_LUMINANCE, texture->potWidth, texture->potHeight, 0,
@@ -599,24 +613,23 @@
}
}
if (!data) {
- if (t.format == GGL_PIXEL_FORMAT_RGB_565) {
+ if (t.format == HAL_PIXEL_FORMAT_RGB_565) {
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, bounds.top, t.width, bounds.height(),
GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
t.data + bounds.top*t.stride*2);
- } else if (t.format == GGL_PIXEL_FORMAT_RGBA_4444) {
+ } else if (t.format == HAL_PIXEL_FORMAT_RGBA_4444) {
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, bounds.top, t.width, bounds.height(),
GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4,
t.data + bounds.top*t.stride*2);
- } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888 ||
- t.format == GGL_PIXEL_FORMAT_RGBX_8888) {
+ } else if (t.format == HAL_PIXEL_FORMAT_RGBA_8888 ||
+ t.format == HAL_PIXEL_FORMAT_RGBX_8888) {
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, bounds.top, t.width, bounds.height(),
GL_RGBA, GL_UNSIGNED_BYTE,
t.data + bounds.top*t.stride*4);
- } else if ( t.format == GGL_PIXEL_FORMAT_YCbCr_422_SP ||
- t.format == GGL_PIXEL_FORMAT_YCbCr_420_SP) {
+ } else if (isSupportedYuvFormat(t.format)) {
// just show the Y plane of YUV buffers
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, bounds.top, t.width, bounds.height(),
diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h
index a49faf7..d1bbd04 100644
--- a/libs/surfaceflinger/LayerBase.h
+++ b/libs/surfaceflinger/LayerBase.h
@@ -265,6 +265,7 @@
status_t initializeEglImage(
const sp<GraphicBuffer>& buffer, Texture* texture);
+ bool isSupportedYuvFormat(int format) const;
sp<SurfaceFlinger> mFlinger;
uint32_t mFlags;
diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp
index bd3113b..6d1685b 100644
--- a/libs/surfaceflinger/LayerBuffer.cpp
+++ b/libs/surfaceflinger/LayerBuffer.cpp
@@ -472,10 +472,12 @@
// First, try to use the buffer as an EGLImage directly
if (mUseEGLImageDirectly) {
// NOTE: Assume the buffer is allocated with the proper USAGE flags
+
sp<GraphicBuffer> buffer = new GraphicBuffer(
src.img.w, src.img.h, src.img.format,
GraphicBuffer::USAGE_HW_TEXTURE,
src.img.w, src.img.handle, false);
+
err = mLayer.initializeEglImage(buffer, &mTexture);
if (err != NO_ERROR) {
mUseEGLImageDirectly = false;
@@ -563,33 +565,27 @@
}
// Allocate a temporary buffer and create the corresponding EGLImageKHR
-
- status_t err;
- mTempGraphicBuffer.clear();
- mTempGraphicBuffer = new GraphicBuffer(
+ // once the EGLImage has been created we don't need the
+ // graphic buffer reference anymore.
+ sp<GraphicBuffer> buffer = new GraphicBuffer(
w, h, HAL_PIXEL_FORMAT_RGB_565,
GraphicBuffer::USAGE_HW_TEXTURE |
GraphicBuffer::USAGE_HW_2D);
- err = mTempGraphicBuffer->initCheck();
+ status_t err = buffer->initCheck();
if (err == NO_ERROR) {
NativeBuffer& dst(mTempBuffer);
- dst.img.w = mTempGraphicBuffer->getStride();
+ dst.img.w = buffer->getStride();
dst.img.h = h;
- dst.img.format = mTempGraphicBuffer->getPixelFormat();
- dst.img.handle = (native_handle_t *)mTempGraphicBuffer->handle;
+ dst.img.format = buffer->getPixelFormat();
+ dst.img.handle = (native_handle_t *)buffer->handle;
dst.img.base = 0;
dst.crop.l = 0;
dst.crop.t = 0;
dst.crop.r = w;
dst.crop.b = h;
- err = mLayer.initializeEglImage(
- mTempGraphicBuffer, &mTexture);
- // once the EGLImage has been created (whether it fails
- // or not) we don't need the graphic buffer reference
- // anymore.
- mTempGraphicBuffer.clear();
+ err = mLayer.initializeEglImage(buffer, &mTexture);
}
return err;
@@ -606,9 +602,6 @@
Texture defaultTexture;
mTexture = defaultTexture;
mTexture.name = mLayer.createTexture();
-
- // and the associated buffer
- mTempGraphicBuffer.clear();
}
// ---------------------------------------------------------------------------
diff --git a/libs/surfaceflinger/LayerBuffer.h b/libs/surfaceflinger/LayerBuffer.h
index 3257b76..eb5b8eb 100644
--- a/libs/surfaceflinger/LayerBuffer.h
+++ b/libs/surfaceflinger/LayerBuffer.h
@@ -144,7 +144,6 @@
size_t mBufferSize;
mutable LayerBase::Texture mTexture;
mutable NativeBuffer mTempBuffer;
- mutable sp<GraphicBuffer> mTempGraphicBuffer;
mutable bool mUseEGLImageDirectly;
};
diff --git a/libs/surfaceflinger_client/LayerState.cpp b/libs/surfaceflinger_client/LayerState.cpp
index 114a9e9..01c4c7e 100644
--- a/libs/surfaceflinger_client/LayerState.cpp
+++ b/libs/surfaceflinger_client/LayerState.cpp
@@ -22,17 +22,37 @@
status_t layer_state_t::write(Parcel& output) const
{
+ status_t err;
+
+ size_t len = transparentRegion.write(NULL, 0);
+ err = output.writeInt32(len);
+ if (err < NO_ERROR) return err;
+
+ void* buf = output.writeInplace(len);
+ if (buf == NULL) return NO_MEMORY;
+
+ err = transparentRegion.write(buf, len);
+ if (err < NO_ERROR) return err;
+
+ // NOTE: regions are at the end of the structure
size_t size = sizeof(layer_state_t);
- transparentRegion.write(output);
size -= sizeof(transparentRegion);
- output.write(this, size);
- return NO_ERROR;
+ err = output.write(this, size);
+ return err;
}
status_t layer_state_t::read(const Parcel& input)
{
+ status_t err;
+ size_t len = input.readInt32();
+ void const* buf = input.readInplace(len);
+ if (buf == NULL) return NO_MEMORY;
+
+ err = transparentRegion.read(buf);
+ if (err < NO_ERROR) return err;
+
+ // NOTE: regions are at the end of the structure
size_t size = sizeof(layer_state_t);
- transparentRegion.read(input);
size -= sizeof(transparentRegion);
input.read(this, size);
return NO_ERROR;
diff --git a/libs/ui/PixelFormat.cpp b/libs/ui/PixelFormat.cpp
index b65ed97..9b41804 100644
--- a/libs/ui/PixelFormat.cpp
+++ b/libs/ui/PixelFormat.cpp
@@ -16,14 +16,17 @@
#include <ui/PixelFormat.h>
#include <pixelflinger/format.h>
+#include <hardware/hardware.h>
namespace android {
+static const int COMPONENT_YUV = 0xFF;
+
size_t PixelFormatInfo::getScanlineSize(unsigned int width) const
{
size_t size;
- if ((components >= 6) && (components <= 8)) {
- // YCbCr formats are differents.
+ if (components == COMPONENT_YUV) {
+ // YCbCr formats are different.
size = (width * bitsPerPixel)>>3;
} else {
size = width * bytesPerPixel;
@@ -53,14 +56,42 @@
if (info->version != sizeof(PixelFormatInfo))
return INVALID_OPERATION;
+ // YUV format from the HAL are handled here
+ switch (format) {
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ case HAL_PIXEL_FORMAT_YCrCb_422_SP:
+ case HAL_PIXEL_FORMAT_YCbCr_422_P:
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ case HAL_PIXEL_FORMAT_CbYCrY_422_I:
+ info->bitsPerPixel = 16;
+ goto done;
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP_TILED:
+ case HAL_PIXEL_FORMAT_YCbCr_420_P:
+ case HAL_PIXEL_FORMAT_YCbCr_420_I:
+ case HAL_PIXEL_FORMAT_CbYCrY_420_I:
+ info->bitsPerPixel = 12;
+ done:
+ info->format = format;
+ info->components = COMPONENT_YUV;
+ info->bytesPerPixel = 1;
+ info->h_alpha = 0;
+ info->l_alpha = 0;
+ info->h_red = info->h_green = info->h_blue = 8;
+ info->l_red = info->l_green = info->l_blue = 0;
+ return NO_ERROR;
+ }
+
size_t numEntries;
const GGLFormat *i = gglGetPixelFormatTable(&numEntries) + format;
bool valid = uint32_t(format) < numEntries;
if (!valid) {
return BAD_INDEX;
}
-
- #define COMPONENT(name) \
+
+ #define COMPONENT(name) \
case GGL_##name: info->components = PixelFormatInfo::name; break;
switch (i->components) {
@@ -69,9 +100,6 @@
COMPONENT(RGBA)
COMPONENT(LUMINANCE)
COMPONENT(LUMINANCE_ALPHA)
- COMPONENT(Y_CB_CR_SP)
- COMPONENT(Y_CB_CR_P)
- COMPONENT(Y_CB_CR_I)
default:
return BAD_INDEX;
}
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp
index d21ed57..12db908 100644
--- a/libs/ui/Region.cpp
+++ b/libs/ui/Region.cpp
@@ -63,16 +63,10 @@
{
}
-Region::Region(const Parcel& parcel)
-{
- status_t err = read(parcel);
- LOGE_IF(err<0, "error %s reading Region from parcel", strerror(err));
-}
-
Region::Region(const void* buffer)
{
status_t err = read(buffer);
- LOGE_IF(err<0, "error %s reading Region from parcel", strerror(err));
+ LOGE_IF(err<0, "error %s reading Region from buffer", strerror(err));
}
Region::~Region()
@@ -532,37 +526,6 @@
// ----------------------------------------------------------------------------
-status_t Region::write(Parcel& parcel) const
-{
-#if VALIDATE_REGIONS
- validate(*this, "write(Parcel)");
-#endif
- status_t err;
- const size_t count = mStorage.size();
- const size_t sizeNeeded = sizeof(int32_t) + (1+count)*sizeof(Rect);
- void* buffer = parcel.writeInplace(sizeNeeded);
- if (!buffer) return NO_MEMORY;
- ssize_t written = Region::write(buffer, sizeNeeded);
- if (written < 0) return status_t(written);
- return NO_ERROR;
-}
-
-status_t Region::read(const Parcel& parcel)
-{
- void const* buffer = parcel.readInplace(sizeof(int32_t));
- if (!buffer) return NO_MEMORY;
- const size_t count = *static_cast<int32_t const *>(buffer);
- void const* dummy = parcel.readInplace((1+count)*sizeof(Rect));
- if (!dummy) return NO_MEMORY;
- const size_t sizeNeeded = sizeof(int32_t) + (1+count)*sizeof(Rect);
- const ssize_t read = Region::read(buffer);
- if (read < 0) return status_t(read);
-#if VALIDATE_REGIONS
- validate(*this, "read(Parcel)");
-#endif
- return NO_ERROR;
-}
-
ssize_t Region::write(void* buffer, size_t size) const
{
#if VALIDATE_REGIONS
@@ -570,12 +533,14 @@
#endif
const size_t count = mStorage.size();
const size_t sizeNeeded = sizeof(int32_t) + (1+count)*sizeof(Rect);
- if (sizeNeeded > size) return NO_MEMORY;
- int32_t* const p = static_cast<int32_t*>(buffer);
- *p = count;
- memcpy(p+1, &mBounds, sizeof(Rect));
- if (count) {
- memcpy(p+5, mStorage.array(), count*sizeof(Rect));
+ if (buffer != NULL) {
+ if (sizeNeeded > size) return NO_MEMORY;
+ int32_t* const p = static_cast<int32_t*>(buffer);
+ *p = count;
+ memcpy(p+1, &mBounds, sizeof(Rect));
+ if (count) {
+ memcpy(p+5, mStorage.array(), count*sizeof(Rect));
+ }
}
return ssize_t(sizeNeeded);
}
diff --git a/opengl/libagl/copybit.cpp b/opengl/libagl/copybit.cpp
index 4cacc11..67d1ce7 100644
--- a/opengl/libagl/copybit.cpp
+++ b/opengl/libagl/copybit.cpp
@@ -48,19 +48,8 @@
const GGLSurface* surface, int32_t opFormat,
android_native_buffer_t* buffer, copybit_image_t* img)
{
- uint32_t vstride = 0;
- if (opFormat == COPYBIT_FORMAT_YCbCr_422_SP ||
- opFormat == COPYBIT_FORMAT_YCbCr_420_SP) {
- // NOTE: this static_cast is really not safe b/c we can't know for
- // sure the buffer passed is of the right type.
- // However, since we do this only for YUV formats, we should be safe
- // since only SurfaceFlinger makes use of them.
- GraphicBuffer* graphicBuffer = static_cast<GraphicBuffer*>(buffer);
- vstride = graphicBuffer->getVerticalStride();
- }
-
img->w = surface->stride;
- img->h = vstride ? vstride : surface->height;
+ img->h = surface->height;
img->format = opFormat;
img->base = surface->data;
img->handle = (native_handle_t *)buffer->handle;
@@ -98,8 +87,6 @@
case COPYBIT_FORMAT_BGRA_8888:
case COPYBIT_FORMAT_RGBA_5551:
case COPYBIT_FORMAT_RGBA_4444:
- case COPYBIT_FORMAT_YCbCr_422_SP:
- case COPYBIT_FORMAT_YCbCr_420_SP:
return true;
default:
return false;