Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: Source/platform/graphics/GraphicsLayer.cpp

Issue 1329553004: Add a FOUC painting test. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix build. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "wtf/HashSet.h" 57 #include "wtf/HashSet.h"
58 #include "wtf/text/WTFString.h" 58 #include "wtf/text/WTFString.h"
59 #include <algorithm> 59 #include <algorithm>
60 60
61 #ifndef NDEBUG 61 #ifndef NDEBUG
62 #include <stdio.h> 62 #include <stdio.h>
63 #endif 63 #endif
64 64
65 namespace blink { 65 namespace blink {
66 66
67 static bool s_drawDebugRedFill = true;
68
67 // TODO(wangxianzhu): Remove this when we no longer invalidate rects. 69 // TODO(wangxianzhu): Remove this when we no longer invalidate rects.
68 struct PaintInvalidationTrackingInfo { 70 struct PaintInvalidationTrackingInfo {
69 Vector<FloatRect> invalidationRects; 71 Vector<FloatRect> invalidationRects;
70 Vector<String> invalidationObjects; 72 Vector<String> invalidationObjects;
71 }; 73 };
72 74
73 typedef HashMap<const GraphicsLayer*, PaintInvalidationTrackingInfo> PaintInvali dationTrackingMap; 75 typedef HashMap<const GraphicsLayer*, PaintInvalidationTrackingInfo> PaintInvali dationTrackingMap;
74 static PaintInvalidationTrackingMap& paintInvalidationTrackingMap() 76 static PaintInvalidationTrackingMap& paintInvalidationTrackingMap()
75 { 77 {
76 DEFINE_STATIC_LOCAL(PaintInvalidationTrackingMap, map, ()); 78 DEFINE_STATIC_LOCAL(PaintInvalidationTrackingMap, map, ());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if (m_replicatedLayer) 144 if (m_replicatedLayer)
143 m_replicatedLayer->setReplicatedByLayer(0); 145 m_replicatedLayer->setReplicatedByLayer(0);
144 146
145 removeAllChildren(); 147 removeAllChildren();
146 removeFromParent(); 148 removeFromParent();
147 149
148 resetTrackedPaintInvalidations(); 150 resetTrackedPaintInvalidations();
149 ASSERT(!m_parent); 151 ASSERT(!m_parent);
150 } 152 }
151 153
154 void GraphicsLayer::setDrawDebugRedFillForTesting(bool enabled)
155 {
156 s_drawDebugRedFill = enabled;
157 }
158
152 void GraphicsLayer::setParent(GraphicsLayer* layer) 159 void GraphicsLayer::setParent(GraphicsLayer* layer)
153 { 160 {
154 ASSERT(!layer || !layer->hasAncestor(this)); 161 ASSERT(!layer || !layer->hasAncestor(this));
155 m_parent = layer; 162 m_parent = layer;
156 } 163 }
157 164
158 #if ENABLE(ASSERT) 165 #if ENABLE(ASSERT)
159 166
160 bool GraphicsLayer::hasAncestor(GraphicsLayer* ancestor) const 167 bool GraphicsLayer::hasAncestor(GraphicsLayer* ancestor) const
161 { 168 {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 290 }
284 291
285 void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const I ntRect& clip) 292 void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const I ntRect& clip)
286 { 293 {
287 if (!m_client) 294 if (!m_client)
288 return; 295 return;
289 if (firstPaintInvalidationTrackingEnabled()) 296 if (firstPaintInvalidationTrackingEnabled())
290 m_debugInfo.clearAnnotatedInvalidateRects(); 297 m_debugInfo.clearAnnotatedInvalidateRects();
291 incrementPaintCount(); 298 incrementPaintCount();
292 #ifndef NDEBUG 299 #ifndef NDEBUG
293 if (m_displayItemList && contentsOpaque()) { 300 if (m_displayItemList && contentsOpaque() && s_drawDebugRedFill) {
294 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); 301 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
295 FloatRect rect(FloatPoint(), size()); 302 FloatRect rect(FloatPoint(), size());
296 if (!DrawingRecorder::useCachedDrawingIfPossible(context, *this, Display Item::DebugRedFill)) { 303 if (!DrawingRecorder::useCachedDrawingIfPossible(context, *this, Display Item::DebugRedFill)) {
297 DrawingRecorder recorder(context, *this, DisplayItem::DebugRedFill, rect); 304 DrawingRecorder recorder(context, *this, DisplayItem::DebugRedFill, rect);
298 context.fillRect(rect, SK_ColorRED); 305 context.fillRect(rect, SK_ColorRED);
299 } 306 }
300 } 307 }
301 #endif 308 #endif
302 m_client->paintContents(this, context, m_paintingPhase, clip); 309 m_client->paintContents(this, context, m_paintingPhase, clip);
303 } 310 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 { 460 {
454 clearContentsLayerIfUnregistered(); 461 clearContentsLayerIfUnregistered();
455 return m_contentsLayer; 462 return m_contentsLayer;
456 } 463 }
457 464
458 void GraphicsLayer::resetTrackedPaintInvalidations() 465 void GraphicsLayer::resetTrackedPaintInvalidations()
459 { 466 {
460 paintInvalidationTrackingMap().remove(this); 467 paintInvalidationTrackingMap().remove(this);
461 } 468 }
462 469
470 bool GraphicsLayer::hasTrackedPaintInvalidations() const
471 {
472 PaintInvalidationTrackingMap::iterator it = paintInvalidationTrackingMap().f ind(this);
473 if (it != paintInvalidationTrackingMap().end())
474 return !it->value.invalidationRects.isEmpty();
475 return false;
476 }
477
463 void GraphicsLayer::trackPaintInvalidationRect(const FloatRect& rect) 478 void GraphicsLayer::trackPaintInvalidationRect(const FloatRect& rect)
464 { 479 {
465 if (rect.isEmpty()) 480 if (rect.isEmpty())
466 return; 481 return;
467 482
468 // The caller must check isTrackingPaintInvalidations() before calling this method 483 // The caller must check isTrackingPaintInvalidations() before calling this method
469 // to avoid constructing the rect unnecessarily. 484 // to avoid constructing the rect unnecessarily.
470 ASSERT(isTrackingPaintInvalidations()); 485 ASSERT(isTrackingPaintInvalidations());
471 486
472 paintInvalidationTrackingMap().add(this, PaintInvalidationTrackingInfo()).st oredValue->value.invalidationRects.append(rect); 487 paintInvalidationTrackingMap().add(this, PaintInvalidationTrackingInfo()).st oredValue->value.invalidationRects.append(rect);
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 { 1171 {
1157 if (!layer) { 1172 if (!layer) {
1158 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); 1173 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n");
1159 return; 1174 return;
1160 } 1175 }
1161 1176
1162 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); 1177 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo);
1163 fprintf(stderr, "%s\n", output.utf8().data()); 1178 fprintf(stderr, "%s\n", output.utf8().data());
1164 } 1179 }
1165 #endif 1180 #endif
OLDNEW
« no previous file with comments | « Source/platform/graphics/GraphicsLayer.h ('k') | Source/web/tests/DocumentLoadingRenderingTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698