Merge remote-tracking branch 'goog/master-chromium' into 'goog/master'

bug: 6906025
diff --git a/Android.mk b/Android.mk
index 3d59ea7..f55d5a1 100644
--- a/Android.mk
+++ b/Android.mk
@@ -87,6 +87,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 \
@@ -322,7 +324,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/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/PlatformGraphicsContextSkia.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.cpp
index fcd9ade..cd3ef7d 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/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
index 1064388..dcdd94b 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
@@ -47,9 +47,10 @@
 class OpacityDrawFilter : public SkDrawFilter {
 public:
     OpacityDrawFilter(int opacity) : m_opacity(opacity) { }
-    virtual void filter(SkPaint* paint, Type)
+    virtual bool filter(SkPaint* paint, Type)
     {
         paint->setAlpha(m_opacity);
+        return true;
     }
 private:
     int m_opacity;
diff --git a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp
index f0e4292..e7527bc 100644
--- a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp
@@ -61,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()) {
@@ -148,11 +147,11 @@
     canvas->drawText(NULL, 0, 0, 0, paint);
 
     // decompose the canvas into basics
-    void* matrixStorage = malloc(canvas->getTotalMatrix().flatten(NULL));
-    void* clipStorage = malloc(canvas->getTotalClip().flatten(NULL));
+    void* matrixStorage = malloc(canvas->getTotalMatrix().writeToMemory(NULL));
+    void* clipStorage = malloc(canvas->getTotalClip().writeToMemory(NULL));
 
-    canvas->getTotalMatrix().flatten(matrixStorage);
-    canvas->getTotalClip().flatten(clipStorage);
+    canvas->getTotalMatrix().writeToMemory(matrixStorage);
+    canvas->getTotalClip().writeToMemory(clipStorage);
 
     const SkBitmap& bitmap = canvas->getDevice()->accessBitmap(true);
     bitmap.lockPixels();
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/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.h b/Source/WebCore/platform/graphics/android/rendering/InspectorCanvas.h
index 415a579..47dc8f7 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)
     {
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/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 650e202..97c15d0 100644
--- a/Source/WebKit/android/jni/ViewStateSerializer.cpp
+++ b/Source/WebKit/android/jni/ViewStateSerializer.cpp
@@ -41,7 +41,8 @@
 #include "PictureLayerContent.h"
 #include "ScrollableLayerAndroid.h"
 #include "SkData.h"
-#include "SkFlattenable.h"
+#include "SkOrderedReadBuffer.h"
+#include "SkOrderedWriteBuffer.h"
 #include "SkPicture.h"
 #include "TilesManager.h"
 
@@ -408,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);
@@ -527,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);
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;
     }