merge in jb-mr2-release history after reset to master
diff --git a/Source/WebCore/platform/graphics/android/layers/CanvasTexture.cpp b/Source/WebCore/platform/graphics/android/layers/CanvasTexture.cpp
index dca0dcd..ccab443 100644
--- a/Source/WebCore/platform/graphics/android/layers/CanvasTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/CanvasTexture.cpp
@@ -42,7 +42,7 @@
 
 #include <android/native_window.h>
 #include <gui/GLConsumer.h>
-#include <gui/SurfaceTextureClient.h>
+#include <gui/Surface.h>
 
 namespace WebCore {
 
@@ -98,7 +98,7 @@
     }
 }
 
-SurfaceTextureClient* CanvasTexture::nativeWindow()
+android::Surface* CanvasTexture::nativeWindow()
 {
     android::Mutex::Autolock lock(m_surfaceLock);
     if (m_ANW.get())
@@ -108,7 +108,7 @@
     if (!useSurfaceTexture())
         return 0;
     m_surfaceTexture = new android::GLConsumer(m_texture, false);
-    m_ANW = new android::SurfaceTextureClient(m_surfaceTexture->getBufferQueue());
+    m_ANW = new android::Surface(m_surfaceTexture->getBufferQueue());
     int result = native_window_set_buffers_format(m_ANW.get(), HAL_PIXEL_FORMAT_RGBA_8888);
     GLUtils::checkSurfaceTextureError("native_window_set_buffers_format", result);
     if (result == NO_ERROR) {
@@ -127,7 +127,7 @@
 bool CanvasTexture::uploadImageBuffer(ImageBuffer* imageBuffer)
 {
     m_hasValidTexture = false;
-    SurfaceTextureClient* anw = nativeWindow();
+    android::Surface* anw = nativeWindow();
     if (!anw)
         return false;
     // Size mismatch, early abort (will fall back to software)
diff --git a/Source/WebCore/platform/graphics/android/layers/CanvasTexture.h b/Source/WebCore/platform/graphics/android/layers/CanvasTexture.h
index f8c2f95..1561434 100644
--- a/Source/WebCore/platform/graphics/android/layers/CanvasTexture.h
+++ b/Source/WebCore/platform/graphics/android/layers/CanvasTexture.h
@@ -35,7 +35,7 @@
 
 namespace android {
 class GLConsumer;
-class SurfaceTextureClient;
+class Surface;
 }
 
 namespace WebCore {
@@ -53,7 +53,7 @@
      * Called by WebKit thread
      ********************************************/
     void setSize(const IntSize& size);
-    SurfaceTextureClient* nativeWindow();
+    android::Surface* nativeWindow();
     bool uploadImageBuffer(ImageBuffer* imageBuffer);
     bool hasValidTexture() { return m_hasValidTexture; }
 
@@ -82,7 +82,7 @@
     GLuint m_texture;
     android::Mutex m_surfaceLock;
     sp<android::GLConsumer> m_surfaceTexture;
-    sp<android::SurfaceTextureClient> m_ANW;
+    sp<android::Surface> m_ANW;
     bool m_hasValidTexture;
     bool m_useHwAcceleration;
 
diff --git a/Source/WebCore/platform/graphics/android/layers/MediaLayer.h b/Source/WebCore/platform/graphics/android/layers/MediaLayer.h
index 188252b..fb24d1c 100644
--- a/Source/WebCore/platform/graphics/android/layers/MediaLayer.h
+++ b/Source/WebCore/platform/graphics/android/layers/MediaLayer.h
@@ -47,7 +47,7 @@
     void invertContents(bool invert) { m_mediaTexture->invertContents(invert); }
     void setOutlineSize(int size) { m_outlineSize = size; }
 
-    // function to setup the primary SurfaceTextureClient in the renderer's context
+    // function to setup the primary Surface in the renderer's context
     ANativeWindow* acquireNativeWindowForContent();
 
     // functions to manipulate secondary layers for video playback
@@ -60,7 +60,7 @@
     bool m_isCopy;
     int m_outlineSize;
 
-    // SurfaceTextureClient member variables
+    // Surface member variables
     MediaTexture* m_mediaTexture;
 };
 
diff --git a/Source/WebCore/platform/graphics/android/layers/MediaListener.h b/Source/WebCore/platform/graphics/android/layers/MediaListener.h
index f02ff7c..74eb59a 100644
--- a/Source/WebCore/platform/graphics/android/layers/MediaListener.h
+++ b/Source/WebCore/platform/graphics/android/layers/MediaListener.h
@@ -20,7 +20,7 @@
 #if USE(ACCELERATED_COMPOSITING)
 
 #include <gui/GLConsumer.h>
-#include <gui/SurfaceTextureClient.h>
+#include <gui/Surface.h>
 #include <jni.h>
 #include <JNIUtility.h>
 #include "MediaTexture.h"
diff --git a/Source/WebCore/platform/graphics/android/layers/MediaTexture.cpp b/Source/WebCore/platform/graphics/android/layers/MediaTexture.cpp
index 67324c7..b001c1a 100644
--- a/Source/WebCore/platform/graphics/android/layers/MediaTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/MediaTexture.cpp
@@ -30,7 +30,7 @@
 
 #include <android/native_window.h>
 #include <gui/GLConsumer.h>
-#include <gui/SurfaceTextureClient.h>
+#include <gui/Surface.h>
 #include <JNIUtility.h>
 #include "WebCoreJni.h"
 
@@ -281,7 +281,7 @@
     // populate the wrapper
     glGenTextures(1, &wrapper->textureId);
     wrapper->surfaceTexture = new android::GLConsumer(wrapper->textureId);
-    wrapper->nativeWindow = new android::SurfaceTextureClient(
+    wrapper->nativeWindow = new android::Surface(
             wrapper->surfaceTexture->getBufferQueue());
     wrapper->dimensions.setEmpty();
 
diff --git a/Source/WebCore/platform/graphics/android/rendering/GaneshRenderer.cpp b/Source/WebCore/platform/graphics/android/rendering/GaneshRenderer.cpp
index ed57613..4eace7c 100644
--- a/Source/WebCore/platform/graphics/android/rendering/GaneshRenderer.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/GaneshRenderer.cpp
@@ -91,7 +91,7 @@
     GaneshContext::instance()->flush();
 
     // In SurfaceTextureMode we must call swapBuffers to unlock and post the
-    // tile's ANativeWindow (i.e. SurfaceTextureClient) buffer
+    // tile's ANativeWindow (i.e. Surface) buffer
     TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
     eglSwapBuffers(eglGetCurrentDisplay(), tileQueue->m_eglSurface);
     SkBitmap dummyBitmap;
diff --git a/Source/WebCore/platform/graphics/android/rendering/TextureInfo.cpp b/Source/WebCore/platform/graphics/android/rendering/TextureInfo.cpp
index 714410e..32237cd 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TextureInfo.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/TextureInfo.cpp
@@ -31,7 +31,7 @@
 #include <JNIUtility.h>
 #include <android/native_window.h>
 #include <gui/GLConsumer.h>
-#include <gui/SurfaceTextureClient.h>
+#include <gui/Surface.h>
 
 namespace WebCore {
 
diff --git a/Source/WebCore/platform/graphics/android/rendering/TilesManager.cpp b/Source/WebCore/platform/graphics/android/rendering/TilesManager.cpp
index 0ab74aa..f44f79d 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TilesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/TilesManager.cpp
@@ -43,7 +43,7 @@
 #include <android/native_window.h>
 #include <cutils/atomic.h>
 #include <gui/GLConsumer.h>
-#include <gui/SurfaceTextureClient.h>
+#include <gui/Surface.h>
 #include <wtf/CurrentTime.h>
 
 // Important: We need at least twice as many textures as is needed to cover
diff --git a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp
index 0db91bd..81b3ff4 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp
@@ -40,7 +40,7 @@
 #include "TilesManager.h"
 #include <android/native_window.h>
 #include <gui/GLConsumer.h>
-#include <gui/SurfaceTextureClient.h>
+#include <gui/Surface.h>
 
 // For simple webView usage, MINIMAL_SIZE is recommended for memory saving.
 // In browser case, EFFICIENT_SIZE is preferred.
@@ -113,7 +113,7 @@
                                         GL_TEXTURE_EXTERNAL_OES, true,
                                         bufferQueue);
 #endif
-        m_ANW = new android::SurfaceTextureClient(bufferQueue);
+        m_ANW = new android::Surface(bufferQueue);
         m_sharedSurfaceTexture->setSynchronousMode(true);
 
         int extraBuffersNeeded = 0;
diff --git a/Source/WebKit/android/plugins/ANPSurfaceInterface.cpp b/Source/WebKit/android/plugins/ANPSurfaceInterface.cpp
index 2b593e2..1b699de 100644
--- a/Source/WebKit/android/plugins/ANPSurfaceInterface.cpp
+++ b/Source/WebKit/android/plugins/ANPSurfaceInterface.cpp
@@ -35,6 +35,7 @@
 #include <ui/Rect.h>
 #include <ui/Region.h>
 #include <utils/RefBase.h>
+#include <android_runtime/android_view_Surface.h>
 
 using namespace android;
 
@@ -43,7 +44,6 @@
     bool        initialized;
     jmethodID   getSurfaceHolder;
     jmethodID   getSurface;
-    jfieldID    surfacePointer;
 } gSurfaceJavaGlue;
 
 static inline sp<android::Surface> getSurface(JNIEnv* env, jobject view) {
@@ -61,11 +61,6 @@
         gSurfaceJavaGlue.getSurface = env->GetMethodID(surfaceHolderClass, "getSurface",
                                                        "()Landroid/view/Surface;");
 
-        jclass surfaceClass = env->FindClass("android/view/Surface");
-        gSurfaceJavaGlue.surfacePointer = env->GetFieldID(surfaceClass,
-                ANDROID_VIEW_SURFACE_JNI_ID, "I");
-
-        env->DeleteLocalRef(surfaceClass);
         env->DeleteLocalRef(surfaceViewClass);
         env->DeleteLocalRef(surfaceHolderClass);
 
@@ -74,12 +69,13 @@
 
     jobject holder = env->CallObjectMethod(view, gSurfaceJavaGlue.getSurfaceHolder);
     jobject surface = env->CallObjectMethod(holder, gSurfaceJavaGlue.getSurface);
-    jint surfacePointer = env->GetIntField(surface, gSurfaceJavaGlue.surfacePointer);
+
+    sp<android::Surface> sur = android_view_Surface_getSurface(env, surface);
 
     env->DeleteLocalRef(holder);
     env->DeleteLocalRef(surface);
 
-    return sp<android::Surface>((android::Surface*) surfacePointer);
+    return sur;
 }
 
 static inline ANPBitmapFormat convertPixelFormat(PixelFormat format) {
@@ -111,14 +107,17 @@
         dirtyRegion.set(Rect(0x3FFF, 0x3FFF));
     }
 
-    android::Surface::SurfaceInfo info;
-    status_t err = surface->lock(&info, &dirtyRegion);
+
+    ANativeWindow_Buffer outBuffer;
+    Rect dirtyBounds(dirtyRegion.getBounds());
+    status_t err = surface->lock(&outBuffer, &dirtyBounds);
     if (err < 0) {
         return false;
     }
 
     // the surface may have expanded the dirty region so we must to pass that
     // information back to the plugin.
+    dirtyRegion.set(dirtyBounds);
     if (dirtyRect) {
         Rect dirtyBounds = dirtyRegion.getBounds();
         dirtyRect->left = dirtyBounds.left;
@@ -127,15 +126,15 @@
         dirtyRect->bottom = dirtyBounds.bottom;
     }
 
-    ssize_t bpr = info.s * bytesPerPixel(info.format);
+    ssize_t bpr = outBuffer.stride * bytesPerPixel(outBuffer.format);
 
-    bitmap->format = convertPixelFormat(info.format);
-    bitmap->width = info.w;
-    bitmap->height = info.h;
+    bitmap->format = convertPixelFormat(outBuffer.format);
+    bitmap->width = outBuffer.width;
+    bitmap->height = outBuffer.height;
     bitmap->rowBytes = bpr;
 
-    if (info.w > 0 && info.h > 0) {
-        bitmap->baseAddr = info.bits;
+    if (outBuffer.width > 0 && outBuffer.height > 0) {
+        bitmap->baseAddr = outBuffer.bits;
     } else {
         bitmap->baseAddr = NULL;
         return false;