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

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

Issue 2398453002: Rewrap comments to 80 columns in Source/platform/graphics/. (Closed)
Patch Set: Review feedback Created 4 years, 2 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
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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 m_paintController->imagePainted()); 340 m_paintController->imagePainted());
341 } 341 }
342 342
343 void GraphicsLayer::updateChildList() { 343 void GraphicsLayer::updateChildList() {
344 WebLayer* childHost = m_layer->layer(); 344 WebLayer* childHost = m_layer->layer();
345 childHost->removeAllChildren(); 345 childHost->removeAllChildren();
346 346
347 clearContentsLayerIfUnregistered(); 347 clearContentsLayerIfUnregistered();
348 348
349 if (m_contentsLayer) { 349 if (m_contentsLayer) {
350 // FIXME: add the contents layer in the correct order with negative z-order children. 350 // FIXME: Add the contents layer in the correct order with negative z-order
351 // This does not cause visible rendering issues because currently contents l ayers are only used 351 // children. This does not currently cause visible rendering issues because
352 // for replaced elements that don't have children. 352 // contents layers are only used for replaced elements that don't have
353 // children.
353 childHost->addChild(m_contentsLayer); 354 childHost->addChild(m_contentsLayer);
354 } 355 }
355 356
356 for (size_t i = 0; i < m_children.size(); ++i) 357 for (size_t i = 0; i < m_children.size(); ++i)
357 childHost->addChild(m_children[i]->platformLayer()); 358 childHost->addChild(m_children[i]->platformLayer());
358 359
359 for (size_t i = 0; i < m_linkHighlights.size(); ++i) 360 for (size_t i = 0; i < m_linkHighlights.size(); ++i)
360 childHost->addChild(m_linkHighlights[i]->layer()); 361 childHost->addChild(m_linkHighlights[i]->layer());
361 } 362 }
362 363
363 void GraphicsLayer::updateLayerIsDrawable() { 364 void GraphicsLayer::updateLayerIsDrawable() {
364 // For the rest of the accelerated compositor code, there is no reason to make a 365 // For the rest of the accelerated compositor code, there is no reason to make
365 // distinction between drawsContent and contentsVisible. So, for m_layer->laye r(), these two 366 // a distinction between drawsContent and contentsVisible. So, for
366 // flags are combined here. m_contentsLayer shouldn't receive the drawsContent flag 367 // m_layer->layer(), these two flags are combined here. |m_contentsLayer|
367 // so it is only given contentsVisible. 368 // shouldn't receive the drawsContent flag, so it is only given
369 // contentsVisible.
368 370
369 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); 371 m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible);
370 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) 372 if (WebLayer* contentsLayer = contentsLayerIfRegistered())
371 contentsLayer->setDrawsContent(m_contentsVisible); 373 contentsLayer->setDrawsContent(m_contentsVisible);
372 374
373 if (m_drawsContent) { 375 if (m_drawsContent) {
374 m_layer->layer()->invalidate(); 376 m_layer->layer()->invalidate();
375 for (size_t i = 0; i < m_linkHighlights.size(); ++i) 377 for (size_t i = 0; i < m_linkHighlights.size(); ++i)
376 m_linkHighlights[i]->invalidate(); 378 m_linkHighlights[i]->invalidate();
377 } 379 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 445
444 void GraphicsLayer::setupContentsLayer(WebLayer* contentsLayer) { 446 void GraphicsLayer::setupContentsLayer(WebLayer* contentsLayer) {
445 ASSERT(contentsLayer); 447 ASSERT(contentsLayer);
446 m_contentsLayer = contentsLayer; 448 m_contentsLayer = contentsLayer;
447 m_contentsLayerId = m_contentsLayer->id(); 449 m_contentsLayerId = m_contentsLayer->id();
448 450
449 m_contentsLayer->setLayerClient(this); 451 m_contentsLayer->setLayerClient(this);
450 m_contentsLayer->setTransformOrigin(FloatPoint3D()); 452 m_contentsLayer->setTransformOrigin(FloatPoint3D());
451 m_contentsLayer->setUseParentBackfaceVisibility(true); 453 m_contentsLayer->setUseParentBackfaceVisibility(true);
452 454
453 // It is necessary to call setDrawsContent as soon as we receive the new conte ntsLayer, for 455 // It is necessary to call setDrawsContent as soon as we receive the new
454 // the correctness of early exit conditions in setDrawsContent() and setConten tsVisible(). 456 // contentsLayer, for the correctness of early exit conditions in
457 // setDrawsContent() and setContentsVisible().
455 m_contentsLayer->setDrawsContent(m_contentsVisible); 458 m_contentsLayer->setDrawsContent(m_contentsVisible);
456 459
457 // Insert the content layer first. Video elements require this, because they h ave 460 // Insert the content layer first. Video elements require this, because they
458 // shadow content that must display in front of the video. 461 // have shadow content that must display in front of the video.
459 m_layer->layer()->insertChild(m_contentsLayer, 0); 462 m_layer->layer()->insertChild(m_contentsLayer, 0);
460 WebLayer* borderWebLayer = m_contentsClippingMaskLayer 463 WebLayer* borderWebLayer = m_contentsClippingMaskLayer
461 ? m_contentsClippingMaskLayer->platformLayer() 464 ? m_contentsClippingMaskLayer->platformLayer()
462 : 0; 465 : 0;
463 m_contentsLayer->setMaskLayer(borderWebLayer); 466 m_contentsLayer->setMaskLayer(borderWebLayer);
464 467
465 m_contentsLayer->setRenderingContext(m_renderingContext3d); 468 m_contentsLayer->setRenderingContext(m_renderingContext3d);
466 } 469 }
467 470
468 void GraphicsLayer::clearContentsLayerIfUnregistered() { 471 void GraphicsLayer::clearContentsLayerIfUnregistered() {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 if (m_isTrackingRasterInvalidations) { 523 if (m_isTrackingRasterInvalidations) {
521 RasterInvalidationInfo info; 524 RasterInvalidationInfo info;
522 info.client = &client; 525 info.client = &client;
523 info.clientDebugName = client.debugName(); 526 info.clientDebugName = client.debugName();
524 info.rect = rect; 527 info.rect = rect;
525 info.reason = reason; 528 info.reason = reason;
526 tracking.trackedRasterInvalidations.append(info); 529 tracking.trackedRasterInvalidations.append(info);
527 } 530 }
528 531
529 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) { 532 if (RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled()) {
530 // TODO(crbug.com/496260): Some antialiasing effects overflows the paint inv alidation rect. 533 // TODO(crbug.com/496260): Some antialiasing effects overflow the paint
534 // invalidation rect.
531 IntRect r = rect; 535 IntRect r = rect;
532 r.inflate(1); 536 r.inflate(1);
533 tracking.rasterInvalidationRegionSinceLastPaint.unite(r); 537 tracking.rasterInvalidationRegionSinceLastPaint.unite(r);
534 } 538 }
535 } 539 }
536 540
537 template <typename T> 541 template <typename T>
538 static std::unique_ptr<JSONArray> pointAsJSONArray(const T& point) { 542 static std::unique_ptr<JSONArray> pointAsJSONArray(const T& point) {
539 std::unique_ptr<JSONArray> array = JSONArray::create(); 543 std::unique_ptr<JSONArray> array = JSONArray::create();
540 array->pushDouble(point.x()); 544 array->pushDouble(point.x());
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 void GraphicsLayer::setOwnerNodeId(int nodeId) { 814 void GraphicsLayer::setOwnerNodeId(int nodeId) {
811 m_debugInfo.setOwnerNodeId(nodeId); 815 m_debugInfo.setOwnerNodeId(nodeId);
812 } 816 }
813 817
814 void GraphicsLayer::setPosition(const FloatPoint& point) { 818 void GraphicsLayer::setPosition(const FloatPoint& point) {
815 m_position = point; 819 m_position = point;
816 platformLayer()->setPosition(m_position); 820 platformLayer()->setPosition(m_position);
817 } 821 }
818 822
819 void GraphicsLayer::setSize(const FloatSize& size) { 823 void GraphicsLayer::setSize(const FloatSize& size) {
820 // We are receiving negative sizes here that cause assertions to fail in the c ompositor. Clamp them to 0 to 824 // We are receiving negative sizes here that cause assertions to fail in the
821 // avoid those assertions. 825 // compositor. Clamp them to 0 to avoid those assertions.
822 // FIXME: This should be an ASSERT instead, as negative sizes should not exist in WebCore. 826 // FIXME: This should be an ASSERT instead, as negative sizes should not exist
827 // in WebCore.
823 FloatSize clampedSize = size; 828 FloatSize clampedSize = size;
824 if (clampedSize.width() < 0 || clampedSize.height() < 0) 829 if (clampedSize.width() < 0 || clampedSize.height() < 0)
825 clampedSize = FloatSize(); 830 clampedSize = FloatSize();
826 831
827 if (clampedSize == m_size) 832 if (clampedSize == m_size)
828 return; 833 return;
829 834
830 m_size = clampedSize; 835 m_size = clampedSize;
831 836
832 m_layer->layer()->setBounds(flooredIntSize(m_size)); 837 m_layer->layer()->setBounds(flooredIntSize(m_size));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 872
868 bool GraphicsLayer::masksToBounds() const { 873 bool GraphicsLayer::masksToBounds() const {
869 return m_layer->layer()->masksToBounds(); 874 return m_layer->layer()->masksToBounds();
870 } 875 }
871 876
872 void GraphicsLayer::setMasksToBounds(bool masksToBounds) { 877 void GraphicsLayer::setMasksToBounds(bool masksToBounds) {
873 m_layer->layer()->setMasksToBounds(masksToBounds); 878 m_layer->layer()->setMasksToBounds(masksToBounds);
874 } 879 }
875 880
876 void GraphicsLayer::setDrawsContent(bool drawsContent) { 881 void GraphicsLayer::setDrawsContent(bool drawsContent) {
877 // Note carefully this early-exit is only correct because we also properly cal l 882 // NOTE: This early-exit is only correct because we also properly call
878 // WebLayer::setDrawsContent whenever m_contentsLayer is set to a new layer in setupContentsLayer(). 883 // WebLayer::setDrawsContent() whenever |m_contentsLayer| is set to a new
884 // layer in setupContentsLayer().
879 if (drawsContent == m_drawsContent) 885 if (drawsContent == m_drawsContent)
880 return; 886 return;
881 887
882 m_drawsContent = drawsContent; 888 m_drawsContent = drawsContent;
883 updateLayerIsDrawable(); 889 updateLayerIsDrawable();
884 890
885 if (!drawsContent && m_paintController) 891 if (!drawsContent && m_paintController)
886 m_paintController.reset(); 892 m_paintController.reset();
887 } 893 }
888 894
889 void GraphicsLayer::setContentsVisible(bool contentsVisible) { 895 void GraphicsLayer::setContentsVisible(bool contentsVisible) {
890 // Note carefully this early-exit is only correct because we also properly cal l 896 // NOTE: This early-exit is only correct because we also properly call
891 // WebLayer::setDrawsContent whenever m_contentsLayer is set to a new layer in setupContentsLayer(). 897 // WebLayer::setDrawsContent() whenever |m_contentsLayer| is set to a new
898 // layer in setupContentsLayer().
892 if (contentsVisible == m_contentsVisible) 899 if (contentsVisible == m_contentsVisible)
893 return; 900 return;
894 901
895 m_contentsVisible = contentsVisible; 902 m_contentsVisible = contentsVisible;
896 updateLayerIsDrawable(); 903 updateLayerIsDrawable();
897 } 904 }
898 905
899 void GraphicsLayer::setClipParent(WebLayer* parent) { 906 void GraphicsLayer::setClipParent(WebLayer* parent) {
900 m_hasClipParent = !!parent; 907 m_hasClipParent = !!parent;
901 m_layer->layer()->setClipParent(parent); 908 m_layer->layer()->setClipParent(parent);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) { 983 if (WebLayer* contentsLayer = contentsLayerIfRegistered()) {
977 contentsLayer->invalidate(); 984 contentsLayer->invalidate();
978 trackRasterInvalidation(*this, m_contentsRect, PaintInvalidationFull); 985 trackRasterInvalidation(*this, m_contentsRect, PaintInvalidationFull);
979 } 986 }
980 } 987 }
981 988
982 void GraphicsLayer::setNeedsDisplay() { 989 void GraphicsLayer::setNeedsDisplay() {
983 if (!drawsContent()) 990 if (!drawsContent())
984 return; 991 return;
985 992
986 // TODO(chrishtr): stop invalidating the rects once FrameView::paintRecursivel y does so. 993 // TODO(chrishtr): Stop invalidating the rects once
994 // FrameView::paintRecursively() does so.
987 m_layer->layer()->invalidate(); 995 m_layer->layer()->invalidate();
988 for (size_t i = 0; i < m_linkHighlights.size(); ++i) 996 for (size_t i = 0; i < m_linkHighlights.size(); ++i)
989 m_linkHighlights[i]->invalidate(); 997 m_linkHighlights[i]->invalidate();
990 getPaintController().invalidateAll(); 998 getPaintController().invalidateAll();
991 999
992 trackRasterInvalidation(*this, IntRect(IntPoint(), expandedIntSize(m_size)), 1000 trackRasterInvalidation(*this, IntRect(IntPoint(), expandedIntSize(m_size)),
993 PaintInvalidationFull); 1001 PaintInvalidationFull);
994 } 1002 }
995 1003
996 void GraphicsLayer::setNeedsDisplayInRect( 1004 void GraphicsLayer::setNeedsDisplayInRect(
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 else 1114 else
1107 m_layer->layer()->setScrollClient(this); 1115 m_layer->layer()->setScrollClient(this);
1108 } 1116 }
1109 1117
1110 void GraphicsLayer::didScroll() { 1118 void GraphicsLayer::didScroll() {
1111 if (m_scrollableArea) { 1119 if (m_scrollableArea) {
1112 DoublePoint newPosition = 1120 DoublePoint newPosition =
1113 -m_scrollableArea->scrollOrigin() + 1121 -m_scrollableArea->scrollOrigin() +
1114 toDoubleSize(m_layer->layer()->scrollPositionDouble()); 1122 toDoubleSize(m_layer->layer()->scrollPositionDouble());
1115 1123
1116 // FrameView::setScrollPosition doesn't work for compositor commits (interac ts poorly with programmatic scroll animations) 1124 // FrameView::setScrollPosition() doesn't work for compositor commits
1117 // so we need to use the ScrollableArea version. The FrameView method should go away soon anyway. 1125 // (interacts poorly with programmatic scroll animations) so we need to use
1126 // the ScrollableArea version. The FrameView method should go away soon
1127 // anyway.
1118 m_scrollableArea->ScrollableArea::setScrollPosition(newPosition, 1128 m_scrollableArea->ScrollableArea::setScrollPosition(newPosition,
1119 CompositorScroll); 1129 CompositorScroll);
1120 } 1130 }
1121 } 1131 }
1122 1132
1123 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 1133 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
1124 GraphicsLayer::TakeDebugInfo(cc::Layer* layer) { 1134 GraphicsLayer::TakeDebugInfo(cc::Layer* layer) {
1125 std::unique_ptr<base::trace_event::TracedValue> tracedValue( 1135 std::unique_ptr<base::trace_event::TracedValue> tracedValue(
1126 m_debugInfo.asTracedValue()); 1136 m_debugInfo.asTracedValue());
1127 tracedValue->SetString( 1137 tracedValue->SetString(
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 *newBitmap.getAddr32(bitmapX, bitmapY) = 1251 *newBitmap.getAddr32(bitmapX, bitmapY) =
1242 SkColorSetARGB(0xFF, 0xA0, 0, 0); // Dark red. 1252 SkColorSetARGB(0xFF, 0xA0, 0, 0); // Dark red.
1243 } else { 1253 } else {
1244 *newBitmap.getAddr32(bitmapX, bitmapY) = SK_ColorTRANSPARENT; 1254 *newBitmap.getAddr32(bitmapX, bitmapY) = SK_ColorTRANSPARENT;
1245 } 1255 }
1246 } 1256 }
1247 } 1257 }
1248 oldBitmap.unlockPixels(); 1258 oldBitmap.unlockPixels();
1249 newBitmap.unlockPixels(); 1259 newBitmap.unlockPixels();
1250 1260
1251 // Visualize under-invalidations by overlaying the new bitmap (containing red pixels indicating under-invalidations, 1261 // Visualize under-invalidations by overlaying the new bitmap (containing red
1252 // and transparent pixels otherwise) onto the painting. 1262 // pixels indicating under-invalidations, and transparent pixels otherwise)
1263 // onto the painting.
1253 SkPictureRecorder recorder; 1264 SkPictureRecorder recorder;
1254 recorder.beginRecording(rect); 1265 recorder.beginRecording(rect);
1255 recorder.getRecordingCanvas()->drawBitmap(newBitmap, rect.x(), rect.y()); 1266 recorder.getRecordingCanvas()->drawBitmap(newBitmap, rect.x(), rect.y());
1256 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture(); 1267 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
1257 getPaintController().appendDebugDrawingAfterCommit( 1268 getPaintController().appendDebugDrawingAfterCommit(
1258 *this, picture, offsetFromLayoutObjectWithSubpixelAccumulation()); 1269 *this, picture, offsetFromLayoutObjectWithSubpixelAccumulation());
1259 } 1270 }
1260 1271
1261 } // namespace blink 1272 } // namespace blink
1262 1273
1263 #ifndef NDEBUG 1274 #ifndef NDEBUG
1264 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { 1275 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) {
1265 if (!layer) { 1276 if (!layer) {
1266 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n"); 1277 fprintf(stderr, "Cannot showGraphicsLayerTree for (nil).\n");
1267 return; 1278 return;
1268 } 1279 }
1269 1280
1270 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo); 1281 String output = layer->layerTreeAsText(blink::LayerTreeIncludesDebugInfo);
1271 fprintf(stderr, "%s\n", output.utf8().data()); 1282 fprintf(stderr, "%s\n", output.utf8().data());
1272 } 1283 }
1273 #endif 1284 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698