| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PaintTiming_h | 5 #ifndef PaintTiming_h |
| 6 #define PaintTiming_h | 6 #define PaintTiming_h |
| 7 | 7 |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "platform/Supplementable.h" | 9 #include "platform/Supplementable.h" |
| 10 #include "platform/geometry/IntRect.h" |
| 10 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
| 12 #include "wtf/HashMap.h" |
| 13 #include "wtf/Int32Array.h" |
| 11 | 14 |
| 12 namespace blink { | 15 namespace blink { |
| 13 | 16 |
| 14 class LocalFrame; | 17 class LocalFrame; |
| 15 | 18 |
| 16 class PaintTiming final : public NoBaseWillBeGarbageCollectedFinalized<PaintTimi
ng>, public WillBeHeapSupplement<Document> { | 19 class PaintTiming final : public NoBaseWillBeGarbageCollectedFinalized<PaintTimi
ng>, public WillBeHeapSupplement<Document> { |
| 17 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PaintTiming); | 20 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PaintTiming); |
| 18 public: | 21 public: |
| 19 virtual ~PaintTiming() { } | 22 virtual ~PaintTiming() { } |
| 20 | 23 |
| 21 static PaintTiming& from(Document&); | 24 static PaintTiming& from(Document&); |
| 22 | 25 |
| 23 void markFirstPaint(); | 26 void markFirstPaint(); |
| 24 void markFirstTextPaint(); | 27 void markFirstTextPaint(); |
| 25 void markFirstImagePaint(); | 28 void markFirstImagePaint(); |
| 29 void markPaintInvalidation(const IntRect* visualRect, int paintCount); |
| 26 | 30 |
| 27 // These return monotonically-increasing seconds. | 31 // These return monotonically-increasing seconds. |
| 28 double firstPaint() const { return m_firstPaint; } | 32 double firstPaint() const { return m_firstPaint; } |
| 29 double firstTextPaint() const { return m_firstTextPaint; } | 33 double firstTextPaint() const { return m_firstTextPaint; } |
| 30 double firstImagePaint() const { return m_firstImagePaint; } | 34 double firstImagePaint() const { return m_firstImagePaint; } |
| 31 | 35 |
| 36 // When a consumer asks for the speed index, stop collecting and analyzing |
| 37 // invalidation rects and give the result using information collected at the |
| 38 // first request time. |
| 39 double speedIndex(double referenceTime) const; |
| 40 |
| 41 void setLoadCommitted() { m_loadCommitted = true; } |
| 42 |
| 32 DECLARE_VIRTUAL_TRACE(); | 43 DECLARE_VIRTUAL_TRACE(); |
| 33 | 44 |
| 34 private: | 45 private: |
| 35 explicit PaintTiming(Document&); | 46 explicit PaintTiming(Document&); |
| 36 LocalFrame* frame() const; | 47 LocalFrame* frame() const; |
| 37 void notifyPaintTimingChanged(); | 48 void notifyPaintTimingChanged(); |
| 38 | 49 |
| 39 double m_firstPaint = 0.0; | 50 double m_firstPaint = 0.0; |
| 40 double m_firstTextPaint = 0.0; | 51 double m_firstTextPaint = 0.0; |
| 41 double m_firstImagePaint = 0.0; | 52 double m_firstImagePaint = 0.0; |
| 53 // Speed Index is calculated once when first queried, then cached. |
| 54 mutable double m_speedIndex = 0.0; |
| 55 |
| 56 // Members needed to calculate SpeedIndex: |
| 57 |
| 58 // Ignore all paint invalidations until the load commits. |
| 59 bool m_loadCommitted = false; |
| 60 |
| 61 IntRect m_viewPortRect; |
| 62 int m_lastPaintCount = 0; |
| 63 |
| 64 // Forbids duplicate rect invalidations that occur before painting. |
| 65 WTF::HashSet<unsigned> frameRects; |
| 66 |
| 67 // Counts rect occurrences. |
| 68 typedef WTF::HashMap<unsigned, int> RectCountMap; |
| 69 RectCountMap m_rectCounts; |
| 70 |
| 71 double m_lastPaintInvalidationTime = 0.0; |
| 72 |
| 73 // The current area under the curve of "painted area over time." |
| 74 double m_totalLoadedArea = 0.0; |
| 75 // The total amount of painted area. |
| 76 double m_totalContributions = 0.0; |
| 42 | 77 |
| 43 RawPtrWillBeMember<Document> m_document; | 78 RawPtrWillBeMember<Document> m_document; |
| 44 }; | 79 }; |
| 45 | 80 |
| 46 } | 81 } |
| 47 | 82 |
| 48 #endif | 83 #endif |
| OLD | NEW |