am b6cb93cf: am ae0bf538: Merge "Avoid members with the same base name in ar\'s archives"
# By dvshkurk
# Via Android Git Automerger (1) and others
* commit 'b6cb93cfb62e26168298b6f6e606af379350b064':
Avoid members with the same base name in ar's archives
diff --git a/Android.mk b/Android.mk
index ecff19e..3d59ea7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -298,7 +298,6 @@
libicuuc \
libicui18n \
libmedia \
- libmedia_native \
libnativehelper \
libskia \
libsqlite \
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/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/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..dca0dcd 100644
--- a/Source/WebCore/platform/graphics/android/layers/CanvasTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/CanvasTexture.cpp
@@ -41,7 +41,7 @@
#include "SkPixelRef.h"
#include <android/native_window.h>
-#include <gui/SurfaceTexture.h>
+#include <gui/GLConsumer.h>
#include <gui/SurfaceTextureClient.h>
namespace WebCore {
@@ -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::SurfaceTextureClient(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) {
diff --git a/Source/WebCore/platform/graphics/android/layers/CanvasTexture.h b/Source/WebCore/platform/graphics/android/layers/CanvasTexture.h
index 98962a0..f8c2f95 100644
--- a/Source/WebCore/platform/graphics/android/layers/CanvasTexture.h
+++ b/Source/WebCore/platform/graphics/android/layers/CanvasTexture.h
@@ -34,7 +34,7 @@
#include <utils/threads.h>
namespace android {
-class SurfaceTexture;
+class GLConsumer;
class SurfaceTextureClient;
}
@@ -81,7 +81,7 @@
int m_layerId;
GLuint m_texture;
android::Mutex m_surfaceLock;
- sp<android::SurfaceTexture> m_surfaceTexture;
+ sp<android::GLConsumer> m_surfaceTexture;
sp<android::SurfaceTextureClient> 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.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..188252b 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 SurfaceTextureClient 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
+ // SurfaceTextureClient 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..f02ff7c 100644
--- a/Source/WebCore/platform/graphics/android/layers/MediaListener.h
+++ b/Source/WebCore/platform/graphics/android/layers/MediaListener.h
@@ -19,7 +19,7 @@
#if USE(ACCELERATED_COMPOSITING)
-#include <gui/SurfaceTexture.h>
+#include <gui/GLConsumer.h>
#include <gui/SurfaceTextureClient.h>
#include <jni.h>
#include <JNIUtility.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..67324c7 100644
--- a/Source/WebCore/platform/graphics/android/layers/MediaTexture.cpp
+++ b/Source/WebCore/platform/graphics/android/layers/MediaTexture.cpp
@@ -29,7 +29,7 @@
#if USE(ACCELERATED_COMPOSITING)
#include <android/native_window.h>
-#include <gui/SurfaceTexture.h>
+#include <gui/GLConsumer.h>
#include <gui/SurfaceTextureClient.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::SurfaceTextureClient(
+ 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..f0e4292 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)
@@ -98,4 +101,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().flatten(NULL));
+ void* clipStorage = malloc(canvas->getTotalClip().flatten(NULL));
+
+ canvas->getTotalMatrix().flatten(matrixStorage);
+ canvas->getTotalClip().flatten(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/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/GaneshRenderer.cpp b/Source/WebCore/platform/graphics/android/rendering/GaneshRenderer.cpp
index 8b5e30a..ed57613 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. SurfaceTextureClient) buffer
TransferQueue* tileQueue = TilesManager::instance()->transferQueue();
eglSwapBuffers(eglGetCurrentDisplay(), tileQueue->m_eglSurface);
SkBitmap dummyBitmap;
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..714410e 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TextureInfo.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/TextureInfo.cpp
@@ -30,7 +30,7 @@
#include <JNIUtility.h>
#include <android/native_window.h>
-#include <gui/SurfaceTexture.h>
+#include <gui/GLConsumer.h>
#include <gui/SurfaceTextureClient.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..0ab74aa 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TilesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/TilesManager.cpp
@@ -42,7 +42,7 @@
#include <android/native_window.h>
#include <cutils/atomic.h>
-#include <gui/SurfaceTexture.h>
+#include <gui/GLConsumer.h>
#include <gui/SurfaceTextureClient.h>
#include <wtf/CurrentTime.h>
diff --git a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp
index b15fa6d..0db91bd 100644
--- a/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp
+++ b/Source/WebCore/platform/graphics/android/rendering/TransferQueue.cpp
@@ -39,7 +39,7 @@
#include "TileTexture.h"
#include "TilesManager.h"
#include <android/native_window.h>
-#include <gui/SurfaceTexture.h>
+#include <gui/GLConsumer.h>
#include <gui/SurfaceTextureClient.h>
// For simple webView usage, MINIMAL_SIZE is recommended for memory saving.
@@ -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::SurfaceTextureClient(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/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/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/ViewStateSerializer.cpp b/Source/WebKit/android/jni/ViewStateSerializer.cpp
index 8963837..650e202 100644
--- a/Source/WebKit/android/jni/ViewStateSerializer.cpp
+++ b/Source/WebKit/android/jni/ViewStateSerializer.cpp
@@ -40,6 +40,7 @@
#include "LayerContent.h"
#include "PictureLayerContent.h"
#include "ScrollableLayerAndroid.h"
+#include "SkData.h"
#include "SkFlattenable.h"
#include "SkPicture.h"
#include "TilesManager.h"
@@ -152,12 +153,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 +196,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;
}
@@ -413,7 +440,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)
@@ -509,11 +536,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/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;