diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-02-13 12:57:50 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-02-13 12:57:50 -0800 |
commit | c9c497faa69a20ac6ff0360281f8896e373a79f9 (patch) | |
tree | f1c5e97e13324b6854b486a0703044f3849b9e47 /WebKit/android | |
parent | 498e5e4ad10920a9cfae6fdb7ffb19a6ed936ba7 (diff) | |
download | external_webkit-c9c497faa69a20ac6ff0360281f8896e373a79f9.zip external_webkit-c9c497faa69a20ac6ff0360281f8896e373a79f9.tar.gz external_webkit-c9c497faa69a20ac6ff0360281f8896e373a79f9.tar.bz2 |
auto import from //branches/cupcake/...@131421
Diffstat (limited to 'WebKit/android')
-rw-r--r-- | WebKit/android/TimeCounter.cpp | 57 | ||||
-rw-r--r-- | WebKit/android/TimeCounter.h | 15 | ||||
-rw-r--r-- | WebKit/android/jni/PictureSet.cpp | 18 | ||||
-rw-r--r-- | WebKit/android/jni/PictureSet.h | 1 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 36 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 2 | ||||
-rw-r--r-- | WebKit/android/nav/CacheBuilder.cpp | 1 | ||||
-rw-r--r-- | WebKit/android/nav/WebView.cpp | 14 | ||||
-rw-r--r-- | WebKit/android/plugins/ANPSoundInterface.cpp | 2 |
9 files changed, 110 insertions, 36 deletions
diff --git a/WebKit/android/TimeCounter.cpp b/WebKit/android/TimeCounter.cpp index 0c8fe3b..c92afb2 100644 --- a/WebKit/android/TimeCounter.cpp +++ b/WebKit/android/TimeCounter.cpp @@ -43,9 +43,16 @@ namespace android { static double sStartTotalTime; static uint32_t sStartThreadTime; +static double sLastTotalTime; +static uint32_t sLastThreadTime; +uint32_t TimeCounter::sStartWebCoreThreadTime; +uint32_t TimeCounter::sEndWebCoreThreadTime; +bool TimeCounter::sRecordWebCoreTime; uint32_t TimeCounter::sTotalTimeUsed[TimeCounter::TotalTimeCounterCount]; +uint32_t TimeCounter::sLastTimeUsed[TimeCounter::TotalTimeCounterCount]; uint32_t TimeCounter::sCounter[TimeCounter::TotalTimeCounterCount]; +uint32_t TimeCounter::sLastCounter[TimeCounter::TotalTimeCounterCount]; uint32_t TimeCounter::sStartTime[TimeCounter::TotalTimeCounterCount]; static const char* timeCounterNames[] = { @@ -54,10 +61,12 @@ static const char* timeCounterNames[] = { "Java callback (frame bridge)", "layout", "native 1 (frame bridge)", - // "paint", "parsing (may include calcStyle or Java callback)", "native 3 (resource load)", "native 2 (shared timer)", + "build nav (webview core)", + "draw content (webview core)", + "record content (webview core)", "native 4 (webview core)" }; @@ -69,7 +78,8 @@ void TimeCounter::record(enum Type type, const char* functionName) void TimeCounter::recordNoCounter(enum Type type, const char* functionName) { - uint32_t elapsed = get_thread_msec() - sStartTime[type]; + uint32_t time = sEndWebCoreThreadTime = get_thread_msec(); + uint32_t elapsed = time - sStartTime[type]; sTotalTimeUsed[type] += elapsed; if (elapsed > 1000) LOGW("***** %s() used %d ms\n", functionName, elapsed); @@ -81,10 +91,11 @@ void TimeCounter::report(const KURL& url, int live, int dead) int totalTime = static_cast<int>((currentTime() - sStartTotalTime) * 1000); int threadTime = get_thread_msec() - sStartThreadTime; LOGD("*-* Total load time: %d ms, thread time: %d ms for %s\n", - totalTime, threadTime, urlString.utf8().data()); + totalTime, threadTime, urlString.utf8().data()); // FIXME: JSGlobalObject no longer records time // JSC::JSGlobalObject::reportTimeCounter(); - for (Type type = (Type) 0; type < TotalTimeCounterCount; type = (Type) (type + 1)) { + for (Type type = (Type) 0; type < TotalTimeCounterCount; type + = (Type) (type + 1)) { char scratch[256]; int index = sprintf(scratch, "*-* Total %s time: %d ms", timeCounterNames[type], sTotalTimeUsed[type]); @@ -95,6 +106,36 @@ void TimeCounter::report(const KURL& url, int live, int dead) LOGD("Current cache has %d bytes live and %d bytes dead", live, dead); } +void TimeCounter::reportNow() +{ + double current = currentTime(); + uint32_t currentThread = get_thread_msec(); + int elapsedTime = static_cast<int>((current - sLastTotalTime) * 1000); + int elapsedThreadTime = currentThread - sLastThreadTime; + LOGD("*-* Elapsed time: %d ms, ui thread time: %d ms, webcore thread time:" + " %d ms\n", elapsedTime, elapsedThreadTime, sEndWebCoreThreadTime - + sStartWebCoreThreadTime); +// FIXME: JSGlobalObject no longer records time +// JSC::JSGlobalObject::reportTimeCounter(); + for (Type type = (Type) 0; type < TotalTimeCounterCount; type + = (Type) (type + 1)) { + if (sTotalTimeUsed[type] == sLastTimeUsed[type]) + continue; + char scratch[256]; + int index = sprintf(scratch, "*-* Diff %s time: %d ms", + timeCounterNames[type], sTotalTimeUsed[type] - sLastTimeUsed[type]); + if (sCounter[type] > sLastCounter[type]) + sprintf(&scratch[index], " called %d times", sCounter[type] + - sLastCounter[type]); + LOGD("%s", scratch); + } + memcpy(sLastTimeUsed, sTotalTimeUsed, sizeof(sTotalTimeUsed)); + memcpy(sLastCounter, sCounter, sizeof(sCounter)); + sLastTotalTime = current; + sLastThreadTime = currentThread; + sRecordWebCoreTime = true; +} + void TimeCounter::reset() { // FIXME: JSGlobalObject no longer records time // JSC::JSGlobalObject::resetTimeCounter(); @@ -107,10 +148,14 @@ void TimeCounter::reset() { void TimeCounter::start(enum Type type) { - sStartTime[type] = get_thread_msec(); + uint32_t time = get_thread_msec(); + if (sRecordWebCoreTime) { + sStartWebCoreThreadTime = time; + sRecordWebCoreTime = false; + } + sStartTime[type] = time; } - #endif } diff --git a/WebKit/android/TimeCounter.h b/WebKit/android/TimeCounter.h index 369eb4e..58d2468 100644 --- a/WebKit/android/TimeCounter.h +++ b/WebKit/android/TimeCounter.h @@ -46,10 +46,12 @@ public: JavaCallbackTimeCounter, LayoutTimeCounter, NativeCallbackTimeCounter, - // PaintTimeCounter, // FIXME: WebCore no longer records draw time ParsingTimeCounter, ResourceTimeCounter, SharedTimerTimeCounter, + WebViewCoreBuildNavTimeCounter, + WebViewCoreDrawTimeCounter, + WebViewCoreRecordTimeCounter, WebViewCoreTimeCounter, TotalTimeCounterCount }; @@ -57,11 +59,17 @@ public: static void record(enum Type type, const char* functionName); static void recordNoCounter(enum Type type, const char* functionName); static void report(const WebCore::KURL& , int live, int dead); + static void reportNow(); static void reset(); static void start(enum Type type); private: + static uint32_t sStartWebCoreThreadTime; + static uint32_t sEndWebCoreThreadTime; + static bool sRecordWebCoreTime; static uint32_t sTotalTimeUsed[TotalTimeCounterCount]; + static uint32_t sLastTimeUsed[TotalTimeCounterCount]; static uint32_t sCounter[TotalTimeCounterCount]; + static uint32_t sLastCounter[TotalTimeCounterCount]; static uint32_t sStartTime[TotalTimeCounterCount]; friend class TimeCounterAuto; }; @@ -71,7 +79,10 @@ public: TimeCounterAuto(TimeCounter::Type type) : m_type(type), m_startTime(WebCore::get_thread_msec()) {} ~TimeCounterAuto() { - TimeCounter::sTotalTimeUsed[m_type] += WebCore::get_thread_msec() - m_startTime; + uint32_t time = WebCore::get_thread_msec(); + TimeCounter::sEndWebCoreThreadTime = time; + TimeCounter::sTotalTimeUsed[m_type] += time - m_startTime; + TimeCounter::sCounter[m_type]++; } private: TimeCounter::Type m_type; diff --git a/WebKit/android/jni/PictureSet.cpp b/WebKit/android/jni/PictureSet.cpp index 410769e..65aac8f 100644 --- a/WebKit/android/jni/PictureSet.cpp +++ b/WebKit/android/jni/PictureSet.cpp @@ -601,24 +601,6 @@ void PictureSet::split(PictureSet* out) const out->dump("split-out"); } -void PictureSet::toPicture(SkPicture* result) const -{ - DBG_SET_LOGD("%p", this); - SkPicture tempPict; - SkAutoPictureRecord arp(&tempPict, mWidth, mHeight); - SkCanvas* recorder = arp.getRecordingCanvas(); - const Pictures* last = mPictures.end(); - for (const Pictures* working = mPictures.begin(); working != last; working++) { - int saved = recorder->save(); - SkPath pathBounds; - working->mArea.getBoundaryPath(&pathBounds); - recorder->clipPath(pathBounds); - recorder->drawPicture(*working->mPicture); - recorder->restoreToCount(saved); - } - result->swap(tempPict); -} - bool PictureSet::validate(const char* funct) const { bool valid = true; diff --git a/WebKit/android/jni/PictureSet.h b/WebKit/android/jni/PictureSet.h index ce94fc0..ae250b0 100644 --- a/WebKit/android/jni/PictureSet.h +++ b/WebKit/android/jni/PictureSet.h @@ -73,7 +73,6 @@ namespace android { void setPicture(size_t i, SkPicture* p); size_t size() const { return mPictures.size(); } void split(PictureSet* result) const; - void toPicture(SkPicture* ) const; bool upToDate(size_t i) const { return mPictures[i].mPicture != NULL; } int width() const { return mWidth; } void dump(const char* label) const; diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 12dc9ef..fc32b98 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -113,6 +113,12 @@ FILE* gRenderTreeFile = 0; #include "TimeCounter.h" #endif +/* We pass this flag when recording the actual content, so that we don't spend + time actually regionizing complex path clips, when all we really want to do + is record them. + */ +#define PICT_RECORD_FLAGS SkPicture::kUsePathBoundsForClip_RecordingFlag + //////////////////////////////////////////////////////////////////////////////////////////////// namespace android { @@ -315,7 +321,8 @@ void WebViewCore::recordPicture(SkPicture* picture) return; // draw into the picture's recording canvas WebCore::FrameView* view = m_mainFrame->view(); - SkAutoPictureRecord arp(picture, view->contentsWidth(), view->contentsHeight()); + SkAutoPictureRecord arp(picture, view->contentsWidth(), + view->contentsHeight(), PICT_RECORD_FLAGS); SkAutoMemoryUsageProbe mup(__FUNCTION__); // Copy m_buttons so we can pass it to our graphics context. @@ -452,12 +459,19 @@ void WebViewCore::copyContentToPicture(SkPicture* picture) m_contentMutex.lock(); PictureSet copyContent = PictureSet(m_content); m_contentMutex.unlock(); - copyContent.toPicture(picture); + + int w = copyContent.width(); + int h = copyContent.height(); + copyContent.draw(picture->beginRecording(w, h, PICT_RECORD_FLAGS)); + picture->endRecording(); DBG_SET_LOG("end"); } bool WebViewCore::drawContent(SkCanvas* canvas, SkColor color) { +#ifdef ANDROID_INSTRUMENT + TimeCounterAuto counter(TimeCounter::WebViewCoreDrawTimeCounter); +#endif DBG_SET_LOG("start"); m_contentMutex.lock(); PictureSet copyContent = PictureSet(m_content); @@ -521,6 +535,9 @@ void WebViewCore::rebuildPictureSet(PictureSet* pictureSet) bool WebViewCore::recordContent(SkRegion* region, SkIPoint* point) { +#ifdef ANDROID_INSTRUMENT + TimeCounterAuto counter(TimeCounter::WebViewCoreRecordTimeCounter); +#endif DBG_SET_LOG("start"); m_contentMutex.lock(); PictureSet contentCopy(m_content); @@ -847,6 +864,9 @@ bool WebViewCore::prepareFrameCache() DBG_NAV_LOG("!m_frameCacheOutOfDate"); return false; } +#ifdef ANDROID_INSTRUMENT + TimeCounterAuto counter(TimeCounter::WebViewCoreBuildNavTimeCounter); +#endif m_frameCacheOutOfDate = false; #if DEBUG_NAV_UI DBG_NAV_LOG("m_frameCacheOutOfDate was true"); @@ -1442,9 +1462,11 @@ void WebViewCore::passToJs(WebCore::Frame* frame, WebCore::Node* node, int x, in } } -void WebViewCore::saveDocumentState(WebCore::Frame* frame, WebCore::Node* node, int x, int y) +void WebViewCore::saveDocumentState(WebCore::Frame* frame) { - frame = changedKitFocus(frame, node, x, y); + if (!FrameLoaderClientAndroid::get(m_mainFrame)->getCacheBuilder() + .validNode(frame, 0)) + frame = m_mainFrame; WebCore::HistoryItem *item = frame->loader()->currentHistoryItem(); // item can be null when there is no offical URL for the current page. This happens @@ -2041,7 +2063,7 @@ static void PassToJs(JNIEnv *env, jobject obj, jint frame, jint node, x, y, generation, currentText, keyCode, keyValue, down, cap, fn, sym); } -static void SaveDocumentState(JNIEnv *env, jobject obj, jint frame, jint node, jint x, jint y) +static void SaveDocumentState(JNIEnv *env, jobject obj, jint frame) { #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); @@ -2049,7 +2071,7 @@ static void SaveDocumentState(JNIEnv *env, jobject obj, jint frame, jint node, j LOGV("webviewcore::nativeSaveDocumentState()\n"); WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); LOG_ASSERT(viewImpl, "viewImpl not set in nativeSaveDocumentState"); - viewImpl->saveDocumentState((WebCore::Frame*) frame, (WebCore::Node*) node, x, y); + viewImpl->saveDocumentState((WebCore::Frame*) frame); } static bool RecordContent(JNIEnv *env, jobject obj, jobject region, jobject pt) @@ -2365,7 +2387,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) ReplaceTextfieldText } , { "passToJs", "(IIIIILjava/lang/String;IIZZZZ)V", (void*) PassToJs } , - { "nativeSaveDocumentState", "(IIII)V", + { "nativeSaveDocumentState", "(I)V", (void*) SaveDocumentState }, { "nativeFindAddress", "(Ljava/lang/String;)Ljava/lang/String;", (void*) FindAddress }, diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 29bdf37..6ae0de1 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -257,7 +257,7 @@ namespace android { void passToJs(WebCore::Frame* frame, WebCore::Node* node, int x, int y, int generation, jstring currentText, int jKeyCode, int keyVal, bool down, bool cap, bool fn, bool sym); - void saveDocumentState(WebCore::Frame* frame, WebCore::Node* node, int x, int y); + void saveDocumentState(WebCore::Frame* frame); // TODO: I don't like this hack but I need to access the java object in // order to send it as a parameter to java diff --git a/WebKit/android/nav/CacheBuilder.cpp b/WebKit/android/nav/CacheBuilder.cpp index 9efcbd7..8b31de6 100644 --- a/WebKit/android/nav/CacheBuilder.cpp +++ b/WebKit/android/nav/CacheBuilder.cpp @@ -1218,6 +1218,7 @@ void CacheBuilder::BuildFrame(Frame* root, Frame* frame, // FIXME: Are we sure there will always be a style and font, and it's correct? RenderStyle* style = nodeRenderer->style(); if (style) { + isUnclipped |= !style->hasAppearance(); textSize = style->fontSize(); isRtlText = style->direction() == RTL || style->textAlign() == WebCore::RIGHT || diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index fc34c84..39c53aa 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -55,6 +55,10 @@ #include "WebViewCore.h" #include "jni_utility.h" +#ifdef ANDROID_INSTRUMENT +#include "TimeCounter.h" +#endif + #ifdef GET_NATIVE_VIEW #undef GET_NATIVE_VIEW #endif @@ -775,6 +779,7 @@ OutOfFocusFix fixOutOfDateFocus(bool useReplay) int webWidth = webRoot->width(); if (uiWidth != webWidth) { DBG_NAV_LOGD("uiWidth=%d webWidth=%d", uiWidth, webWidth); + return DoNothing; // allow text inputs to preserve their state } else { const WebCore::IntRect& cachedBounds = m_frameCacheUI->focusBounds(); const CachedFrame* webFrame = 0; @@ -1922,6 +1927,13 @@ static bool nativeFocusNodeWantsKeyEvents(JNIEnv* env, jobject jwebview) { return view->focusNodeWantsKeyEvents(); } +static void nativeInstrumentReport(JNIEnv *env, jobject obj) +{ +#ifdef ANDROID_INSTRUMENT + TimeCounter::reportNow(); +#endif +} + static WebCore::IntRect jrect_to_webrect(JNIEnv* env, jobject obj) { int L, T, R, B; @@ -2230,6 +2242,8 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeGetFocusRingBounds }, { "nativeGetNavBounds", "()Landroid/graphics/Rect;", (void*) nativeGetNavBounds }, + { "nativeInstrumentReport", "()V", + (void*) nativeInstrumentReport }, { "nativeMarkNodeInvalid", "(I)V", (void*) nativeMarkNodeInvalid }, { "nativeMotionUp", "(IIIZ)V", diff --git a/WebKit/android/plugins/ANPSoundInterface.cpp b/WebKit/android/plugins/ANPSoundInterface.cpp index 9b7d8d0..6b019d1 100644 --- a/WebKit/android/plugins/ANPSoundInterface.cpp +++ b/WebKit/android/plugins/ANPSoundInterface.cpp @@ -94,7 +94,7 @@ static ANPAudioTrack* ANPCreateTrack(uint32_t sampleRate, track->mUser = user; track->mProc = proc; - track->mTrack = new android::AudioTrack(android::AudioTrack::MUSIC, + track->mTrack = new android::AudioTrack(android::AudioSystem::MUSIC, sampleRate, fromANPFormat(format), channelCount, |