| Index: third_party/WebKit/Source/platform/graphics/paint/PaintInvalidationTracking.h
|
| diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintInvalidationTracking.h b/third_party/WebKit/Source/platform/graphics/paint/PaintInvalidationTracking.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b5a8545299386387924088de20dcc7df9c27164a
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/platform/graphics/paint/PaintInvalidationTracking.h
|
| @@ -0,0 +1,92 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef PaintInvalidationTracking_h
|
| +#define PaintInvalidationTracking_h
|
| +
|
| +#include "platform/geometry/IntRect.h"
|
| +#include "platform/geometry/Region.h"
|
| +#include "platform/graphics/PaintInvalidationReason.h"
|
| +#include "platform/json/JSONValues.h"
|
| +#include "third_party/skia/include/core/SkColor.h"
|
| +#include "third_party/skia/include/core/SkPicture.h"
|
| +#include "wtf/Allocator.h"
|
| +#include "wtf/text/WTFString.h"
|
| +
|
| +namespace blink {
|
| +
|
| +class DisplayItemClient;
|
| +
|
| +struct PaintInvalidationInfo {
|
| + DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
|
| + // This is for comparison only. Don't dereference because the client may have died.
|
| + const DisplayItemClient* client;
|
| + String clientDebugName;
|
| + IntRect rect;
|
| + PaintInvalidationReason reason;
|
| + PaintInvalidationInfo() : reason(PaintInvalidationFull) {}
|
| +};
|
| +
|
| +inline bool operator==(const PaintInvalidationInfo& a, const PaintInvalidationInfo& b)
|
| +{
|
| + return a.rect == b.rect;
|
| +}
|
| +
|
| +struct UnderPaintInvalidation {
|
| + DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
|
| + int x;
|
| + int y;
|
| + SkColor oldPixel;
|
| + SkColor newPixel;
|
| +};
|
| +
|
| +struct PaintInvalidationTracking {
|
| + DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
|
| + Vector<PaintInvalidationInfo> trackedPaintInvalidations;
|
| + sk_sp<SkPicture> lastPaintedPicture;
|
| + IntRect lastInterestRect;
|
| + Region paintInvalidationRegionSinceLastPaint;
|
| + Vector<UnderPaintInvalidation> underPaintInvalidations;
|
| +
|
| + void asJSON(JSONObject*);
|
| +};
|
| +
|
| +template <class TargetClass>
|
| +class PaintInvalidationTrackingMap {
|
| +public:
|
| + void asJSON(TargetClass* key, JSONObject* json)
|
| + {
|
| + auto it = m_invalidationTrackingMap.find(key);
|
| + if (it != m_invalidationTrackingMap.end())
|
| + it->value.asJSON(json);
|
| + }
|
| +
|
| + void remove(TargetClass* key)
|
| + {
|
| + auto it = m_invalidationTrackingMap.find(key);
|
| + if (it != m_invalidationTrackingMap.end())
|
| + m_invalidationTrackingMap.remove(it);
|
| + }
|
| +
|
| + PaintInvalidationTracking& add(TargetClass* key)
|
| + {
|
| + return m_invalidationTrackingMap.add(key, PaintInvalidationTracking()).storedValue->value;
|
| + }
|
| +
|
| + PaintInvalidationTracking* find(TargetClass* key)
|
| + {
|
| + auto it = m_invalidationTrackingMap.find(key);
|
| + if (it == m_invalidationTrackingMap.end())
|
| + return nullptr;
|
| + return &it->value;
|
| + }
|
| +
|
| +private:
|
| + typedef HashMap<TargetClass*, PaintInvalidationTracking> InvalidationTrackingMap;
|
| + InvalidationTrackingMap m_invalidationTrackingMap;
|
| +};
|
| +
|
| +} // namespace blink
|
| +
|
| +#endif // PaintInvalidationTracking_h
|
|
|