diff options
10 files changed, 33 insertions, 287 deletions
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk index 710408f..f5d987d 100644 --- a/Source/WebCore/Android.mk +++ b/Source/WebCore/Android.mk @@ -677,7 +677,6 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ platform/graphics/android/PictureLayerContent.cpp \ platform/graphics/android/PictureSetLayerContent.cpp \ platform/graphics/android/PlatformGraphicsContext.cpp \ - platform/graphics/android/PerformanceMonitor.cpp \ platform/graphics/android/RasterRenderer.cpp \ platform/graphics/android/ScrollableLayerAndroid.cpp \ platform/graphics/android/SharedBufferStream.cpp \ diff --git a/Source/WebCore/platform/graphics/android/BaseRenderer.cpp b/Source/WebCore/platform/graphics/android/BaseRenderer.cpp index 6dd16e1..fb95e14 100644 --- a/Source/WebCore/platform/graphics/android/BaseRenderer.cpp +++ b/Source/WebCore/platform/graphics/android/BaseRenderer.cpp @@ -40,12 +40,13 @@ #include "SkCanvas.h" #include "SkDevice.h" #include "SkPicture.h" +#include "SkTypeface.h" #include "TilesManager.h" #include <wtf/text/CString.h> #define UPDATE_COUNT_MASK 0xFF // displayed count wraps at 256 -#define UPDATE_COUNT_ALPHA_MASK 0x3F // alpha wraps at 64 +#define UPDATE_COUNT_ALPHA_MASK 0x1F // alpha wraps at 32 namespace WebCore { @@ -70,37 +71,21 @@ void BaseRenderer::swapRendererIfNeeded(BaseRenderer*& renderer) } void BaseRenderer::drawTileInfo(SkCanvas* canvas, - const TileRenderInfo& renderInfo, int updateCount) + const TileRenderInfo& renderInfo, int updateCount, double renderDuration) { + static SkTypeface* s_typeface = 0; + if (!s_typeface) + s_typeface = SkTypeface::CreateFromName("", SkTypeface::kBold); SkPaint paint; + paint.setTextSize(17); char str[256]; - snprintf(str, 256, "(%d,%d) %.2f, tl%x p%x c%d", renderInfo.x, renderInfo.y, - renderInfo.scale, this, renderInfo.tilePainter, updateCount); - paint.setARGB(255, 0, 0, 0); - canvas->drawText(str, strlen(str), 0, 10, paint); + snprintf(str, 256, " (%d,%d) %.2fx %d %.1fms", renderInfo.x, renderInfo.y, + renderInfo.scale, updateCount, renderDuration); + paint.setARGB(128, 255, 255, 255); + canvas->drawRectCoords(0, 0, renderInfo.tileSize.fWidth, 17, paint); paint.setARGB(255, 255, 0, 0); - canvas->drawText(str, strlen(str), 0, 11, paint); - - int tagCount = 0; - const String* tags = getPerformanceTags(tagCount); - - float total = 0; - for (int i = 0; i < tagCount; i++) { - float tagDuration = m_perfMon.getAverageDuration(tags[i]); - total += tagDuration; - snprintf(str, 256, "%s: %.2f", tags[i].utf8().data(), tagDuration); - paint.setARGB(255, 0, 0, 0); - int textY = (i * 12) + 25; - canvas->drawText(str, strlen(str), 0, textY, paint); - paint.setARGB(255, 255, 0, 0); - canvas->drawText(str, strlen(str), 0, textY + 1, paint); - } - snprintf(str, 256, "total: %.2f", total); - paint.setARGB(255, 0, 0, 0); - int textY = (tagCount * 12) + 30; - canvas->drawText(str, strlen(str), 0, textY, paint); - paint.setARGB(255, 255, 0, 0); - canvas->drawText(str, strlen(str), 0, textY + 1, paint); + paint.setTypeface(s_typeface); + canvas->drawText(str, strlen(str), 20, 15, paint); } void BaseRenderer::renderTiledContent(const TileRenderInfo& renderInfo) @@ -117,8 +102,11 @@ void BaseRenderer::renderTiledContent(const TileRenderInfo& renderInfo) return; } - if (visualIndicator) + double before; + if (visualIndicator) { canvas.save(); + before = currentTimeMS(); + } setupPartialInval(renderInfo, &canvas); canvas.translate(-renderInfo.x * tileSize.width(), -renderInfo.y * tileSize.height()); @@ -126,32 +114,22 @@ void BaseRenderer::renderTiledContent(const TileRenderInfo& renderInfo) renderInfo.tilePainter->paint(renderInfo.baseTile, &canvas); if (visualIndicator) { + double after = currentTimeMS(); canvas.restore(); unsigned int updateCount = renderInfo.tilePainter->getUpdateCount() & UPDATE_COUNT_MASK; const int color = updateCount & UPDATE_COUNT_ALPHA_MASK; // only color the invalidated area - SkPaint invalPaint; - invalPaint.setARGB(color, 0, 255, 0); + SkPaint paint; + paint.setARGB(color, 0, 255, 0); if (renderInfo.invalRect) - canvas.drawIRect(*renderInfo.invalRect, invalPaint); + canvas.drawIRect(*renderInfo.invalRect, paint); else { SkIRect rect; rect.set(0, 0, tileSize.width(), tileSize.height()); - canvas.drawIRect(rect, invalPaint); + canvas.drawIRect(rect, paint); } - // paint the tile boundaries - SkPaint paint; - paint.setARGB(128, 255, 0, 0); - paint.setStrokeWidth(3); - canvas.drawLine(0, 0, tileSize.width(), tileSize.height(), paint); - paint.setARGB(128, 0, 255, 0); - canvas.drawLine(0, tileSize.height(), tileSize.width(), 0, paint); - paint.setARGB(128, 0, 0, 255); - canvas.drawLine(0, 0, tileSize.width(), 0, paint); - canvas.drawLine(tileSize.width(), 0, tileSize.width(), tileSize.height(), paint); - if (renderInfo.invalRect) { // if partial inval... int x = renderInfo.invalRect->fLeft; @@ -163,9 +141,16 @@ void BaseRenderer::renderTiledContent(const TileRenderInfo& renderInfo) canvas.drawLine(x, y, x + w, y + h, paint); canvas.drawLine(x, y + h, x + w, y, paint); } + drawTileInfo(&canvas, renderInfo, updateCount, after - before); - if (renderInfo.measurePerf) - drawTileInfo(&canvas, renderInfo, updateCount); + // paint the tile boundaries + paint.setARGB(64, 255, 0, 0); + paint.setStrokeWidth(3); + canvas.drawLine(0, 0, tileSize.width(), tileSize.height(), paint); + paint.setARGB(64, 0, 255, 0); + canvas.drawLine(0, tileSize.height(), tileSize.width(), 0, paint); + paint.setARGB(128, 0, 0, 255); + canvas.drawLine(tileSize.width(), 0, tileSize.width(), tileSize.height(), paint); } renderingComplete(renderInfo, &canvas); } diff --git a/Source/WebCore/platform/graphics/android/BaseRenderer.h b/Source/WebCore/platform/graphics/android/BaseRenderer.h index 2defcc3..4f65aff 100644 --- a/Source/WebCore/platform/graphics/android/BaseRenderer.h +++ b/Source/WebCore/platform/graphics/android/BaseRenderer.h @@ -28,8 +28,8 @@ #if USE(ACCELERATED_COMPOSITING) -#include "PerformanceMonitor.h" #include "SkRect.h" +#include <wtf/text/StringHash.h> class SkCanvas; class SkDevice; @@ -62,9 +62,6 @@ struct TileRenderInfo { // info about the texture that we are to render into TextureInfo* textureInfo; - - // specifies whether or not to measure the rendering performance - bool measurePerf; }; /** @@ -92,12 +89,7 @@ protected: virtual void renderingComplete(const TileRenderInfo& renderInfo, SkCanvas* canvas) = 0; void drawTileInfo(SkCanvas* canvas, const TileRenderInfo& renderInfo, - int updateCount); - - virtual const String* getPerformanceTags(int& tagCount) = 0; - - // Performance tracking - PerformanceMonitor m_perfMon; + int updateCount, double renderDuration); private: RendererType m_type; diff --git a/Source/WebCore/platform/graphics/android/BaseTile.cpp b/Source/WebCore/platform/graphics/android/BaseTile.cpp index d15feeb..ac8f78c 100644 --- a/Source/WebCore/platform/graphics/android/BaseTile.cpp +++ b/Source/WebCore/platform/graphics/android/BaseTile.cpp @@ -391,7 +391,6 @@ void BaseTile::paintBitmap(TilePainter* painter) if (!fullRepaint) { renderInfo.invalRect = &totalRect; - renderInfo.measurePerf = false; m_renderer->renderTiledContent(renderInfo); } } @@ -399,7 +398,6 @@ void BaseTile::paintBitmap(TilePainter* painter) // Do a full repaint if needed if (fullRepaint) { renderInfo.invalRect = 0; - renderInfo.measurePerf = TilesManager::instance()->getShowVisualIndicator(); m_renderer->renderTiledContent(renderInfo); } diff --git a/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp b/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp index 74b008c..559af1f 100644 --- a/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp +++ b/Source/WebCore/platform/graphics/android/GaneshRenderer.cpp @@ -39,16 +39,6 @@ namespace WebCore { -static const String TAG_CREATE_FBO = "create_fbo"; -static const String TAG_DRAW_PICTURE = "draw_picture"; -static const String TAG_UPDATE_TEXTURE = "update_texture"; -#define TAG_COUNT 3 -static const String TAGS[] = { - TAG_CREATE_FBO, - TAG_DRAW_PICTURE, - TAG_UPDATE_TEXTURE, -}; - GaneshRenderer::GaneshRenderer() : BaseRenderer(BaseRenderer::Ganesh) { #ifdef DEBUG_COUNT @@ -65,9 +55,6 @@ GaneshRenderer::~GaneshRenderer() void GaneshRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* canvas) { - if (renderInfo.measurePerf) - m_perfMon.start(TAG_CREATE_FBO); - GaneshContext* ganesh = GaneshContext::instance(); TransferQueue* tileQueue = TilesManager::instance()->transferQueue(); @@ -92,11 +79,6 @@ void GaneshRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* can renderInfo.tileSize.width(), renderInfo.tileSize.height()); } - if (renderInfo.measurePerf) { - m_perfMon.stop(TAG_CREATE_FBO); - m_perfMon.start(TAG_DRAW_PICTURE); - } - // set the GPU device to the canvas canvas->setDevice(device); } @@ -113,11 +95,6 @@ void GaneshRenderer::setupPartialInval(const TileRenderInfo& renderInfo, SkCanva void GaneshRenderer::renderingComplete(const TileRenderInfo& renderInfo, SkCanvas* canvas) { - if (renderInfo.measurePerf) { - m_perfMon.stop(TAG_DRAW_PICTURE); - m_perfMon.start(TAG_UPDATE_TEXTURE); - } - ALOGV("rendered to tile (%d,%d)", renderInfo.x, renderInfo.y); GaneshContext::instance()->flush(); @@ -128,15 +105,6 @@ void GaneshRenderer::renderingComplete(const TileRenderInfo& renderInfo, SkCanva eglSwapBuffers(eglGetCurrentDisplay(), tileQueue->m_eglSurface); tileQueue->addItemInTransferQueue(&renderInfo, GpuUpload, 0); tileQueue->unlockQueue(); - - if (renderInfo.measurePerf) - m_perfMon.stop(TAG_UPDATE_TEXTURE); -} - -const String* GaneshRenderer::getPerformanceTags(int& tagCount) -{ - tagCount = TAG_COUNT; - return TAGS; } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/GaneshRenderer.h b/Source/WebCore/platform/graphics/android/GaneshRenderer.h index 0e1d41e..7963a66 100644 --- a/Source/WebCore/platform/graphics/android/GaneshRenderer.h +++ b/Source/WebCore/platform/graphics/android/GaneshRenderer.h @@ -49,7 +49,6 @@ protected: virtual void setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* canvas); virtual void setupPartialInval(const TileRenderInfo& renderInfo, SkCanvas* canvas); virtual void renderingComplete(const TileRenderInfo& renderInfo, SkCanvas* canvas); - virtual const String* getPerformanceTags(int& tagCount); }; diff --git a/Source/WebCore/platform/graphics/android/PerformanceMonitor.cpp b/Source/WebCore/platform/graphics/android/PerformanceMonitor.cpp deleted file mode 100644 index ed6d046..0000000 --- a/Source/WebCore/platform/graphics/android/PerformanceMonitor.cpp +++ /dev/null @@ -1,102 +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. - */ - -#define LOG_TAG "PerformanceMonitor" -#define LOG_NDEBUG 1 - -#include "PerformanceMonitor.h" - -#include "AndroidLog.h" -#include <wtf/text/CString.h> - -namespace WebCore { - -PerformanceMonitor::PerformanceMonitor() -{ -} - -PerformanceMonitor::~PerformanceMonitor() -{ -} - -void PerformanceMonitor::start(const String &tag) -{ - if (tag.isEmpty()) - return; - PerfItem *item; - if (m_tags.contains(tag)) - item = m_tags.get(tag); - else { - item = new PerfItem(); - m_tags.set(tag, item); - } - gettimeofday(&(item->start_time), NULL); -} - -void PerformanceMonitor::stop(const String &tag) -{ - if (!m_tags.contains(tag)) - return; - PerfItem *item = m_tags.get(tag); - struct timeval end; - gettimeofday(&end, NULL); - long seconds, useconds; - seconds = end.tv_sec - item->start_time.tv_sec; - useconds = end.tv_usec - item->start_time.tv_usec; - - float mtime = (seconds * 1000.0) + (useconds/1000.0); - - if (item->average_ms) { - item->average_ms = (item->average_ms + mtime) / 2; - } else - item->average_ms = mtime; -} - -float PerformanceMonitor::getAverageDuration(const String &tag) -{ - if (tag.isEmpty() || !m_tags.contains(tag)) - return 0; - return m_tags.get(tag)->average_ms; -} - -void PerformanceMonitor::display(int limit) -{ - bool shown = false; - HashMap<String, PerfItem*, StringHash>::iterator end = m_tags.end(); - for (HashMap<String, PerfItem*, StringHash>::iterator it = m_tags.begin(); it != end; ++it) { - PerfItem* item = it->second; - if (item->average_ms > limit) { - if (!shown) { - ALOGD("=== DISPLAY MONITOR ===="); - shown = true; - } - ALOGD("item %s took longer than %d ms: %.2f", it->first.latin1().data(), limit, item->average_ms); - } - } - if (shown) - ALOGD("=== END DISPLAY MONITOR ===="); -} - -} // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/PerformanceMonitor.h b/Source/WebCore/platform/graphics/android/PerformanceMonitor.h deleted file mode 100644 index 4ebbf6a..0000000 --- a/Source/WebCore/platform/graphics/android/PerformanceMonitor.h +++ /dev/null @@ -1,59 +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. - */ - -#ifndef PerformanceMonitor_h -#define PerformanceMonitor_h - -#include "config.h" - -#include <wtf/HashMap.h> -#include <wtf/text/StringHash.h> -#include <sys/time.h> -#include <unistd.h> - -namespace WebCore { - -struct PerfItem { - PerfItem() : average_ms(0), start_time() {} - float average_ms; - struct timeval start_time; -}; - -class PerformanceMonitor { -public: - PerformanceMonitor(); - virtual ~PerformanceMonitor(); - void start(const String &tag); - void stop(const String &tag); - float getAverageDuration(const String &tag); - void display(int limit); - -private: - HashMap<String, PerfItem*, StringHash> m_tags; -}; - -} - -#endif // PerformanceMonitor_h diff --git a/Source/WebCore/platform/graphics/android/RasterRenderer.cpp b/Source/WebCore/platform/graphics/android/RasterRenderer.cpp index 44f2a7d..c218d94 100644 --- a/Source/WebCore/platform/graphics/android/RasterRenderer.cpp +++ b/Source/WebCore/platform/graphics/android/RasterRenderer.cpp @@ -37,16 +37,6 @@ namespace WebCore { -static const String TAG_CREATE_BITMAP = "create_bitmap"; -static const String TAG_DRAW_PICTURE = "draw_picture"; -static const String TAG_UPDATE_TEXTURE = "update_texture"; -#define TAG_COUNT 3 -static const String TAGS[] = { - TAG_CREATE_BITMAP, - TAG_DRAW_PICTURE, - TAG_UPDATE_TEXTURE, -}; - SkBitmap* RasterRenderer::g_bitmap = 0; RasterRenderer::RasterRenderer() : BaseRenderer(BaseRenderer::Raster) @@ -72,9 +62,6 @@ RasterRenderer::~RasterRenderer() void RasterRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* canvas) { - if (renderInfo.measurePerf) - m_perfMon.start(TAG_CREATE_BITMAP); - if (renderInfo.baseTile->isLayerTile()) { g_bitmap->setIsOpaque(false); g_bitmap->eraseARGB(0, 0, 0, 0); @@ -85,11 +72,6 @@ void RasterRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* can SkDevice* device = new SkDevice(*g_bitmap); - if (renderInfo.measurePerf) { - m_perfMon.stop(TAG_CREATE_BITMAP); - m_perfMon.start(TAG_DRAW_PICTURE); - } - canvas->setDevice(device); device->unref(); @@ -106,23 +88,8 @@ void RasterRenderer::setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* can void RasterRenderer::renderingComplete(const TileRenderInfo& renderInfo, SkCanvas* canvas) { - if (renderInfo.measurePerf) { - m_perfMon.stop(TAG_DRAW_PICTURE); - m_perfMon.start(TAG_UPDATE_TEXTURE); - } - const SkBitmap& bitmap = canvas->getDevice()->accessBitmap(false); - GLUtils::paintTextureWithBitmap(&renderInfo, bitmap); - - if (renderInfo.measurePerf) - m_perfMon.stop(TAG_UPDATE_TEXTURE); -} - -const String* RasterRenderer::getPerformanceTags(int& tagCount) -{ - tagCount = TAG_COUNT; - return TAGS; } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/RasterRenderer.h b/Source/WebCore/platform/graphics/android/RasterRenderer.h index 96b3f58..74ee52d 100644 --- a/Source/WebCore/platform/graphics/android/RasterRenderer.h +++ b/Source/WebCore/platform/graphics/android/RasterRenderer.h @@ -49,7 +49,6 @@ protected: virtual void setupCanvas(const TileRenderInfo& renderInfo, SkCanvas* canvas); virtual void renderingComplete(const TileRenderInfo& renderInfo, SkCanvas* canvas); - virtual const String* getPerformanceTags(int& tagCount); private: static SkBitmap* g_bitmap; |