am 11d7657e: Merge "Switch to prebuilt bison"

* commit '11d7657ebc4dfb1462db8cdc8b48ffa25478e442':
  Switch to prebuilt bison
diff --git a/Android.mk b/Android.mk
index 693b88d..fb7cf3d 100644
--- a/Android.mk
+++ b/Android.mk
@@ -26,7 +26,7 @@
 # Control SVG compiling in webkit.
 # Default is true unless explictly disabled.
 ifneq ($(ENABLE_SVG),false)
-    ENABLE_SVG = true
+    ENABLE_SVG := true
 endif
 
 # Control complex scripts support compiling in webkit.
@@ -98,6 +98,8 @@
 	external/skia/include/images \
 	external/skia/include/ports \
 	external/skia/include/utils \
+	external/skia/src/core \
+	external/skia/src/images \
 	external/skia/src/ports \
 	external/sqlite/dist \
 	frameworks/base/core/jni/android/graphics \
@@ -309,7 +311,6 @@
 	libicuuc \
 	libicui18n \
 	libmedia \
-	libmedia_native \
 	libnativehelper \
 	libskia \
 	libsqlite \
@@ -334,7 +335,7 @@
 endif
 
 # Build the list of static libraries
-LOCAL_STATIC_LIBRARIES := libxml2 libxslt libhyphenation libskiagpu libv8
+LOCAL_STATIC_LIBRARIES := libxml2 libxslt libhyphenation libv8
 
 ifeq ($(ENABLE_AUTOFILL),true)
 LOCAL_SHARED_LIBRARIES += libexpat
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk
index 10eb822..c2bbd42 100644
--- a/Source/WebCore/Android.mk
+++ b/Source/WebCore/Android.mk
@@ -699,8 +699,7 @@
 	platform/graphics/android/rendering/TilesProfiler.cpp \
 	platform/graphics/android/rendering/TransferQueue.cpp \
 	\
-	platform/graphics/android/utils/ClassTracker.cpp \
-	platform/graphics/android/utils/LinearAllocator.cpp
+	platform/graphics/android/utils/ClassTracker.cpp
 
 ifeq ($(ENABLE_SVG), true)
 LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp b/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp
index 957040b..e69c145 100644
--- a/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp
@@ -102,15 +102,13 @@
 
 GraphicsContext* GraphicsContext::createOffscreenContext(int width, int height)
 {
-    PlatformGraphicsContextSkia* pgc = new PlatformGraphicsContextSkia(new SkCanvas, true);
-
     SkBitmap bitmap;
-
     bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
     bitmap.allocPixels();
     bitmap.eraseColor(0);
-    pgc->canvas()->setBitmapDevice(bitmap);
 
+    PlatformGraphicsContextSkia* pgc =
+        new PlatformGraphicsContextSkia(new SkCanvas(bitmap), true);
     GraphicsContext* ctx = new GraphicsContext(pgc);
     return ctx;
 }
diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.cpp b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.cpp
index ab6e676..d24ce35 100644
--- a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.cpp
+++ b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.cpp
@@ -28,12 +28,12 @@
 #include "GraphicsOperation.h"
 
 #include "AndroidLog.h"
