| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 SkCanvas* canvas = recorder.beginRecording(unionRect.width(), unionRect.heig
ht(), 0, 0); | 89 SkCanvas* canvas = recorder.beginRecording(unionRect.width(), unionRect.heig
ht(), 0, 0); |
| 90 for (size_t i = 0; i < pictures.size(); ++i) { | 90 for (size_t i = 0; i < pictures.size(); ++i) { |
| 91 canvas->save(); | 91 canvas->save(); |
| 92 canvas->translate(tiles[i]->layerOffset.x() - unionRect.x(), tiles[i]->l
ayerOffset.y() - unionRect.y()); | 92 canvas->translate(tiles[i]->layerOffset.x() - unionRect.x(), tiles[i]->l
ayerOffset.y() - unionRect.y()); |
| 93 pictures[i]->playback(canvas, 0); | 93 pictures[i]->playback(canvas, 0); |
| 94 canvas->restore(); | 94 canvas->restore(); |
| 95 } | 95 } |
| 96 return adoptRef(new PictureSnapshot(adoptRef(recorder.endRecordingAsPicture(
)))); | 96 return adoptRef(new PictureSnapshot(adoptRef(recorder.endRecordingAsPicture(
)))); |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool PictureSnapshot::isEmpty() const |
| 100 { |
| 101 return m_picture->cullRect().isEmpty(); |
| 102 } |
| 103 |
| 99 PassOwnPtr<Vector<char>> PictureSnapshot::replay(unsigned fromStep, unsigned toS
tep, double scale) const | 104 PassOwnPtr<Vector<char>> PictureSnapshot::replay(unsigned fromStep, unsigned toS
tep, double scale) const |
| 100 { | 105 { |
| 101 const SkIRect bounds = m_picture->cullRect().roundOut(); | 106 const SkIRect bounds = m_picture->cullRect().roundOut(); |
| 102 SkBitmap bitmap; | 107 SkBitmap bitmap; |
| 103 bitmap.allocPixels(SkImageInfo::MakeN32Premul(bounds.width(), bounds.height(
))); | 108 bitmap.allocPixels(SkImageInfo::MakeN32Premul(bounds.width(), bounds.height(
))); |
| 104 bitmap.eraseARGB(0, 0, 0, 0); | 109 bitmap.eraseARGB(0, 0, 0, 0); |
| 105 { | 110 { |
| 106 ReplayingCanvas canvas(bitmap, fromStep, toStep); | 111 ReplayingCanvas canvas(bitmap, fromStep, toStep); |
| 107 canvas.scale(scale, scale); | 112 canvas.scale(scale, scale); |
| 108 canvas.resetStepCount(); | 113 canvas.resetStepCount(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 126 bitmap.eraseARGB(0, 0, 0, 0); | 131 bitmap.eraseARGB(0, 0, 0, 0); |
| 127 | 132 |
| 128 double now = WTF::monotonicallyIncreasingTime(); | 133 double now = WTF::monotonicallyIncreasingTime(); |
| 129 double stopTime = now + minDuration; | 134 double stopTime = now + minDuration; |
| 130 for (unsigned step = 0; step < minRepeatCount || now < stopTime; ++step) { | 135 for (unsigned step = 0; step < minRepeatCount || now < stopTime; ++step) { |
| 131 timings->append(Vector<double>()); | 136 timings->append(Vector<double>()); |
| 132 Vector<double>* currentTimings = &timings->last(); | 137 Vector<double>* currentTimings = &timings->last(); |
| 133 if (timings->size() > 1) | 138 if (timings->size() > 1) |
| 134 currentTimings->reserveCapacity(timings->begin()->size()); | 139 currentTimings->reserveCapacity(timings->begin()->size()); |
| 135 ProfilingCanvas canvas(bitmap); | 140 ProfilingCanvas canvas(bitmap); |
| 136 if (clipRect) | 141 if (clipRect) { |
| 137 canvas.clipRect(SkRect::MakeXYWH(clipRect->x(), clipRect->y(), clipR
ect->width(), clipRect->height())); | 142 canvas.clipRect(SkRect::MakeXYWH(clipRect->x(), clipRect->y(), clipR
ect->width(), clipRect->height())); |
| 143 canvas.resetStepCount(); |
| 144 } |
| 138 canvas.setTimings(currentTimings); | 145 canvas.setTimings(currentTimings); |
| 139 m_picture->playback(&canvas); | 146 m_picture->playback(&canvas); |
| 140 now = WTF::monotonicallyIncreasingTime(); | 147 now = WTF::monotonicallyIncreasingTime(); |
| 141 } | 148 } |
| 142 return timings.release(); | 149 return timings.release(); |
| 143 } | 150 } |
| 144 | 151 |
| 145 PassRefPtr<JSONArray> PictureSnapshot::snapshotCommandLog() const | 152 PassRefPtr<JSONArray> PictureSnapshot::snapshotCommandLog() const |
| 146 { | 153 { |
| 147 const SkIRect bounds = m_picture->cullRect().roundOut(); | 154 const SkIRect bounds = m_picture->cullRect().roundOut(); |
| 148 LoggingCanvas canvas(bounds.width(), bounds.height()); | 155 LoggingCanvas canvas(bounds.width(), bounds.height()); |
| 149 m_picture->playback(&canvas); | 156 m_picture->playback(&canvas); |
| 150 return canvas.log(); | 157 return canvas.log(); |
| 151 } | 158 } |
| 152 | 159 |
| 153 } // namespace blink | 160 } // namespace blink |
| OLD | NEW |