| Index: Source/platform/graphics/GraphicsContextRecorder.cpp
|
| diff --git a/Source/platform/graphics/GraphicsContextRecorder.cpp b/Source/platform/graphics/GraphicsContextRecorder.cpp
|
| index 02615de435184b81902e47fee8b0ae3087c9a66d..86d11ccaa34916baa927e96142545992afce73a7 100644
|
| --- a/Source/platform/graphics/GraphicsContextRecorder.cpp
|
| +++ b/Source/platform/graphics/GraphicsContextRecorder.cpp
|
| @@ -164,22 +164,14 @@ private:
|
| Vector<double>* m_currentTimings;
|
| };
|
|
|
| -class LoggingSnapshotPlayer : public SnapshotPlayer {
|
| +class LoggingCanvas : public SkCanvas {
|
| public:
|
| - LoggingSnapshotPlayer(PassRefPtr<SkPicture> picture, SkCanvas* canvas)
|
| - : SnapshotPlayer(picture, canvas)
|
| + LoggingCanvas(int width, int height) : SkCanvas(width, height)
|
| {
|
| + initLog();
|
| }
|
|
|
| - virtual bool abortDrawing() OVERRIDE
|
| - {
|
| - return false;
|
| - }
|
| -};
|
| -
|
| -class LoggingCanvas : public SkCanvas {
|
| -public:
|
| - LoggingCanvas()
|
| + void initLog()
|
| {
|
| m_log = JSONArray::create();
|
| }
|
| @@ -428,7 +420,8 @@ public:
|
| SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags) OVERRIDE
|
| {
|
| RefPtr<JSONObject> params = addItemWithParams("saveLayer");
|
| - params->setObject("bounds", objectForSkRect(*bounds));
|
| + if (bounds)
|
| + params->setObject("bounds", objectForSkRect(*bounds));
|
| params->setObject("paint", objectForSkPaint(*paint));
|
| params->setString("saveFlags", saveFlagsToString(flags));
|
| this->SkCanvas::willSaveLayer(bounds, paint, flags);
|
| @@ -988,6 +981,36 @@ private:
|
| }
|
| };
|
|
|
| +class LoggingSnapshotPlayer : public SnapshotPlayer {
|
| +public:
|
| + LoggingSnapshotPlayer(PassRefPtr<SkPicture> picture, LoggingCanvas* canvas)
|
| + : SnapshotPlayer(picture, canvas)
|
| + {
|
| + }
|
| +
|
| + void play(unsigned fromStep, unsigned toStep)
|
| + {
|
| + m_fromStep = fromStep;
|
| + m_toStep = toStep;
|
| + m_stepCount = 0;
|
| + SnapshotPlayer::play();
|
| + }
|
| +
|
| + virtual bool abortDrawing() OVERRIDE
|
| + {
|
| + ++m_stepCount;
|
| + if (m_stepCount == m_fromStep) {
|
| + static_cast<LoggingCanvas*>(canvas())->initLog();
|
| + }
|
| + return m_toStep && m_stepCount > m_toStep;
|
| + }
|
| +
|
| +private:
|
| + unsigned m_fromStep;
|
| + unsigned m_toStep;
|
| + unsigned m_stepCount;
|
| +};
|
| +
|
| static bool decodeBitmap(const void* data, size_t length, SkBitmap* result)
|
| {
|
| RefPtr<SharedBuffer> buffer = SharedBuffer::create(static_cast<const char*>(data), length);
|
| @@ -1033,11 +1056,11 @@ PassOwnPtr<ImageBuffer> GraphicsContextSnapshot::createImageBuffer() const
|
| return ImageBuffer::create(IntSize(m_picture->width(), m_picture->height()), m_isCertainlyOpaque ? Opaque : NonOpaque);
|
| }
|
|
|
| -PassRefPtr<JSONArray> GraphicsContextSnapshot::snapshotCommandLog() const
|
| +PassRefPtr<JSONArray> GraphicsContextSnapshot::snapshotCommandLog(unsigned fromStep, unsigned toStep) const
|
| {
|
| - LoggingCanvas canvas;
|
| - FragmentSnapshotPlayer player(m_picture, &canvas);
|
| - player.play(0, 0);
|
| + LoggingCanvas canvas(m_picture->width(), m_picture->height());
|
| + LoggingSnapshotPlayer player(m_picture, &canvas);
|
| + player.play(fromStep, toStep);
|
| return canvas.log();
|
| }
|
|
|
|
|