diff options
Diffstat (limited to 'Source/WebKit')
-rw-r--r-- | Source/WebKit/android/RenderSkinMediaButton.cpp | 3 | ||||
-rw-r--r-- | Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp | 4 | ||||
-rw-r--r-- | Source/WebKit/android/jni/PictureSet.cpp | 38 | ||||
-rw-r--r-- | Source/WebKit/android/jni/PictureSet.h | 10 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 28 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.h | 4 |
6 files changed, 83 insertions, 4 deletions
diff --git a/Source/WebKit/android/RenderSkinMediaButton.cpp b/Source/WebKit/android/RenderSkinMediaButton.cpp index febf575..b3aa57d 100644 --- a/Source/WebKit/android/RenderSkinMediaButton.cpp +++ b/Source/WebKit/android/RenderSkinMediaButton.cpp @@ -95,6 +95,9 @@ void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonT Decode(); } + if (!canvas) + return; + // If we failed to decode, do nothing. This way the browser still works, // and webkit will still draw the label and layout space for us. if (gDecodingFailed) diff --git a/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp b/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp index 95ced96..52aeb23 100644 --- a/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp +++ b/Source/WebKit/android/WebCoreSupport/MediaPlayerPrivateAndroid.cpp @@ -264,7 +264,9 @@ public: if (!m_poster || (!m_poster->getPixels() && !m_poster->pixelRef())) return; - SkCanvas* canvas = ctxt->platformContext()->mCanvas; + SkCanvas* canvas = ctxt->platformContext()->getCanvas(); + if (!canvas) + return; // We paint with the following rules in mind: // - only downscale the poster, never upscale // - maintain the natural aspect ratio of the poster diff --git a/Source/WebKit/android/jni/PictureSet.cpp b/Source/WebKit/android/jni/PictureSet.cpp index f3534eb..8beb0ef 100644 --- a/Source/WebKit/android/jni/PictureSet.cpp +++ b/Source/WebKit/android/jni/PictureSet.cpp @@ -38,6 +38,8 @@ #include "SkRegion.h" #include "SkStream.h" +#include "PlatformGraphicsContext.h" + #define MAX_DRAW_TIME 100 #define MIN_SPLITTABLE 400 #define MAX_ADDITIONAL_AREA 0.65 @@ -133,6 +135,9 @@ void PictureSet::add(const Pictures* temp) { Pictures pictureAndBounds = *temp; SkSafeRef(pictureAndBounds.mPicture); +#ifdef CONTEXT_RECORDING + SkSafeRef(pictureAndBounds.mGraphicsOperationCollection); +#endif pictureAndBounds.mWroteElapsed = false; mPictures.append(pictureAndBounds); } @@ -478,13 +483,20 @@ void PictureSet::add(const SkIRect& area, uint32_t elapsed, bool split, bool emp working->mArea.setEmpty(); SkSafeUnref(working->mPicture); working->mPicture = 0; +#ifdef CONTEXT_RECORDING + SkSafeUnref(working->mGraphicsOperationCollection); + working->mGraphicsOperationCollection = 0; +#endif } } // Now we can add the new Picture to the list, with the correct area // that need to be repainted - Pictures pictureAndBounds = {totalArea, 0, totalArea, - elapsed, split, false, false, empty}; + Pictures pictureAndBounds = {totalArea, 0, +#ifdef CONTEXT_RECORDING + 0, +#endif + totalArea, elapsed, split, false, false, empty}; #ifdef FAST_PICTURESET if (mPictures.size() == 0) @@ -525,6 +537,10 @@ void PictureSet::add(const SkIRect& area, uint32_t elapsed, bool split, bool emp working->mArea.setEmpty(); SkSafeUnref(working->mPicture); working->mPicture = 0; +#ifdef CONTEXT_RECORDING + SkSafeUnref(working->mGraphicsOperationCollection); + working->mGraphicsOperationCollection = 0; +#endif } } @@ -677,6 +693,9 @@ void PictureSet::clear() for (Pictures* working = mPictures.begin(); working != last; working++) { working->mArea.setEmpty(); SkSafeUnref(working->mPicture); +#ifdef CONTEXT_RECORDING + SkSafeUnref(working->mGraphicsOperationCollection); +#endif } mPictures.clear(); #endif // FAST_PICTURESET @@ -797,7 +816,14 @@ bool PictureSet::draw(SkCanvas* canvas) canvas->translate(pathBounds.fLeft, pathBounds.fTop); canvas->save(); uint32_t startTime = getThreadMsec(); + +#ifdef CONTEXT_RECORDING + WebCore::PlatformGraphicsContextSkia context(canvas); + working->mGraphicsOperationCollection->apply(&context); +#else canvas->drawPicture(*working->mPicture); +#endif + size_t elapsed = working->mElapsed = getThreadMsec() - startTime; working->mWroteElapsed = true; if (maxElapsed < elapsed && (pathBounds.width() >= MIN_SPLITTABLE || @@ -1060,6 +1086,14 @@ void PictureSet::setPicture(size_t i, SkPicture* p) mPictures[i].mEmpty = emptyPicture(p); } +#ifdef CONTEXT_RECORDING +void PictureSet::setGraphicsOperationCollection(size_t i, WebCore::GraphicsOperationCollection* p) +{ + SkSafeUnref(mPictures[i].mGraphicsOperationCollection); + mPictures[i].mGraphicsOperationCollection = p; +} +#endif + void PictureSet::split(PictureSet* out) const { dump(__FUNCTION__); diff --git a/Source/WebKit/android/jni/PictureSet.h b/Source/WebKit/android/jni/PictureSet.h index 1d9a14d..1e639da 100644 --- a/Source/WebKit/android/jni/PictureSet.h +++ b/Source/WebKit/android/jni/PictureSet.h @@ -45,7 +45,10 @@ #include <wtf/Vector.h> #include <wtf/HashMap.h> +#include "GraphicsOperationCollection.h" + // #define FAST_PICTURESET // use a hierarchy of pictures +// #define CONTEXT_RECORDING // use the new PlatformGraphicsContextRecording class SkCanvas; class SkPicture; @@ -100,6 +103,9 @@ namespace android { const SkIRect& bounds(size_t i) const { return mPictures[i].mArea; } void setPicture(size_t i, SkPicture* p); +#ifdef CONTEXT_RECORDING + void setGraphicsOperationCollection(size_t i, WebCore::GraphicsOperationCollection* p); +#endif void setDrawTimes(const PictureSet& ); size_t size() const { return mPictures.size(); } void split(PictureSet* result) const; @@ -119,9 +125,13 @@ namespace android { int mBucketCountX; int mBucketCountY; #else + struct Pictures { SkIRect mArea; SkPicture* mPicture; +#ifdef CONTEXT_RECORDING + WebCore::GraphicsOperationCollection* mGraphicsOperationCollection; +#endif SkIRect mUnsplit; uint32_t mElapsed; bool mSplit : 8; diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index 540b1dd..6270c63 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -62,6 +62,7 @@ #include "Geolocation.h" #include "GraphicsContext.h" #include "GraphicsJNI.h" +#include "GraphicsOperationCollection.h" #include "HTMLAnchorElement.h" #include "HTMLAreaElement.h" #include "HTMLElement.h" @@ -787,7 +788,7 @@ SkPicture* WebViewCore::rebuildPicture(const SkIRect& inval) SkAutoMemoryUsageProbe mup(__FUNCTION__); SkCanvas* recordingCanvas = arp.getRecordingCanvas(); - WebCore::PlatformGraphicsContext pgc(recordingCanvas); + WebCore::PlatformGraphicsContextSkia pgc(recordingCanvas); WebCore::GraphicsContext gc(&pgc); IntPoint origin = view->minimumScrollPosition(); WebCore::IntRect drawArea(inval.fLeft + origin.x(), inval.fTop + origin.y(), @@ -803,6 +804,27 @@ SkPicture* WebViewCore::rebuildPicture(const SkIRect& inval) return picture; } +#ifdef CONTEXT_RECORDING +GraphicsOperationCollection* WebViewCore::rebuildGraphicsOperationCollection(const SkIRect& inval) +{ + WebCore::FrameView* view = m_mainFrame->view(); + int width = view->contentsWidth(); + int height = view->contentsHeight(); + + IntPoint origin = view->minimumScrollPosition(); + WebCore::IntRect drawArea(inval.fLeft + origin.x(), inval.fTop + origin.y(), + inval.width(), inval.height()); + + AutoGraphicsOperationCollection autoPicture(drawArea); + view->platformWidget()->draw(autoPicture.context(), drawArea); + + m_rebuildInval.op(inval, SkRegion::kUnion_Op); + + SkSafeRef(autoPicture.picture()); + return autoPicture.picture(); +} +#endif + void WebViewCore::rebuildPictureSet(PictureSet* pictureSet) { #ifdef FAST_PICTURESET @@ -828,6 +850,10 @@ void WebViewCore::rebuildPictureSet(PictureSet* pictureSet) DBG_SET_LOGD("pictSet=%p [%d] {%d,%d,w=%d,h=%d}", pictureSet, index, inval.fLeft, inval.fTop, inval.width(), inval.height()); pictureSet->setPicture(index, rebuildPicture(inval)); +#ifdef CONTEXT_RECORDING + pictureSet->setGraphicsOperationCollection(index, + rebuildGraphicsOperationCollection(inval)); +#endif } pictureSet->validate(__FUNCTION__); diff --git a/Source/WebKit/android/jni/WebViewCore.h b/Source/WebKit/android/jni/WebViewCore.h index 23568bb..99a13f3 100644 --- a/Source/WebKit/android/jni/WebViewCore.h +++ b/Source/WebKit/android/jni/WebViewCore.h @@ -53,6 +53,7 @@ namespace WebCore { class Color; + class GraphicsOperationCollection; class FrameView; class HTMLAnchorElement; class HTMLElement; @@ -641,6 +642,9 @@ namespace android { void recordPictureSet(PictureSet* master); SkPicture* rebuildPicture(const SkIRect& inval); +#ifdef CONTEXT_RECORDING + WebCore::GraphicsOperationCollection* rebuildGraphicsOperationCollection(const SkIRect& inval); +#endif void rebuildPictureSet(PictureSet* ); void sendNotifyProgressFinished(); /* |