Revert "Merge remote-tracking branch 'goog/master-chromium' into 'goog/master'" DO NOT MERGE

This reverts commit 77437f7411c2a1b6eed9e8635cd1d79c216064af, reversing
changes made to 97df262f2fd351a399bc757d3f7e7c7bb3b00065.

Change-Id: I594d7f423efce65f02b7ac14aff875aa22742ad0
diff --git a/Android.mk b/Android.mk
index f55d5a1..3d59ea7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -87,8 +87,6 @@
 	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 \
@@ -324,7 +322,7 @@
 endif
 
 # Build the list of static libraries
-LOCAL_STATIC_LIBRARIES := libxml2 libxslt libhyphenation libv8
+LOCAL_STATIC_LIBRARIES := libxml2 libxslt libhyphenation libskiagpu 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 e69c145..957040b 100644
--- a/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/context/GraphicsContextAndroid.cpp
@@ -102,13 +102,15 @@
 
 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 cd3ef7d..fcd9ade 100644
--- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.cpp
+++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.cpp
@@ -9,7 +9,6 @@
 #include "GraphicsContext.h"
 #include "SkCanvas.h"
 #include "SkCornerPathEffect.h"
-#include "SkMathPriv.h"
 #include "SkPaint.h"
 #include "SkShader.h"
 #include "SkiaUtils.h"
@@ -273,7 +272,8 @@
     for (size_t i = 1; i < numPoints; i++)
         path.lineTo(SkFloatToScalar(points[i].x()), SkFloatToScalar(points[i].y()));
 
-    if (mCanvas->quickReject(path)) {
+    if (mCanvas->quickReject(path, shouldAntialias ?
+            SkCanvas::kAA_EdgeType : SkCanvas::kBW_EdgeType)) {
         return;
     }
 
diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
index dcdd94b..1064388 100644
--- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp
@@ -47,10 +47,9 @@
 class OpacityDrawFilter : public SkDrawFilter {
 public:
     OpacityDrawFilter(int opacity) : m_opacity(opacity) { }
-    virtual bool filter(SkPaint* paint, Type)
+    virtual void 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 e7527bc..f0e4292 100644
--- a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp
@@ -61,12 +61,13 @@
 
     // 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());
-    InspectorBounder inspectorBounder;
-    InspectorCanvas checker(&inspectorBounder, m_picture, bitmap);
+    checker.setBitmapDevice(bitmap);
     checker.drawPicture(*m_picture);
     m_hasText = checker.hasText();
     if (!checker.hasContent()) {
@@ -147,11 +148,11 @@
     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));
+    void* matrixStorage = malloc(canvas->getTotalMatrix().flatten(NULL));
+    void* clipStorage = malloc(canvas->getTotalClip().flatten(NULL));
 
-    canvas->getTotalMatrix().writeToMemory(matrixStorage);
-    canvas->getTotalClip().writeToMemory(clipStorage);
+    canvas->getTotalMatrix().flatten(matrixStorage);
+    canvas->getTotalClip().flatten(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 0ea8d93..5c4b453 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_GrPixelConfig;
+        renderTargetDesc.fConfig = kRGBA_8888_PM_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 64277ac..db03753 100644
--- a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp
@@ -113,7 +113,10 @@
     // Create a copy of the image
     img->setConfig(SkBitmap::kARGB_8888_Config, w, h);
     img->allocPixels();
-    SkCanvas canvas(*img);
+    SkDevice* device = new SkDevice(*img);
+    SkCanvas canvas;
+    canvas.setDevice(device);
+    device->unref();
     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 47dc8f7..415a579 100644
--- a/Source/WebCore/platform/graphics/android/rendering/InspectorCanvas.h
+++ b/Source/WebCore/platform/graphics/android/rendering/InspectorCanvas.h
@@ -40,9 +40,8 @@
 
 class InspectorCanvas : public SkCanvas {
 public:
-    InspectorCanvas(SkBounder* bounder, SkPicture* picture, SkBitmap& bitmap)
-        : SkCanvas(bitmap)
-        , m_picture(picture)
+    InspectorCanvas(SkBounder* bounder, SkPicture* picture)
+        : 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 fce5e28..24a14aa 100644
--- a/Source/WebCore/plugins/android/PluginViewAndroid.cpp
+++ b/Source/WebCore/plugins/android/PluginViewAndroid.cpp
@@ -83,6 +83,7 @@
 #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 f6fe5db..44cfccb 100644
--- a/Source/WebKit/android/jni/PicturePile.cpp
+++ b/Source/WebKit/android/jni/PicturePile.cpp
@@ -84,7 +84,8 @@
      * 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())))
+    if (canvas->quickReject(SkRect::MakeWH(m_size.width(), m_size.height()),
+            SkCanvas::kBW_EdgeType))
         return;
     drawWithClipRecursive(canvas, m_pile.size() - 1);
 }
@@ -101,7 +102,7 @@
     if (index < 0)
         return;
     PictureContainer& pc = m_pile[index];
-    if (pc.picture && !canvas->quickReject(pc.area)) {
+    if (pc.picture && !canvas->quickReject(pc.area, SkCanvas::kBW_EdgeType)) {
         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 97c15d0..650e202 100644
--- a/Source/WebKit/android/jni/ViewStateSerializer.cpp
+++ b/Source/WebKit/android/jni/ViewStateSerializer.cpp
@@ -41,8 +41,7 @@
 #include "PictureLayerContent.h"
 #include "ScrollableLayerAndroid.h"
 #include "SkData.h"
-#include "SkOrderedReadBuffer.h"
-#include "SkOrderedWriteBuffer.h"
+#include "SkFlattenable.h"
 #include "SkPicture.h"
 #include "TilesManager.h"
 
@@ -409,7 +408,7 @@
     bool hasContentsImage = layer->m_imageCRC != 0;
     stream->writeBool(hasContentsImage);
     if (hasContentsImage) {
-        SkOrderedWriteBuffer buffer(1024);
+        SkFlattenableWriteBuffer buffer(1024);
         buffer.setFlags(SkFlattenableWriteBuffer::kCrossProcess_Flag);
         ImageTexture* imagetexture =
                 ImagesManager::instance()->retainImage(layer->m_imageCRC);
@@ -528,7 +527,7 @@
         int size = stream->readU32();
         SkAutoMalloc storage(size);
         stream->read(storage.get(), size);
-        SkOrderedReadBuffer buffer(storage.get(), size);
+        SkFlattenableReadBuffer 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 06faae5..ed332aa 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 497cc9a..8779038 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 66eccb8..66dbdc1 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)
 {
-#if defined(ANDROID_DUMP_DISPLAY_TREE) && defined(SK_DEVELOPER)
+#ifdef ANDROID_DUMP_DISPLAY_TREE
     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 4519587..d6d89ff 100644
--- a/Source/WebKit/android/plugins/ANPCanvasInterface.cpp
+++ b/Source/WebKit/android/plugins/ANPCanvasInterface.cpp
@@ -80,7 +80,8 @@
 static bool anp_getLocalClipBounds(ANPCanvas* canvas, ANPRectF* r,
                                    bool antialias) {
     SkRect bounds;
-    if (canvas->skcanvas->getClipBounds(&bounds)) {
+    if (canvas->skcanvas->getClipBounds(&bounds,
+                antialias ? SkCanvas::kAA_EdgeType : SkCanvas::kBW_EdgeType)) {
         SkANP::SetRect(r, bounds);
         return true;
     }