| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 return false; | 157 return false; |
| 158 } | 158 } |
| 159 | 159 |
| 160 const GraphicsContextSnapshot::Timings& timingsVector() const { return *m_ti
mingsVector; } | 160 const GraphicsContextSnapshot::Timings& timingsVector() const { return *m_ti
mingsVector; } |
| 161 | 161 |
| 162 private: | 162 private: |
| 163 GraphicsContextSnapshot::Timings* m_timingsVector; | 163 GraphicsContextSnapshot::Timings* m_timingsVector; |
| 164 Vector<double>* m_currentTimings; | 164 Vector<double>* m_currentTimings; |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 class LoggingSnapshotPlayer : public SnapshotPlayer { | |
| 168 public: | |
| 169 LoggingSnapshotPlayer(PassRefPtr<SkPicture> picture, SkCanvas* canvas) | |
| 170 : SnapshotPlayer(picture, canvas) | |
| 171 { | |
| 172 } | |
| 173 | |
| 174 virtual bool abortDrawing() OVERRIDE | |
| 175 { | |
| 176 return false; | |
| 177 } | |
| 178 }; | |
| 179 | |
| 180 class LoggingCanvas : public SkCanvas { | 167 class LoggingCanvas : public SkCanvas { |
| 181 public: | 168 public: |
| 182 LoggingCanvas() | 169 LoggingCanvas(int width, int height) : SkCanvas(width, height) |
| 183 { | 170 { |
| 184 m_log = JSONArray::create(); | 171 m_log = JSONArray::create(); |
| 185 } | 172 } |
| 186 | 173 |
| 187 void clear(SkColor color) OVERRIDE | 174 void clear(SkColor color) OVERRIDE |
| 188 { | 175 { |
| 189 addItemWithParams("clear")->setString("color", stringForSkColor(color)); | 176 addItemWithParams("clear")->setString("color", stringForSkColor(color)); |
| 190 } | 177 } |
| 191 | 178 |
| 192 void drawPaint(const SkPaint& paint) OVERRIDE | 179 void drawPaint(const SkPaint& paint) OVERRIDE |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 408 |
| 422 void willRestore() OVERRIDE | 409 void willRestore() OVERRIDE |
| 423 { | 410 { |
| 424 addItem("restore"); | 411 addItem("restore"); |
| 425 this->SkCanvas::willRestore(); | 412 this->SkCanvas::willRestore(); |
| 426 } | 413 } |
| 427 | 414 |
| 428 SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint* paint,
SaveFlags flags) OVERRIDE | 415 SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint* paint,
SaveFlags flags) OVERRIDE |
| 429 { | 416 { |
| 430 RefPtr<JSONObject> params = addItemWithParams("saveLayer"); | 417 RefPtr<JSONObject> params = addItemWithParams("saveLayer"); |
| 431 params->setObject("bounds", objectForSkRect(*bounds)); | 418 if (bounds) |
| 419 params->setObject("bounds", objectForSkRect(*bounds)); |
| 432 params->setObject("paint", objectForSkPaint(*paint)); | 420 params->setObject("paint", objectForSkPaint(*paint)); |
| 433 params->setString("saveFlags", saveFlagsToString(flags)); | 421 params->setString("saveFlags", saveFlagsToString(flags)); |
| 434 this->SkCanvas::willSaveLayer(bounds, paint, flags); | 422 this->SkCanvas::willSaveLayer(bounds, paint, flags); |
| 435 return kNoLayer_SaveLayerStrategy; | 423 return kNoLayer_SaveLayerStrategy; |
| 436 } | 424 } |
| 437 | 425 |
| 438 void willSave(SaveFlags flags) OVERRIDE | 426 void willSave(SaveFlags flags) OVERRIDE |
| 439 { | 427 { |
| 440 RefPtr<JSONObject> params = addItemWithParams("save"); | 428 RefPtr<JSONObject> params = addItemWithParams("save"); |
| 441 params->setString("saveFlags", saveFlagsToString(flags)); | 429 params->setString("saveFlags", saveFlagsToString(flags)); |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 return timings.release(); | 1016 return timings.release(); |
| 1029 } | 1017 } |
| 1030 | 1018 |
| 1031 PassOwnPtr<ImageBuffer> GraphicsContextSnapshot::createImageBuffer() const | 1019 PassOwnPtr<ImageBuffer> GraphicsContextSnapshot::createImageBuffer() const |
| 1032 { | 1020 { |
| 1033 return ImageBuffer::create(IntSize(m_picture->width(), m_picture->height()),
m_isCertainlyOpaque ? Opaque : NonOpaque); | 1021 return ImageBuffer::create(IntSize(m_picture->width(), m_picture->height()),
m_isCertainlyOpaque ? Opaque : NonOpaque); |
| 1034 } | 1022 } |
| 1035 | 1023 |
| 1036 PassRefPtr<JSONArray> GraphicsContextSnapshot::snapshotCommandLog() const | 1024 PassRefPtr<JSONArray> GraphicsContextSnapshot::snapshotCommandLog() const |
| 1037 { | 1025 { |
| 1038 LoggingCanvas canvas; | 1026 LoggingCanvas canvas(m_picture->width(), m_picture->height()); |
| 1039 FragmentSnapshotPlayer player(m_picture, &canvas); | 1027 FragmentSnapshotPlayer player(m_picture, &canvas); |
| 1040 player.play(0, 0); | 1028 player.play(0, 0); |
| 1041 return canvas.log(); | 1029 return canvas.log(); |
| 1042 } | 1030 } |
| 1043 | 1031 |
| 1044 } | 1032 } |
| OLD | NEW |