-#include "LinearAllocator.h"
+#include <utils/LinearAllocator.h>
 
 namespace WebCore {
 namespace GraphicsOperation {
 
-void* Operation::operator new(size_t size, LinearAllocator* allocator)
+void* Operation::operator new(size_t size, android::LinearAllocator* allocator)
 {
     return allocator->alloc(size);
 }
diff --git a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h
index edcdc35..c3f54d6 100644
--- a/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h
+++ b/Source/WebCore/platform/graphics/android/context/GraphicsOperation.h
@@ -50,10 +50,13 @@
 #define TYPE(x)
 #endif
 
+namespace android {
+class LinearAllocator;
+}
+
 namespace WebCore {
 
 class CanvasState;
-class LinearAllocator;
 
 namespace GraphicsOperation {
 
@@ -64,7 +67,7 @@
         , m_canvasState(0)
     {}
 
-    void* operator new(size_t size, LinearAllocator* allocator);
+    void* operator new(size_t size, android::LinearAllocator* allocator);
 
     // Purposely not implemented - use a LinearAllocator please
     void* operator new(size_t size);
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
index 10bf363..d296b75 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp
@@ -35,7 +35,6 @@
 #include "Font.h"
 #include "GraphicsContext.h"
 #include "GraphicsOperation.h"
-#include "LinearAllocator.h"
 #include "PlatformGraphicsContextSkia.h"
 #include "RTree.h"
 #include "SkDevice.h"
@@ -44,6 +43,8 @@
 #include "wtf/HashSet.h"
 #include "wtf/StringHasher.h"
 
+#include <utils/LinearAllocator.h>
+
 #define NEW_OP(X) new (heap()) GraphicsOperation::X
 
 #define USE_CLIPPING_PAINTER true
@@ -194,7 +195,7 @@
         return m_isTransparencyLayer;
     }
 
-    void* operator new(size_t size, LinearAllocator* la) {
+    void* operator new(size_t size, android::LinearAllocator* la) {
         return la->alloc(size);
     }
 
@@ -210,7 +211,7 @@
     // Careful, ordering matters here. Ordering is first constructed == last destroyed,
     // so we have to make sure our Heap is the first thing listed so that it is
     // the last thing destroyed.
-    LinearAllocator m_heap;
+    android::LinearAllocator m_heap;
 public:
     RecordingImpl()
         : m_tree(&m_heap)
@@ -287,7 +288,7 @@
         toState->playback(context, fromId, toId);
     }
 
-    LinearAllocator* heap() { return &m_heap; }
+    android::LinearAllocator* heap() { return &m_heap; }
 
     RTree::RTree m_tree;
     int m_nodeCount;
@@ -1080,7 +1081,7 @@
     mRecordingStateStack.last().mCanvasState->adoptAndAppend(data);
 }
 
-LinearAllocator* PlatformGraphicsContextRecording::heap()
+android::LinearAllocator* PlatformGraphicsContextRecording::heap()
 {
     return mRecording->recording()->heap();
 }
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
index eefd270..1a703cf 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h
@@ -31,13 +31,16 @@
 #include "RecordingContextCanvasProxy.h"
 #include "SkRefCnt.h"
 
+namespace android {
+class LinearAllocator;
+}
+
 namespace WebCore {
 namespace GraphicsOperation {
 class Operation;
 }
 
 class CanvasState;
-class LinearAllocator;
 class RecordingImpl;
 class PlatformGraphicsContextSkia;
 class RecordingData;
@@ -161,7 +164,7 @@
     void popMatrix();
     IntRect calculateFinalBounds(FloatRect bounds);
     IntRect calculateCoveredBounds(FloatRect bounds);
-    LinearAllocator* heap();
+    android::LinearAllocator* heap();
 
     SkPicture* mPicture;
     SkMatrix* mCurrentMatrix;
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.cpp
index 915970b..b9fc2f5 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.cpp
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.cpp
@@ -9,6 +9,7 @@
 #include "GraphicsContext.h"
 #include "SkCanvas.h"
 #include "SkCornerPathEffect.h"
+#include "SkMathPriv.h"
 #include "SkPaint.h"
 #include "SkShader.h"
 #include "SkiaUtils.h"
@@ -272,8 +273,7 @@
     for (size_t i = 1; i < numPoints; i++)
         path.lineTo(SkFloatToScalar(points[i].x()), SkFloatToScalar(points[i].y()));
 
-    if (mCanvas->quickReject(path, shouldAntialias ?
-            SkCanvas::kAA_EdgeType : SkCanvas::kBW_EdgeType)) {
+    if (mCanvas->quickReject(path)) {
         return;
     }
 
diff --git a/Source/WebCore/platform/graphics/android/context/RTree.cpp b/Source/WebCore/platform/graphics/android/context/RTree.cpp
index 2e24c34..1e11f58 100644
--- a/Source/WebCore/platform/graphics/android/context/RTree.cpp
+++ b/Source/WebCore/platform/graphics/android/context/RTree.cpp
@@ -31,11 +31,11 @@
 #include "RTree.h"
 
 #include "AndroidLog.h"
-#include "LinearAllocator.h"
+#include <utils/LinearAllocator.h>
 
 namespace WebCore {
 
-void* RecordingData::operator new(size_t size, LinearAllocator* allocator)
+void* RecordingData::operator new(size_t size, android::LinearAllocator* allocator)
 {
     return allocator->alloc(size);
 }
@@ -132,7 +132,7 @@
 //
 //////////////////////////////////////////////////////////////////////
 
-RTree::RTree(WebCore::LinearAllocator* allocator, int M)
+RTree::RTree(android::LinearAllocator* allocator, int M)
     : m_allocator(allocator)
 {
     m_maxChildren = M;
diff --git a/Source/WebCore/platform/graphics/android/context/RTree.h b/Source/WebCore/platform/graphics/android/context/RTree.h
index 50962ef..8d9a359 100644
--- a/Source/WebCore/platform/graphics/android/context/RTree.h
+++ b/Source/WebCore/platform/graphics/android/context/RTree.h
@@ -30,9 +30,11 @@
 #include "IntRect.h"
 #include "GraphicsOperation.h"
 
-namespace WebCore {
-
+namespace android {
 class LinearAllocator;
+}
+
+namespace WebCore {
 
 class RecordingData {
 public:
@@ -47,7 +49,7 @@
     size_t m_orderBy;
     GraphicsOperation::Operation* m_operation;
 
-    void* operator new(size_t size, LinearAllocator* allocator);
+    void* operator new(size_t size, android::LinearAllocator* allocator);
 
     // Purposely not implemented - use a LinearAllocator please
     void* operator new(size_t size);
@@ -64,7 +66,7 @@
 class RTree {
 public:
     // M -- max number of children per node
-    RTree(WebCore::LinearAllocator* allocator, int M = 10);
+    RTree(android::LinearAllocator* allocator, int M = 10);
     ~RTree();
 
     void insert(WebCore::IntRect& bounds, WebCore::RecordingData* payload);
@@ -84,7 +86,7 @@
     unsigned m_maxChildren;
     ElementList* m_listA;
     ElementList* m_listB;
-    WebCore::LinearAllocator* m_allocator;
+    android::LinearAllocator* m_allocator;
 
     friend class Node;
 };
diff --git a/Source/WebCore/platform/graphics/android/layers/CanvasLayer.cpp b/Source/WebCore/platform/graphics/android/layers/CanvasLayer.cpp
index 4a7f161..1a51c4f 100644
--- a/Source/WebCore/platform/graphics/android/layers/CanvasLayer.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/CanvasLayer.cpp
@@ -121,7 +121,7 @@
 void CanvasLayer::canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect)
 {
     if (!m_texture->hasValidTexture()) {
-        // We only need to track invals if we aren't using a SurfaceTexture.
+        // We only need to track invals if we aren't using a GLConsumer.
         // If we drop out of hwa, we will do a full inval anyway
         SkIRect irect = SkIRect::MakeXYWH(changedRect.x(), changedRect.y(),
                                           changedRect.width(), changedRect.height());
diff --git a/Source/WebCore/platform/graphics/android/layers/CanvasTexture.cpp b/Source/WebCore/platform/graphics/android/layers/CanvasTexture.cpp
index aacb0bc..ccab443 100644
--- a/Source/WebCore/platform/graphics/android/layers/CanvasTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/CanvasTexture.cpp
@@ -41,8 +41,8 @@
 #include "SkPixelRef.h"
 
 #include <android/native_window.h>
-#include <gui/SurfaceTexture.h>
-#include <gui/SurfaceTextureClient.h>
+#include <gui/GLConsumer.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())
@@ -107,8 +107,8 @@
         return 0;
     if (!useSurfaceTexture())
         return 0;
-    m_surfaceTexture = new android::SurfaceTexture(m_texture, false);
-    m_ANW = new android::SurfaceTextureClient(m_surfaceTexture);
+    m_surfaceTexture = new android::GLConsumer(m_texture, false);
+    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 98962a0..1561434 100644
--- a/Source/WebCore/platform/graphics/android/layers/CanvasTexture.h
+++ b/Source/WebCore/platform/graphics/android/layers/CanvasTexture.h
@@ -34,8 +34,8 @@
 #include <utils/threads.h>
 
 namespace android {
-class SurfaceTexture;
-class SurfaceTextureClient;
+class GLConsumer;
+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; }
 
@@ -81,8 +81,8 @@
     int m_layerId;
     GLuint m_texture;
     android::Mutex m_surfaceLock;
-    sp<android::SurfaceTexture> m_surfaceTexture;
-    sp<android::SurfaceTextureClient> m_ANW;
+    sp<android::GLConsumer> m_surfaceTexture;
+    sp<android::Surface> m_ANW;
     bool m_hasValidTexture;
     bool m_useHwAcceleration;
 
diff --git a/Source/WebCore/platform/graphics/android/layers/FixedPositioning.h b/Source/WebCore/platform/graphics/android/layers/FixedPositioning.h
index ac838c8..5b22488 100644
--- a/Source/WebCore/platform/graphics/android/layers/FixedPositioning.h
+++ b/Source/WebCore/platform/graphics/android/layers/FixedPositioning.h
@@ -134,7 +134,7 @@
 
     // ViewStateSerializer friends
     friend void android::serializeLayer(LayerAndroid* layer, SkWStream* stream);
-    friend LayerAndroid* android::deserializeLayer(int version, SkStream* stream);
+    friend LayerAndroid* android::deserializeLayer(int version, SkMemoryStream* stream);
 
 protected:
     LayerAndroid* m_layer;
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
index c6f2d0d..dcdd94b 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
@@ -50,7 +50,7 @@
     virtual bool filter(SkPaint* paint, Type)
     {
         paint->setAlpha(m_opacity);
-        return false;
+        return true;
     }
 private:
     int m_opacity;
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
index 6c2e43d..dc844b3 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h
@@ -58,7 +58,7 @@
 namespace android {
 class DrawExtra;
 void serializeLayer(WebCore::LayerAndroid* layer, SkWStream* stream);
-WebCore::LayerAndroid* deserializeLayer(int version, SkStream* stream);
+WebCore::LayerAndroid* deserializeLayer(int version, SkMemoryStream* stream);
 void cleanupImageRefs(WebCore::LayerAndroid* layer);
 }
 
@@ -256,7 +256,7 @@
 
     // ViewStateSerializer friends
     friend void android::serializeLayer(LayerAndroid* layer, SkWStream* stream);
-    friend LayerAndroid* android::deserializeLayer(int version, SkStream* stream);
+    friend LayerAndroid* android::deserializeLayer(int version, SkMemoryStream* stream);
     friend void android::cleanupImageRefs(LayerAndroid* layer);
 
     LayerType type() { return m_type; }
diff --git a/Source/WebCore/platform/graphics/android/layers/MediaLayer.h b/Source/WebCore/platform/graphics/android/layers/MediaLayer.h
index 8e04681..fb24d1c 100644
--- a/Source/WebCore/platform/graphics/android/layers/MediaLayer.h
+++ b/Source/WebCore/platform/graphics/android/layers/MediaLayer.h
@@ -24,7 +24,7 @@
 #include <jni.h>
 
 namespace android {
-    class SurfaceTexture;
+    class GLConsumer;
 }
 
 namespace WebCore {
@@ -47,7 +47,7 @@
     void invertContents(bool invert) { m_mediaTexture->invertContents(invert); }
     void setOutlineSize(int size) { m_outlineSize = size; }
 
-    // function to setup the primary SurfaceTexture 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;
 
-    // SurfaceTexture 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 2dfc08b..74eb59a 100644
--- a/Source/WebCore/platform/graphics/android/layers/MediaListener.h
+++ b/Source/WebCore/platform/graphics/android/layers/MediaListener.h
@@ -19,8 +19,8 @@
 
 #if USE(ACCELERATED_COMPOSITING)
 
-#include <gui/SurfaceTexture.h>
-#include <gui/SurfaceTextureClient.h>
+#include <gui/GLConsumer.h>
+#include <gui/Surface.h>
 #include <jni.h>
 #include <JNIUtility.h>
 #include "MediaTexture.h"
@@ -28,11 +28,11 @@
 
 namespace WebCore {
 
-class MediaListener : public android::SurfaceTexture::FrameAvailableListener {
+class MediaListener : public android::GLConsumer::FrameAvailableListener {
 
 public:
     MediaListener(jobject weakWebViewRef,
-                  const sp<android::SurfaceTexture>& surfaceTexture,
+                  const sp<android::GLConsumer>& surfaceTexture,
                   const sp<ANativeWindow>& nativeWindow)
         : m_weakWebViewRef(weakWebViewRef)
         , m_postInvalMethod(0)
@@ -78,7 +78,7 @@
     jobject m_weakWebViewRef;
     jmethodID m_postInvalMethod;
     bool m_frameAvailable;
-    sp<android::SurfaceTexture> m_surfaceTexture;
+    sp<android::GLConsumer> m_surfaceTexture;
     sp<ANativeWindow> m_nativeWindow;
     FramerateCallbackProc m_framerateCallback;
 };
diff --git a/Source/WebCore/platform/graphics/android/layers/MediaTexture.cpp b/Source/WebCore/platform/graphics/android/layers/MediaTexture.cpp
index dffe6c2..b001c1a 100644
--- a/Source/WebCore/platform/graphics/android/layers/MediaTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/MediaTexture.cpp
@@ -29,8 +29,8 @@
 #if USE(ACCELERATED_COMPOSITING)
 
 #include <android/native_window.h>
-#include <gui/SurfaceTexture.h>
-#include <gui/SurfaceTextureClient.h>
+#include <gui/GLConsumer.h>
+#include <gui/Surface.h>
 #include <JNIUtility.h>
 #include "WebCoreJni.h"
 
@@ -280,8 +280,9 @@
 
     // populate the wrapper
     glGenTextures(1, &wrapper->textureId);
-    wrapper->surfaceTexture = new android::SurfaceTexture(wrapper->textureId);
-    wrapper->nativeWindow = new android::SurfaceTextureClient(wrapper->surfaceTexture);
+    wrapper->surfaceTexture = new android::GLConsumer(wrapper->textureId);
+    wrapper->nativeWindow = new android::Surface(
+            wrapper->surfaceTexture->getBufferQueue());
     wrapper->dimensions.setEmpty();
 
     // setup callback
diff --git a/Source/WebCore/platform/graphics/android/layers/MediaTexture.h b/Source/WebCore/platform/graphics/android/layers/MediaTexture.h
index 9ea7be2..ad66f35 100644
--- a/Source/WebCore/platform/graphics/android/layers/MediaTexture.h
+++ b/Source/WebCore/platform/graphics/android/layers/MediaTexture.h
@@ -28,7 +28,7 @@
 #include <jni.h>
 
 namespace android {
-    class SurfaceTexture;
+    class GLConsumer;
 }
 
 namespace WebCore {
@@ -62,7 +62,7 @@
 private:
     struct TextureWrapper {
         GLuint textureId;
-        sp<android::SurfaceTexture> surfaceTexture;
+        sp<android::GLConsumer> surfaceTexture;
         sp<ANativeWindow> nativeWindow;
         sp<MediaListener> mediaListener;
         SkRect dimensions; // only used by the video layer
diff --git a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp
index bfd477e..e7527bc 100644
--- a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp
@@ -8,6 +8,9 @@
 #include "InspectorCanvas.h"
 #include "SkPicture.h"
 
+#include <dlfcn.h>
+#include "SkDevice.h"
+
 namespace WebCore {
 
 PictureLayerContent::PictureLayerContent(SkPicture* picture)
@@ -58,13 +61,12 @@
 
     // Let's check if we have text or not. If we don't, we can limit
     // ourselves to scale 1!
-    InspectorBounder inspectorBounder;
-    InspectorCanvas checker(&inspectorBounder, m_picture);
     SkBitmap bitmap;
     bitmap.setConfig(SkBitmap::kARGB_8888_Config,
                      m_picture->width(),
                      m_picture->height());
-    checker.setBitmapDevice(bitmap);
+    InspectorBounder inspectorBounder;
+    InspectorCanvas checker(&inspectorBounder, m_picture, bitmap);
     checker.drawPicture(*m_picture);
     m_hasText = checker.hasText();
     if (!checker.hasContent()) {
@@ -98,4 +100,71 @@
     m_picture->serialize(stream);
 }
 
+
+LegacyPictureLayerContent::LegacyPictureLayerContent(SkMemoryStream* pictureStream) {
+    m_legacyPicture = NULL;
+    m_width = 0;
+    m_height = 0;
+
+    // load legacy skia lib (all functions hidden except ones defined below)
+    m_legacyLib = dlopen("libskia_legacy.so", RTLD_LAZY);
+    *reinterpret_cast<void**>(&m_createPictureProc) = dlsym(m_legacyLib, "legacy_skia_create_picture");
+    *reinterpret_cast<void**>(&m_deletePictureProc) = dlsym(m_legacyLib, "legacy_skia_delete_picture");
+    *reinterpret_cast<void**>(&m_drawPictureProc) = dlsym(m_legacyLib, "legacy_skia_draw_picture");
+
+    const char* error = dlerror();
+    if (error) {
+      SkDebugf("Unable to load legacy lib: %s", error);
+      sk_throw();
+    }
+
+    // call into library to create picture and set width and height
+    const int streamLength = pictureStream->getLength() - pictureStream->peek();
+    int bytesRead = m_createPictureProc(pictureStream->getAtPos(), streamLength,
+                                        &m_legacyPicture, &m_width, &m_height);
+    pictureStream->skip(bytesRead);
+}
+
+LegacyPictureLayerContent::~LegacyPictureLayerContent() {
+    if (m_legacyLib) {
+        if (m_legacyPicture) {
+          m_deletePictureProc(m_legacyPicture);
+        }
+        dlclose(m_legacyLib);
+    }
+}
+
+void LegacyPictureLayerContent::draw(SkCanvas* canvas) {
+    if (!m_legacyPicture) {
+      return;
+    }
+
+    // if this is an InspectorCanvas we need to at least draw something to
+    // ensure that the canvas is not discarded. (We perform a no-op text
+    // draw in order to trigger the InspectorCanvas into performing high
+    // fidelity rendering while zooming.
+    SkPaint paint;
+    canvas->drawText(NULL, 0, 0, 0, paint);
+
+    // decompose the canvas into basics
+    void* matrixStorage = malloc(canvas->getTotalMatrix().writeToMemory(NULL));
+    void* clipStorage = malloc(canvas->getTotalClip().writeToMemory(NULL));
+
+    canvas->getTotalMatrix().writeToMemory(matrixStorage);
+    canvas->getTotalClip().writeToMemory(clipStorage);
+
+    const SkBitmap& bitmap = canvas->getDevice()->accessBitmap(true);
+    bitmap.lockPixels();
+
+    // pass picture, matrix, clip, and bitmap
+    m_drawPictureProc(m_legacyPicture, matrixStorage, clipStorage,
+                      bitmap.width(), bitmap.height(), bitmap.getConfig(),
+                      bitmap.rowBytes(), bitmap.getPixels());
+
+
+    bitmap.unlockPixels();
+    free(matrixStorage);
+    free(clipStorage);
+}
+
 } // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.h b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.h
index e5181a5..bb004f2 100644
--- a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.h
+++ b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.h
@@ -27,6 +27,7 @@
 #define PictureLayerContent_h
 
 #include "LayerContent.h"
+#include "SkStream.h"
 
 namespace WebCore {
 
@@ -50,6 +51,34 @@
     bool m_hasText;
 };
 
+class LegacyPictureLayerContent : public LayerContent {
+public:
+    LegacyPictureLayerContent(SkMemoryStream* pictureStream);
+    ~LegacyPictureLayerContent();
+
+    virtual int width() { return m_width; }
+    virtual int height() { return m_height; }
+    virtual void setCheckForOptimisations(bool check) {}
+    virtual void checkForOptimisations() {}
+    virtual float maxZoomScale() { return 1e6; }
+    virtual void draw(SkCanvas* canvas);
+    virtual void serialize(SkWStream* stream) { }
+
+private:
+    void* m_legacyLib;
+    void* m_legacyPicture;
+    int m_width;
+    int m_height;
+
+    typedef int  (*legacy_skia_create_picture_proc)(const void*, int, void**, int*, int*);
+    typedef void (*legacy_skia_delete_picture_proc)(void*);
+    typedef void (*legacy_skia_draw_picture_proc)(void*, void*, void*, int, int, int, int, void*);
+
+    legacy_skia_create_picture_proc m_createPictureProc;
+    legacy_skia_delete_picture_proc m_deletePictureProc;
+    legacy_skia_draw_picture_proc m_drawPictureProc;
+};
+
 } // WebCore
 
 #endif // PictureLayerContent_h
diff --git a/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.h
index b3c828f..4f76274 100644
--- a/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/layers/ScrollableLayerAndroid.h
@@ -64,7 +64,7 @@
     bool scrollRectIntoView(const SkIRect&);
 
     friend void android::serializeLayer(LayerAndroid* layer, SkWStream* stream);
-    friend LayerAndroid* android::deserializeLayer(int version, SkStream* stream);
+    friend LayerAndroid* android::deserializeLayer(int version, SkMemoryStream* stream);
 
 protected:
 
diff --git a/Source/WebCore/platform/graphics/android/layers/VideoLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/VideoLayerAndroid.cpp
index 39bbec6..3593f88 100644
--- a/Source/WebCore/platform/graphics/android/layers/VideoLayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/VideoLayerAndroid.cpp
@@ -34,7 +34,7 @@
 #include "ShaderProgram.h"
 #include "TilesManager.h"
 #include <GLES2/gl2.h>
-#include <gui/SurfaceTexture.h>
+#include <gui/GLConsumer.h>
 
 #if USE(ACCELERATED_COMPOSITING)
 
@@ -62,7 +62,7 @@
 }
 
 // We can use this function to set the Layer to point to surface texture.
-void VideoLayerAndroid::setSurfaceTexture(sp<SurfaceTexture> texture,
+void VideoLayerAndroid::setSurfaceTexture(sp<GLConsumer> texture,
                                           int textureName, PlayerState playerState)
 {
     m_surfaceTexture = texture;
diff --git a/Source/WebCore/platform/graphics/android/layers/VideoLayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/VideoLayerAndroid.h
index 07c241f..1390ace 100644
--- a/Source/WebCore/platform/graphics/android/layers/VideoLayerAndroid.h
+++ b/Source/WebCore/platform/graphics/android/layers/VideoLayerAndroid.h
@@ -33,7 +33,7 @@
 #include <jni.h>
 
 namespace android {
-class SurfaceTexture;
+class GLConsumer;
 }
 
 namespace WebCore {
@@ -57,7 +57,7 @@
 
     // The following functions are called in UI thread only.
     virtual bool drawGL(bool layerTilesDisabled);
-    void setSurfaceTexture(sp<SurfaceTexture> texture, int textureName, PlayerState playerState);
+    void setSurfaceTexture(sp<GLConsumer> texture, int textureName, PlayerState playerState);
     virtual bool needsIsolatedSurface() { return true; }
 
 private:
@@ -67,7 +67,7 @@
     SkRect calVideoRect(const SkRect& rect);
     // Surface texture for showing the video is actually allocated in Java side
     // and passed into this native code.
-    sp<android::SurfaceTexture> m_surfaceTexture;
+    sp<android::GLConsumer> m_surfaceTexture;
 
     PlayerState m_playerState;
 
diff --git a/Source/WebCore/platform/graphics/android/rendering/BaseRenderer.cpp b/Source/WebCore/platform/graphics/android/rendering/BaseRenderer.cpp
index 0ab72b7..ddb0533 100644
--- a/Source/WebCore/platform/graphics/android/rendering/BaseRenderer.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/BaseRenderer.cpp
@@ -32,7 +32,6 @@
 #if USE(ACCELERATED_COMPOSITING)
 
 #include "AndroidLog.h"
-#include "GaneshRenderer.h"
 #include "GLUtils.h"
 #include "InstrumentedPlatformCanvas.h"
 #include "RasterRenderer.h"
@@ -58,8 +57,6 @@
 {
     if (g_currentType == Raster)
         return new RasterRenderer();
-    else if (g_currentType == Ganesh)
-        return new GaneshRenderer();
     return NULL;
 }
 
diff --git a/Source/WebCore/platform/graphics/android/rendering/GLUtils.cpp b/Source/WebCore/platform/graphics/android/rendering/GLUtils.cpp
index 1a54cb7..6e4b780 100644
--- a/Source/WebCore/platform/graphics/android/rendering/GLUtils.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/GLUtils.cpp
@@ -39,7 +39,7 @@
 #include "TransferQueue.h"
 
 #include <android/native_window.h>
-#include <gui/SurfaceTexture.h>
+#include <gui/GLConsumer.h>
 #include <wtf/CurrentTime.h>
 
 // We will limit GL error logging for LOG_VOLUME_PER_CYCLE times every
diff --git a/Source/WebCore/platform/graphics/android/rendering/GLUtils.h b/Source/WebCore/platform/graphics/android/rendering/GLUtils.h
index 3b093d1..86475f1 100644
--- a/Source/WebCore/platform/graphics/android/rendering/GLUtils.h
+++ b/Source/WebCore/platform/graphics/android/rendering/GLUtils.h
@@ -40,7 +40,7 @@
 
 namespace android {
 
-class SurfaceTexture;
+class GLConsumer;
 
 } // namespace android
 
diff --git a/Source/WebCore/platform/graphics/android/rendering/GaneshContext.cpp b/Source/WebCore/platform/graphics/android/rendering/GaneshContext.cpp
index 5c4b453..0ea8d93 100644
--- a/Source/WebCore/platform/graphics/android/rendering/GaneshContext.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/GaneshContext.cpp
@@ -152,7 +152,7 @@
         GrPlatformRenderTargetDesc renderTargetDesc;
         renderTargetDesc.fWidth = TilesManager::tileWidth();
         renderTargetDesc.fHeight = TilesManager::tileHeight();
-        renderTargetDesc.fConfig = kRGBA_8888_PM_GrPixelConfig;
+        renderTargetDesc.fConfig = kRGBA_8888_GrPixelConfig;
         renderTargetDesc.fSampleCnt = 0;
         renderTargetDesc.fStencilBits = 8;
         renderTargetDesc.fRenderTargetHandle = 0;
diff --git a/Source/WebCore/platform/graphics/android/rendering/GaneshRenderer.cpp b/Source/WebCore/platform/graphics/android/rendering/GaneshRenderer.cpp
index 8b5e30a..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. SurfaceTexture) 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/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
index db03753..64277ac 100644
--- a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
@@ -113,10 +113,7 @@
     // Create a copy of the image
     img->setConfig(SkBitmap::kARGB_8888_Config, w, h);
     img->allocPixels();
-    SkDevice* device = new SkDevice(*img);
-    SkCanvas canvas;
-    canvas.setDevice(device);
-    device->unref();
+    SkCanvas canvas(*img);
     SkRect dest;
     dest.set(0, 0, w, h);
     img->setIsOpaque(false);
diff --git a/Source/WebCore/platform/graphics/android/rendering/InspectorCanvas.cpp b/Source/WebCore/platform/graphics/android/rendering/InspectorCanvas.cpp
index f9edb74..065cb94 100644
--- a/Source/WebCore/platform/graphics/android/rendering/InspectorCanvas.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/InspectorCanvas.cpp
@@ -66,6 +66,14 @@
     setHasContent();
 }
 
+void InspectorCanvas::drawBitmapRectToRect(const SkBitmap& bitmap,
+                                           const SkRect* src,
+                                           const SkRect& dst,
+                                           const SkPaint* paint)
+{
+    setHasContent();
+}
+
 void InspectorCanvas::drawPaint(const SkPaint& paint)
 {
     setHasContent();
diff --git a/Source/WebCore/platform/graphics/android/rendering/InspectorCanvas.h b/Source/WebCore/platform/graphics/android/rendering/InspectorCanvas.h
index 415a579..be28ad9 100644
--- a/Source/WebCore/platform/graphics/android/rendering/InspectorCanvas.h
+++ b/Source/WebCore/platform/graphics/android/rendering/InspectorCanvas.h
@@ -40,8 +40,9 @@
 
 class InspectorCanvas : public SkCanvas {
 public:
-    InspectorCanvas(SkBounder* bounder, SkPicture* picture)
-        : m_picture(picture)
+    InspectorCanvas(SkBounder* bounder, SkPicture* picture, SkBitmap& bitmap)
+        : SkCanvas(bitmap)
+        , m_picture(picture)
         , m_hasText(false)
         , m_hasContent(false)
     {
@@ -59,6 +60,10 @@
                                   const SkIRect* rect,
                                   const SkMatrix&,
                                   const SkPaint&);
+    virtual void drawBitmapRectToRect(const SkBitmap& bitmap,
+                                      const SkRect* src,
+                                      const SkRect& dst,
+                                      const SkPaint* paint);
 
     virtual void drawPaint(const SkPaint& paint);
     virtual void drawPath(const SkPath&, const SkPaint& paint);
diff --git a/Source/WebCore/platform/graphics/android/rendering/InstrumentedPlatformCanvas.h b/Source/WebCore/platform/graphics/android/rendering/InstrumentedPlatformCanvas.h
index cc3ef55..494bcb5 100644
--- a/Source/WebCore/platform/graphics/android/rendering/InstrumentedPlatformCanvas.h
+++ b/Source/WebCore/platform/graphics/android/rendering/InstrumentedPlatformCanvas.h
@@ -195,12 +195,12 @@
         SkCanvas::drawBitmap(bitmap, left, top, paint);
     }
 
-    virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
+    virtual void drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
             const SkRect& dst, const SkPaint* paint)
     {
         WRAPCANVAS_LOG_ENTRY("");
         m_isSolidColor = false;
-        SkCanvas::drawBitmapRect(bitmap, src, dst, paint);
+        SkCanvas::drawBitmapRectToRect(bitmap, src, dst, paint);
     }
 
     virtual void drawBitmapMatrix(const SkBitmap& bitmap,
diff --git a/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.cpp b/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.cpp
index 5920007..a6f3534 100644
--- a/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/ShaderProgram.cpp
@@ -733,6 +733,7 @@
         glVertexAttribPointer(m_handleArray[type].positionHandle,
                               2, GL_FLOAT, GL_FALSE, 0, 0);
         m_cachedProgramType = type;
+        m_cachedFillPortion = FloatRect();
         m_cachedOpacity = -1; // reset cache for variable shared by multiple programs
     }
     glUniformMatrix4fv(m_handleArray[type].projMtxHandle, 1, GL_FALSE, matrix);
diff --git a/Source/WebCore/platform/graphics/android/rendering/TextureInfo.cpp b/Source/WebCore/platform/graphics/android/rendering/TextureInfo.cpp
index f5c8b02..32237cd 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TextureInfo.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/TextureInfo.cpp
@@ -30,8 +30,8 @@
 
 #include <JNIUtility.h>
 #include <android/native_window.h>
-#include <gui/SurfaceTexture.h>
-#include <gui/SurfaceTextureClient.h>
+#include <gui/GLConsumer.h>
+#include <gui/Surface.h>
 
 namespace WebCore {
 
diff --git a/Source/WebCore/platform/graphics/android/rendering/TextureInfo.h b/Source/WebCore/platform/graphics/android/rendering/TextureInfo.h
index 7d182c3..077748e 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TextureInfo.h
+++ b/Source/WebCore/platform/graphics/android/rendering/TextureInfo.h
@@ -34,7 +34,7 @@
 using android::sp;
 
 namespace android {
-class SurfaceTexture;
+class GLConsumer;
 }
 
 namespace WebCore {
diff --git a/Source/WebCore/platform/graphics/android/rendering/TilesManager.cpp b/Source/WebCore/platform/graphics/android/rendering/TilesManager.cpp
index 50f862d..f44f79d 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TilesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/TilesManager.cpp
@@ -42,8 +42,8 @@
 
 #include <android/native_window.h>
 #include <cutils/atomic.h>
-#include <gui/SurfaceTexture.h>
-#include <gui/SurfaceTextureClient.h>
+#include <gui/GLConsumer.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 b15fa6d..81b3ff4 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp
@@ -39,8 +39,8 @@
 #include "TileTexture.h"
 #include "TilesManager.h"
 #include <android/native_window.h>
-#include <gui/SurfaceTexture.h>
-#include <gui/SurfaceTextureClient.h>
+#include <gui/GLConsumer.h>
+#include <gui/Surface.h>
 
 // For simple webView usage, MINIMAL_SIZE is recommended for memory saving.
 // In browser case, EFFICIENT_SIZE is preferred.
@@ -106,14 +106,14 @@
         sp<BufferQueue> bufferQueue(new BufferQueue(true));
         m_sharedSurfaceTexture =
 #if GPU_UPLOAD_WITHOUT_DRAW
-            new android::SurfaceTexture(m_sharedSurfaceTextureId, true,
+            new android::GLConsumer(m_sharedSurfaceTextureId, true,
                                         GL_TEXTURE_2D, true, bufferQueue);
 #else
-            new android::SurfaceTexture(m_sharedSurfaceTextureId, true,
+            new android::GLConsumer(m_sharedSurfaceTextureId, true,
                                         GL_TEXTURE_EXTERNAL_OES, true,
                                         bufferQueue);
 #endif
-        m_ANW = new android::SurfaceTextureClient(m_sharedSurfaceTexture);
+        m_ANW = new android::Surface(bufferQueue);
         m_sharedSurfaceTexture->setSynchronousMode(true);
 
         int extraBuffersNeeded = 0;
diff --git a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.h b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.h
index 55011b0..d0d4a87 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.h
+++ b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.h
@@ -188,7 +188,7 @@
     bool m_hasGLContext;
 
     GLState m_GLStateBeforeBlit;
-    android::sp<android::SurfaceTexture> m_sharedSurfaceTexture;
+    android::sp<android::GLConsumer> m_sharedSurfaceTexture;
 
     int m_emptyItemCount;
 
diff --git a/Source/WebCore/platform/graphics/android/utils/LinearAllocator.cpp b/Source/WebCore/platform/graphics/android/utils/LinearAllocator.cpp
deleted file mode 100644
index 636c30c..0000000
--- a/Source/WebCore/platform/graphics/android/utils/LinearAllocator.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright 2012, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define LOG_TAG "LinearAllocator"
-#define LOG_NDEBUG 1
-
-#include "config.h"
-#include "LinearAllocator.h"
-
-#include "AndroidLog.h"
-
-namespace WebCore {
-
-// The ideal size of a page allocation (these need to be multiples of 4)
-#define INITIAL_PAGE_SIZE ((size_t)4096) // 4kb
-#define MAX_PAGE_SIZE ((size_t)131072) // 128kb
-
-// The maximum amount of wasted space we can have per page
-// Allocations exceeding this will have their own dedicated page
-// If this is too low, we will malloc too much
-// Too high, and we may waste too much space
-// Must be smaller than INITIAL_PAGE_SIZE
-#define MAX_WASTE_SIZE ((size_t)1024)
-
-#if CPU(MIPS)
-#define ALIGN_SZ (sizeof(double))
-#else
-#define ALIGN_SZ (sizeof(int))
-#endif
-
-#define ALIGN(x) ((x + ALIGN_SZ - 1 ) & ~(ALIGN_SZ - 1))
-#define ALIGN_PTR(p) ((void*)(ALIGN((unsigned int)p)))
-
-#if LOG_NDEBUG
-#define ADD_ALLOCATION(size)
-#define RM_ALLOCATION(size)
-#else
-#include <utils/Thread.h>
-static size_t s_totalAllocations = 0;
-static double s_lastLogged = 0;
-static android::Mutex s_mutex;
-
-static void _logUsageLocked() {
-    double now = currentTimeMS();
-    if (now - s_lastLogged > 5) {
-        s_lastLogged = now;
-        ALOGV("Total memory usage: %d kb", s_totalAllocations / 1024);
-    }
-}
-
-static void _addAllocation(size_t size) {
-    android::AutoMutex lock(s_mutex);
-    s_totalAllocations += size;
-    _logUsageLocked();
-}
-
-#define ADD_ALLOCATION(size) _addAllocation(size);
-#define RM_ALLOCATION(size) _addAllocation(-size);
-#endif
-
-class LinearAllocator::Page {
-public:
-    Page* next() { return m_nextPage; }
-    void setNext(Page* next) { m_nextPage = next; }
-
-    Page()
-        : m_nextPage(0)
-    {}
-
-    void* start()
-    {
-        return (void*) (((unsigned)this) + sizeof(LinearAllocator::Page));
-    }
-
-    void* end(int pageSize)
-    {
-        return (void*) (((unsigned)start()) + pageSize);
-    }
-
-private:
-    Page(const Page& other) {}
-    Page* m_nextPage;
-};
-
-LinearAllocator::LinearAllocator()
-    : m_pageSize(INITIAL_PAGE_SIZE)
-    , m_maxAllocSize(MAX_WASTE_SIZE)
-    , m_next(0)
-    , m_currentPage(0)
-    , m_pages(0)
-    , m_totalAllocated(0)
-    , m_wastedSpace(0)
-    , m_pageCount(0)
-    , m_dedicatedPageCount(0)
-{
-}
-
-LinearAllocator::~LinearAllocator(void)
-{
-    Page* p = m_pages;
-    while (p) {
-        Page* next = p->next();
-        delete p;
-        RM_ALLOCATION(m_pageSize);
-        p = next;
-    }
-}
-
-void* LinearAllocator::start(Page* p)
-{
-    return ALIGN_PTR(((char*)p) + sizeof(Page));
-}
-
-void* LinearAllocator::end(Page* p)
-{
-    return ((char*)p) + m_pageSize;
-}
-
-bool LinearAllocator::fitsInCurrentPage(size_t size)
-{
-    return m_next && ((char*)m_next + size) <= end(m_currentPage);
-}
-
-void LinearAllocator::ensureNext(size_t size)
-{
-    if (fitsInCurrentPage(size))
-        return;
-    if (m_currentPage && m_pageSize < MAX_PAGE_SIZE) {
-        m_pageSize = std::min(MAX_PAGE_SIZE, m_pageSize * 2);
-        m_pageSize = ALIGN(m_pageSize);
-    }
-    m_wastedSpace += m_pageSize;
-    Page* p = newPage(m_pageSize);
-    if (m_currentPage)
-        m_currentPage->setNext(p);
-    m_currentPage = p;
-    if (!m_pages)
-        m_pages = m_currentPage;
-    m_next = start(m_currentPage);
-}
-
-void* LinearAllocator::alloc(size_t size)
-{
-    size = ALIGN(size);
-    if (size > m_maxAllocSize && !fitsInCurrentPage(size)) {
-        ALOGV("Exceeded max size %d > %d", size, m_maxAllocSize);
-        // Allocation is too large, create a dedicated page for the allocation
-        Page* page = newPage(size);
-        m_dedicatedPageCount++;
-        page->setNext(m_pages);
-        m_pages = page;
-        if (!m_currentPage)
-            m_currentPage = m_pages;
-        return start(page);
-    }
-    ensureNext(size);
-    void* ptr = m_next;
-    m_next = ((char*)m_next) + size;
-    m_wastedSpace -= size;
-    return ptr;
-}
-
-void LinearAllocator::rewindIfLastAlloc(void* ptr, size_t allocSize)
-{
-    // Don't bother rewinding across pages
-    allocSize = ALIGN(allocSize);
-    if (ptr >= start(m_currentPage) && ptr < end(m_currentPage)
-            && ptr == ((char*)m_next - allocSize)) {
-        m_totalAllocated -= allocSize;
-        m_wastedSpace += allocSize;
-        m_next = ptr;
-    }
-}
-
-LinearAllocator::Page* LinearAllocator::newPage(size_t pageSize)
-{
-    pageSize = ALIGN(pageSize + sizeof(LinearAllocator::Page));
-    ADD_ALLOCATION(pageSize);
-    m_totalAllocated += pageSize;
-    m_pageCount++;
-    void* buf = malloc(pageSize);
-    return new (buf) Page();
-}
-
-static const char* toSize(size_t value, float& result)
-{
-    if (value < 2000) {
-        result = value;
-        return "B";
-    }
-    if (value < 2000000) {
-        result = value / 1024.0f;
-        return "KB";
-    }
-    result = value / 1048576.0f;
-    return "MB";
-}
-
-void LinearAllocator::dumpMemoryStats(const char* prefix)
-{
-    float prettySize;
-    const char* prettySuffix;
-    prettySuffix = toSize(m_totalAllocated, prettySize);
-    ALOGD("%sTotal allocated: %.2f%s", prefix, prettySize, prettySuffix);
-    prettySuffix = toSize(m_wastedSpace, prettySize);
-    ALOGD("%sWasted space: %.2f%s (%.1f%%)", prefix, prettySize, prettySuffix,
-          (float) m_wastedSpace / (float) m_totalAllocated * 100.0f);
-    ALOGD("%sPages %d (dedicated %d)", prefix, m_pageCount, m_dedicatedPageCount);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/utils/LinearAllocator.h b/Source/WebCore/platform/graphics/android/utils/LinearAllocator.h
deleted file mode 100644
index 8cabf7c..0000000
--- a/Source/WebCore/platform/graphics/android/utils/LinearAllocator.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2012, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LinearAllocator_h
-#define LinearAllocator_h
-
-namespace WebCore {
-
-class LinearAllocator
-{
-public:
-    LinearAllocator();
-    ~LinearAllocator();
-
-    void* alloc(size_t size);
-    void rewindIfLastAlloc(void* ptr, size_t allocSize);
-
-    void dumpMemoryStats(const char* prefix = "");
-
-private:
-    LinearAllocator(const LinearAllocator& other);
-
-    class Page;
-
-    Page* newPage(size_t pageSize);
-    bool fitsInCurrentPage(size_t size);
-    void ensureNext(size_t size);
-    void* start(Page *p);
-    void* end(Page* p);
-
-    size_t m_pageSize;
-    size_t m_maxAllocSize;
-    void* m_next;
-    Page* m_currentPage;
-    Page* m_pages;
-
-    // Memory usage tracking
-    size_t m_totalAllocated;
-    size_t m_wastedSpace;
-    size_t m_pageCount;
-    size_t m_dedicatedPageCount;
-};
-
-} // namespace WebCore
-
-#endif // LinearAllocator_h
diff --git a/Source/WebCore/plugins/android/PluginViewAndroid.cpp b/Source/WebCore/plugins/android/PluginViewAndroid.cpp
index 24a14aa..fce5e28 100644
--- a/Source/WebCore/plugins/android/PluginViewAndroid.cpp
+++ b/Source/WebCore/plugins/android/PluginViewAndroid.cpp
@@ -83,7 +83,6 @@
 #include "ANPSystem_npapi.h"
 #include "ANPVideo_npapi.h"
 #include "SkANP.h"
-#include "SkFlipPixelRef.h"
 
 ///////////////////////////////////////////////////////////////////////////////
 
diff --git a/Source/WebKit/Android.mk b/Source/WebKit/Android.mk
index 6e23421..0b015cd 100644
--- a/Source/WebKit/Android.mk
+++ b/Source/WebKit/Android.mk
@@ -58,7 +58,6 @@
 	android/content/PhoneEmailDetector.cpp \
 	\
 	android/jni/AndroidHitTestResult.cpp \
-	android/jni/CacheManager.cpp \
 	android/jni/CookieManager.cpp \
 	android/jni/DeviceMotionAndOrientationManager.cpp \
 	android/jni/DeviceMotionClientImpl.cpp \
diff --git a/Source/WebKit/android/WebCoreSupport/ChromiumInit.cpp b/Source/WebKit/android/WebCoreSupport/ChromiumInit.cpp
index 500975c..8543c8d 100644
--- a/Source/WebKit/android/WebCoreSupport/ChromiumInit.cpp
+++ b/Source/WebKit/android/WebCoreSupport/ChromiumInit.cpp
@@ -52,7 +52,7 @@
         androidSeverity = ANDROID_LOG_VERBOSE;
         break;
     }
-    android_printLog(androidSeverity, "chromium", "%s:%d: %s", file, line, str.c_str());
+    android_printLog(androidSeverity, "chromium_net", "%s:%d: %s", file, line, str.c_str());
     return false;
 }
 
diff --git a/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp b/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp
index de91766..a2927ca 100644
--- a/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp
+++ b/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp
@@ -40,12 +40,12 @@
 #include <JNIHelp.h>
 #include <JNIUtility.h>
 #include <SkBitmap.h>
-#include <gui/SurfaceTexture.h>
+#include <gui/GLConsumer.h>
 
 using namespace android;
 // Forward decl
 namespace android {
-sp<SurfaceTexture> SurfaceTexture_getSurfaceTexture(JNIEnv* env, jobject thiz);
+sp<GLConsumer> SurfaceTexture_getSurfaceTexture(JNIEnv* env, jobject thiz);
 };
 
 namespace WebCore {
@@ -644,7 +644,7 @@
     if (!surfTex)
         return false;
 
-    sp<SurfaceTexture> texture = android::SurfaceTexture_getSurfaceTexture(env, surfTex);
+    sp<GLConsumer> texture = android::SurfaceTexture_getSurfaceTexture(env, surfTex);
     if (!texture.get())
         return false;
 
@@ -657,7 +657,7 @@
     if (!videoLayer)
         return false;
 
-    // Set the SurfaceTexture to the layer we found
+    // Set the GLConsumer to the layer we found
     videoLayer->setSurfaceTexture(texture, textureName, static_cast<PlayerState>(playerState));
     return true;
 }
diff --git a/Source/WebKit/android/jni/CacheManager.cpp b/Source/WebKit/android/jni/CacheManager.cpp
deleted file mode 100644
index b34776d..0000000
--- a/Source/WebKit/android/jni/CacheManager.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright 2011, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "ChromiumIncludes.h"
-#include "WebCache.h"
-#include "WebCoreJni.h"
-
-#include <JNIHelp.h>
-#include <platform/FileSystem.h>
-#include <platform/text/Base64.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
-
-using namespace WebCore;
-using namespace base;
-using namespace disk_cache;
-using namespace net;
-using namespace std;
-
-namespace android {
-
-// JNI for android.webkit.CacheManager
-static const char* javaCacheManagerClass = "android/webkit/CacheManager";
-
-static void setStringField(JNIEnv* env, const jobject& object, const jfieldID& field, const String& str)
-{
-    jstring jstr = wtfStringToJstring(env, str);
-    env->SetObjectField(object, field, jstr);
-    env->DeleteLocalRef(jstr);
-}
-
-static void setFieldFromHeaderIfPresent(CacheResult* result, const char* header, JNIEnv* env, const jobject& object, const jfieldID& field, bool allowEmptyString)
-{
-  String value;
-  if (result->firstResponseHeader(header, &value, allowEmptyString))
-      setStringField(env, object, field, value);
-}
-
-static String getCacheFileBaseDir(JNIEnv* env)
-{
-    static String baseDir;
-    if (baseDir.isEmpty()) {
-        jclass cacheManagerClass = env->FindClass("android/webkit/CacheManager");
-        jmethodID getCacheFileBaseDirMethod = env->GetStaticMethodID(cacheManagerClass, "getCacheFileBaseDir", "()Ljava/io/File;");
-        jclass fileClass = env->FindClass("java/io/File");
-        jmethodID getPathMethod = env->GetMethodID(fileClass, "getPath", "()Ljava/lang/String;");
-        jobject fileObject = env->CallStaticObjectMethod(cacheManagerClass, getCacheFileBaseDirMethod);
-        baseDir = jstringToWtfString(env, static_cast<jstring>(env->CallObjectMethod(fileObject, getPathMethod)));
-    }
-    return baseDir;
-}
-
-static jobject getCacheResult(JNIEnv* env, jobject, jstring url)
-{
-    // This is called on the UI thread.
-    scoped_refptr<CacheResult> result = WebCache::get(false /*privateBrowsing*/)->getCacheResult(jstringToWtfString(env, url));
-    if (!result)
-        return 0;
-
-    // We create and populate a file with the cache entry. This allows us to
-    // replicate the behaviour of the Android HTTP stack in the Java
-    // CacheManager, which opens the cache file and provides an input stream to
-    // the file as part of the Java CacheResult object!
-    String urlWtfString = jstringToWtfString(env, url);
-    Vector<char> encodedUrl;
-    base64Encode(urlWtfString.utf8().data(), urlWtfString.length(), encodedUrl, false /*insertLFs*/);
-    encodedUrl.append('\0');
-    String filePath = pathByAppendingComponent(getCacheFileBaseDir(env), encodedUrl.data());
-    if (!result->writeToFile(filePath))
-        return 0;
-
-    jclass cacheResultClass = env->FindClass("android/webkit/CacheManager$CacheResult");
-    jmethodID constructor = env->GetMethodID(cacheResultClass, "<init>", "()V");
-    // We only bother with the fields that are made accessible through the public API.
-    jfieldID contentdispositionField = env->GetFieldID(cacheResultClass, "contentdisposition", "Ljava/lang/String;");
-    jfieldID contentLengthField = env->GetFieldID(cacheResultClass, "contentLength", "J");
-    jfieldID etagField = env->GetFieldID(cacheResultClass, "etag", "Ljava/lang/String;");
-    jfieldID encodingField = env->GetFieldID(cacheResultClass, "encoding", "Ljava/lang/String;");
-    jfieldID expiresField = env->GetFieldID(cacheResultClass, "expires", "J");
-    jfieldID expiresStringField = env->GetFieldID(cacheResultClass, "expiresString", "Ljava/lang/String;");
-    jfieldID httpStatusCodeField = env->GetFieldID(cacheResultClass, "httpStatusCode", "I");
-    jfieldID lastModifiedField = env->GetFieldID(cacheResultClass, "lastModified", "Ljava/lang/String;");
-    jfieldID localPathField = env->GetFieldID(cacheResultClass, "localPath", "Ljava/lang/String;");
-    jfieldID locationField = env->GetFieldID(cacheResultClass, "location", "Ljava/lang/String;");
-    jfieldID mimeTypeField = env->GetFieldID(cacheResultClass, "mimeType", "Ljava/lang/String;");
-
-    jobject javaResult = env->NewObject(cacheResultClass, constructor);
-    setFieldFromHeaderIfPresent(result.get(), "content-disposition", env, javaResult, contentdispositionField, true);
-    env->SetLongField(javaResult, contentLengthField, result->contentSize());
-    setFieldFromHeaderIfPresent(result.get(), "etag", env, javaResult, etagField, false);
-    setStringField(env, javaResult, encodingField, "TODO"); // TODO: Where does the Android stack set this?
-    env->SetLongField(javaResult, expiresField, result->expires());
-    env->SetIntField(javaResult, httpStatusCodeField, result->responseCode());
-    setFieldFromHeaderIfPresent(result.get(), "last-modified", env, javaResult, lastModifiedField, false);
-    setStringField(env, javaResult, localPathField, encodedUrl.data());
-    setFieldFromHeaderIfPresent(result.get(), "location", env, javaResult, locationField, false);
-    setStringField(env, javaResult, mimeTypeField, result->mimeType());
-
-    return javaResult;
-}
-
-static JNINativeMethod gCacheManagerMethods[] = {
-    { "nativeGetCacheResult", "(Ljava/lang/String;)Landroid/webkit/CacheManager$CacheResult;", (void*) getCacheResult },
-};
-
-int registerCacheManager(JNIEnv* env)
-{
-#ifndef NDEBUG
-    jclass cacheManager = env->FindClass(javaCacheManagerClass);
-    ALOG_ASSERT(cacheManager, "Unable to find class");
-    env->DeleteLocalRef(cacheManager);
-#endif
-    return jniRegisterNativeMethods(env, javaCacheManagerClass, gCacheManagerMethods, NELEM(gCacheManagerMethods));
-}
-
-} // namespace android
diff --git a/Source/WebKit/android/jni/PicturePile.cpp b/Source/WebKit/android/jni/PicturePile.cpp
index 44cfccb..f6fe5db 100644
--- a/Source/WebKit/android/jni/PicturePile.cpp
+++ b/Source/WebKit/android/jni/PicturePile.cpp
@@ -84,8 +84,7 @@
      * the rect bounds of the SkRegion for the clip, so this still can't be
      * used for translucent surfaces
      */
-    if (canvas->quickReject(SkRect::MakeWH(m_size.width(), m_size.height()),
-            SkCanvas::kBW_EdgeType))
+    if (canvas->quickReject(SkRect::MakeWH(m_size.width(), m_size.height())))
         return;
     drawWithClipRecursive(canvas, m_pile.size() - 1);
 }
@@ -102,7 +101,7 @@
     if (index < 0)
         return;
     PictureContainer& pc = m_pile[index];
-    if (pc.picture && !canvas->quickReject(pc.area, SkCanvas::kBW_EdgeType)) {
+    if (pc.picture && !canvas->quickReject(pc.area)) {
         int saved = canvas->save(SkCanvas::kClip_SaveFlag);
         if (canvas->clipRect(pc.area, SkRegion::kDifference_Op))
             drawWithClipRecursive(canvas, index - 1);
diff --git a/Source/WebKit/android/jni/ViewStateSerializer.cpp b/Source/WebKit/android/jni/ViewStateSerializer.cpp
index 8963837..97c15d0 100644
--- a/Source/WebKit/android/jni/ViewStateSerializer.cpp
+++ b/Source/WebKit/android/jni/ViewStateSerializer.cpp
@@ -40,7 +40,9 @@
 #include "LayerContent.h"
 #include "PictureLayerContent.h"
 #include "ScrollableLayerAndroid.h"
-#include "SkFlattenable.h"
+#include "SkData.h"
+#include "SkOrderedReadBuffer.h"
+#include "SkOrderedWriteBuffer.h"
 #include "SkPicture.h"
 #include "TilesManager.h"
 
@@ -152,12 +154,40 @@
 static BaseLayerAndroid* nativeDeserializeViewState(JNIEnv* env, jobject, jint version,
                                                     jobject jstream, jbyteArray jstorage)
 {
-    SkStream* stream = CreateJavaInputStreamAdaptor(env, jstream, jstorage);
-    if (!stream)
+    SkStream* javaStream = CreateJavaInputStreamAdaptor(env, jstream, jstorage);
+    if (!javaStream)
         return 0;
-    Color color = stream->readU32();
-    SkPicture* picture = new SkPicture(stream);
-    PictureLayerContent* content = new PictureLayerContent(picture);
+
+    // read everything into memory so that we can get the offset into the stream
+    // when necessary. This is needed for the LegacyPictureLayerContent.
+    SkDynamicMemoryWStream tempStream;
+    const int bufferSize = 256*1024; // 256KB
+    uint8_t buffer[bufferSize];
+    int bytesRead = 0;
+
+    do {
+      bytesRead = javaStream->read(buffer, bufferSize);
+      tempStream.write(buffer, bytesRead);
+    } while (bytesRead != 0);
+
+    SkMemoryStream stream;
+    stream.setData(tempStream.copyToData())->unref();
+
+    // clean up the javaStream now that we have everything in memory
+    delete javaStream;
+
+    Color color = stream.readU32();
+
+
+
+    LayerContent* content;
+    if (version == 1) {
+        content = new LegacyPictureLayerContent(&stream);
+    } else {
+        SkPicture* picture = new SkPicture(&stream);
+        content = new PictureLayerContent(picture);
+        SkSafeUnref(picture);
+    }
 
     BaseLayerAndroid* layer = new BaseLayerAndroid(content);
     layer->setBackgroundColor(color);
@@ -167,14 +197,12 @@
     layer->markAsDirty(dirtyRegion);
 
     SkSafeUnref(content);
-    SkSafeUnref(picture);
-    int childCount = stream->readS32();
+    int childCount = stream.readS32();
     for (int i = 0; i < childCount; i++) {
-        LayerAndroid* childLayer = deserializeLayer(version, stream);
+        LayerAndroid* childLayer = deserializeLayer(version, &stream);
         if (childLayer)
             layer->addChild(childLayer);
     }
-    delete stream;
     return layer;
 }
 
@@ -381,7 +409,7 @@
     bool hasContentsImage = layer->m_imageCRC != 0;
     stream->writeBool(hasContentsImage);
     if (hasContentsImage) {
-        SkFlattenableWriteBuffer buffer(1024);
+        SkOrderedWriteBuffer buffer(1024);
         buffer.setFlags(SkFlattenableWriteBuffer::kCrossProcess_Flag);
         ImageTexture* imagetexture =
                 ImagesManager::instance()->retainImage(layer->m_imageCRC);
@@ -413,7 +441,7 @@
         serializeLayer(layer->getChild(i), stream);
 }
 
-LayerAndroid* deserializeLayer(int version, SkStream* stream)
+LayerAndroid* deserializeLayer(int version, SkMemoryStream* stream)
 {
     int type = stream->readU8();
     if (type == LTNone)
@@ -500,7 +528,7 @@
         int size = stream->readU32();
         SkAutoMalloc storage(size);
         stream->read(storage.get(), size);
-        SkFlattenableReadBuffer buffer(storage.get(), size);
+        SkOrderedReadBuffer buffer(storage.get(), size);
         SkBitmap contentsImage;
         contentsImage.unflatten(buffer);
         SkBitmapRef* imageRef = new SkBitmapRef(contentsImage);
@@ -509,11 +537,16 @@
     }
     bool hasRecordingPicture = stream->readBool();
     if (hasRecordingPicture) {
-        SkPicture* picture = new SkPicture(stream);
-        PictureLayerContent* content = new PictureLayerContent(picture);
+      LayerContent* content;
+        if (version == 1) {
+            content = new LegacyPictureLayerContent(stream);
+        } else {
+            SkPicture* picture = new SkPicture(stream);
+            content = new PictureLayerContent(picture);
+            SkSafeUnref(picture);
+        }
         layer->setContent(content);
         SkSafeUnref(content);
-        SkSafeUnref(picture);
     }
     int animationCount = stream->readU32(); // TODO: Support (maybe?)
     readTransformationMatrix(stream, layer->m_transform);
diff --git a/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp b/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp
index ec052f1..d4b1ddb 100644
--- a/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp
+++ b/Source/WebKit/android/jni/WebCoreJniOnLoad.cpp
@@ -91,7 +91,6 @@
 #endif
 extern int registerDeviceMotionAndOrientationManager(JNIEnv*);
 extern int registerCookieManager(JNIEnv*);
-extern int registerCacheManager(JNIEnv*);
 
 }
 
@@ -120,7 +119,6 @@
 #endif
     { "DeviceMotionAndOrientationManager", android::registerDeviceMotionAndOrientationManager },
     { "CookieManager", android::registerCookieManager },
-    { "CacheManager", android::registerCacheManager },
 };
 
 EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
diff --git a/Source/WebKit/android/jni/WebFrameView.cpp b/Source/WebKit/android/jni/WebFrameView.cpp
index ed332aa..06faae5 100644
--- a/Source/WebKit/android/jni/WebFrameView.cpp
+++ b/Source/WebKit/android/jni/WebFrameView.cpp
@@ -50,7 +50,7 @@
 }
 
 WebFrameView::~WebFrameView() {
-    Release(mWebViewCore);
+    ::Release(mWebViewCore);
 }
 
 void WebFrameView::draw(WebCore::GraphicsContext* gc, const WebCore::IntRect& rect) {
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index 8779038..497cc9a 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -560,7 +560,7 @@
     WebViewCore::removeInstance(this);
 
     // Release the focused view
-    Release(m_popupReply);
+    ::Release(m_popupReply);
 
     if (m_javaGlue->m_obj) {
         JNIEnv* env = JSC::Bindings::getJNIEnv();
@@ -3501,7 +3501,7 @@
 {
     if (m_popupReply) {
         m_popupReply->replyInt(index);
-        Release(m_popupReply);
+        ::Release(m_popupReply);
         m_popupReply = 0;
     }
 }
@@ -3510,7 +3510,7 @@
 {
     if (m_popupReply) {
         m_popupReply->replyIntArray(array, count);
-        Release(m_popupReply);
+        ::Release(m_popupReply);
         m_popupReply = 0;
     }
 }
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index 66dbdc1..66eccb8 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -1180,7 +1180,7 @@
 
 static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl)
 {
-#ifdef ANDROID_DUMP_DISPLAY_TREE
+#if defined(ANDROID_DUMP_DISPLAY_TREE) && defined(SK_DEVELOPER)
     WebView* view = GET_NATIVE_VIEW(env, jwebview);
     ALOG_ASSERT(view, "view not set in %s", __FUNCTION__);
 
diff --git a/Source/WebKit/android/plugins/ANPCanvasInterface.cpp b/Source/WebKit/android/plugins/ANPCanvasInterface.cpp
index d6d89ff..4519587 100644
--- a/Source/WebKit/android/plugins/ANPCanvasInterface.cpp
+++ b/Source/WebKit/android/plugins/ANPCanvasInterface.cpp
@@ -80,8 +80,7 @@
 static bool anp_getLocalClipBounds(ANPCanvas* canvas, ANPRectF* r,
                                    bool antialias) {
     SkRect bounds;
-    if (canvas->skcanvas->getClipBounds(&bounds,
-                antialias ? SkCanvas::kAA_EdgeType : SkCanvas::kBW_EdgeType)) {
+    if (canvas->skcanvas->getClipBounds(&bounds)) {
         SkANP::SetRect(r, bounds);
         return true;
     }
diff --git a/Source/WebKit/android/plugins/ANPSoundInterface.cpp b/Source/WebKit/android/plugins/ANPSoundInterface.cpp
index 929832b..0ea9b07 100644
--- a/Source/WebKit/android/plugins/ANPSoundInterface.cpp
+++ b/Source/WebKit/android/plugins/ANPSoundInterface.cpp
@@ -36,6 +36,7 @@
     void*                mUser;
     ANPAudioCallbackProc mProc;
     android::AudioTrack* mTrack;
+    int                  mChannelCount;
 };
 
 static ANPSampleFormat toANPFormat(audio_format_t fm) {
@@ -70,8 +71,8 @@
             
             src = reinterpret_cast<android::AudioTrack::Buffer*>(info);
             dst.bufferData      = src->raw;
-            dst.channelCount    = src->channelCount;
-            dst.format          = toANPFormat((audio_format_t) src->format);
+            dst.channelCount    = track->mChannelCount;
+            dst.format          = toANPFormat(AUDIO_FORMAT_PCM_16_BIT);
             dst.size            = src->size;
             track->mProc(kMoreData_ANPAudioEvent, track->mUser, &dst);
             // return the updated size field
@@ -106,6 +107,7 @@
                                             callbackProc,
                                             track,
                                             0);
+    track->mChannelCount = channelCount;
     
     if (track->mTrack->initCheck() != 0) {  // failure
         delete track->mTrack;
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;