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

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

Issue 311273008: Remove anchorPoint from WebLayer and GraphicsLayer. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return map; 72 return map;
73 } 73 }
74 74
75 PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, G raphicsLayerClient* client) 75 PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, G raphicsLayerClient* client)
76 { 76 {
77 return factory->createGraphicsLayer(client); 77 return factory->createGraphicsLayer(client);
78 } 78 }
79 79
80 GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client) 80 GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client)
81 : m_client(client) 81 : m_client(client)
82 , m_anchorPoint(0.5f, 0.5f, 0) 82 , m_transformOriginSet(false)
83 , m_backgroundColor(Color::transparent) 83 , m_backgroundColor(Color::transparent)
84 , m_opacity(1) 84 , m_opacity(1)
85 , m_zPosition(0) 85 , m_zPosition(0)
86 , m_blendMode(blink::WebBlendModeNormal) 86 , m_blendMode(blink::WebBlendModeNormal)
87 , m_contentsOpaque(false) 87 , m_contentsOpaque(false)
88 , m_shouldFlattenTransform(true) 88 , m_shouldFlattenTransform(true)
89 , m_backfaceVisibility(true) 89 , m_backfaceVisibility(true)
90 , m_masksToBounds(false) 90 , m_masksToBounds(false)
91 , m_drawsContent(false) 91 , m_drawsContent(false)
92 , m_contentsVisible(true) 92 , m_contentsVisible(true)
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 } 443 }
444 444
445 void GraphicsLayer::setupContentsLayer(WebLayer* contentsLayer) 445 void GraphicsLayer::setupContentsLayer(WebLayer* contentsLayer)
446 { 446 {
447 ASSERT(contentsLayer); 447 ASSERT(contentsLayer);
448 m_contentsLayer = contentsLayer; 448 m_contentsLayer = contentsLayer;
449 m_contentsLayerId = m_contentsLayer->id(); 449 m_contentsLayerId = m_contentsLayer->id();
450 450
451 m_contentsLayer->setWebLayerClient(this); 451 m_contentsLayer->setWebLayerClient(this);
452 m_contentsLayer->setTransformOrigin(FloatPoint3D()); 452 m_contentsLayer->setTransformOrigin(FloatPoint3D());
453 m_contentsLayer->setAnchorPoint(FloatPoint(0, 0));
454 m_contentsLayer->setUseParentBackfaceVisibility(true); 453 m_contentsLayer->setUseParentBackfaceVisibility(true);
455 454
456 // It is necessary to call setDrawsContent as soon as we receive the new con tentsLayer, for 455 // It is necessary to call setDrawsContent as soon as we receive the new con tentsLayer, for
457 // the correctness of early exit conditions in setDrawsContent() and setCont entsVisible(). 456 // the correctness of early exit conditions in setDrawsContent() and setCont entsVisible().
458 m_contentsLayer->setDrawsContent(m_contentsVisible); 457 m_contentsLayer->setDrawsContent(m_contentsVisible);
459 458
460 // Insert the content layer first. Video elements require this, because they have 459 // Insert the content layer first. Video elements require this, because they have
461 // shadow content that must display in front of the video. 460 // shadow content that must display in front of the video.
462 m_layer->layer()->insertChild(m_contentsLayer, 0); 461 m_layer->layer()->insertChild(m_contentsLayer, 0);
463 WebLayer* borderWebLayer = m_contentsClippingMaskLayer ? m_contentsClippingM askLayer->platformLayer() : 0; 462 WebLayer* borderWebLayer = m_contentsClippingMaskLayer ? m_contentsClippingM askLayer->platformLayer() : 0;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 if (m_position != FloatPoint()) { 556 if (m_position != FloatPoint()) {
558 writeIndent(ts, indent + 1); 557 writeIndent(ts, indent + 1);
559 ts << "(position " << m_position.x() << " " << m_position.y() << ")\n"; 558 ts << "(position " << m_position.x() << " " << m_position.y() << ")\n";
560 } 559 }
561 560
562 if (m_boundsOrigin != FloatPoint()) { 561 if (m_boundsOrigin != FloatPoint()) {
563 writeIndent(ts, indent + 1); 562 writeIndent(ts, indent + 1);
564 ts << "(bounds origin " << m_boundsOrigin.x() << " " << m_boundsOrigin.y () << ")\n"; 563 ts << "(bounds origin " << m_boundsOrigin.x() << " " << m_boundsOrigin.y () << ")\n";
565 } 564 }
566 565
567 if (m_anchorPoint != FloatPoint3D(0.5f, 0.5f, 0)) { 566 if (m_transformOriginSet && m_transformOrigin != FloatPoint3D(m_size.width() * 0.5f, m_size.height() * 0.5f, 0)) {
ojan 2014/06/05 21:53:31 Bikeshed: This soudns like a set of transformOrigi
chrishtr 2014/06/05 22:24:24 Done.
568 writeIndent(ts, indent + 1);
569 ts << "(anchor " << m_anchorPoint.x() << " " << m_anchorPoint.y() << ")\ n";
570 writeIndent(ts, indent + 1); 567 writeIndent(ts, indent + 1);
571 ts << "(transformOrigin " << m_transformOrigin.x() << " " << m_transform Origin.y() << ")\n"; 568 ts << "(transformOrigin " << m_transformOrigin.x() << " " << m_transform Origin.y() << ")\n";
572 } 569 }
573 570
574 if (m_size != IntSize()) { 571 if (m_size != IntSize()) {
575 writeIndent(ts, indent + 1); 572 writeIndent(ts, indent + 1);
576 ts << "(bounds " << m_size.width() << " " << m_size.height() << ")\n"; 573 ts << "(bounds " << m_size.width() << " " << m_size.height() << ")\n";
577 } 574 }
578 575
579 if (m_opacity != 1) { 576 if (m_opacity != 1) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 { 797 {
801 m_debugInfo.setOwnerNodeId(nodeId); 798 m_debugInfo.setOwnerNodeId(nodeId);
802 } 799 }
803 800
804 void GraphicsLayer::setPosition(const FloatPoint& point) 801 void GraphicsLayer::setPosition(const FloatPoint& point)
805 { 802 {
806 m_position = point; 803 m_position = point;
807 platformLayer()->setPosition(m_position); 804 platformLayer()->setPosition(m_position);
808 } 805 }
809 806
810 void GraphicsLayer::setAnchorPoint(const FloatPoint3D& point)
811 {
812 m_anchorPoint = point;
813 platformLayer()->setAnchorPoint(FloatPoint(m_anchorPoint.x(), m_anchorPoint. y()));
814 platformLayer()->setAnchorPointZ(m_anchorPoint.z());
815 }
816
817 void GraphicsLayer::setSize(const FloatSize& size) 807 void GraphicsLayer::setSize(const FloatSize& size)
818 { 808 {
819 // We are receiving negative sizes here that cause assertions to fail in the compositor. Clamp them to 0 to 809 // We are receiving negative sizes here that cause assertions to fail in the compositor. Clamp them to 0 to
820 // avoid those assertions. 810 // avoid those assertions.
821 // FIXME: This should be an ASSERT instead, as negative sizes should not exi st in WebCore. 811 // FIXME: This should be an ASSERT instead, as negative sizes should not exi st in WebCore.
822 FloatSize clampedSize = size; 812 FloatSize clampedSize = size;
823 if (clampedSize.width() < 0 || clampedSize.height() < 0) 813 if (clampedSize.width() < 0 || clampedSize.height() < 0)
824 clampedSize = FloatSize(); 814 clampedSize = FloatSize();
825 815
826 if (clampedSize == m_size) 816 if (clampedSize == m_size)
827 return; 817 return;
828 818
829 m_size = clampedSize; 819 m_size = clampedSize;
830 820
831 m_layer->layer()->setBounds(flooredIntSize(m_size)); 821 m_layer->layer()->setBounds(flooredIntSize(m_size));
832 // Note that we don't resize m_contentsLayer. It's up the caller to do that. 822 // Note that we don't resize m_contentsLayer. It's up the caller to do that.
833 } 823 }
834 824
835 void GraphicsLayer::setTransform(const TransformationMatrix& transform) 825 void GraphicsLayer::setTransform(const TransformationMatrix& transform)
836 { 826 {
837 m_transform = transform; 827 m_transform = transform;
838 platformLayer()->setTransform(TransformationMatrix::toSkMatrix44(m_transform )); 828 platformLayer()->setTransform(TransformationMatrix::toSkMatrix44(m_transform ));
839 } 829 }
840 830
841 void GraphicsLayer::setTransformOrigin(const FloatPoint3D& transformOrigin) 831 void GraphicsLayer::setTransformOrigin(const FloatPoint3D& transformOrigin)
842 { 832 {
833 m_transformOriginSet = true;
843 m_transformOrigin = transformOrigin; 834 m_transformOrigin = transformOrigin;
844 platformLayer()->setTransformOrigin(transformOrigin); 835 platformLayer()->setTransformOrigin(transformOrigin);
845 } 836 }
846 837
847 void GraphicsLayer::setShouldFlattenTransform(bool shouldFlatten) 838 void GraphicsLayer::setShouldFlattenTransform(bool shouldFlatten)
848 { 839 {
849 if (shouldFlatten == m_shouldFlattenTransform) 840 if (shouldFlatten == m_shouldFlattenTransform)
850 return; 841 return;
851 842
852 m_shouldFlattenTransform = shouldFlatten; 843 m_shouldFlattenTransform = shouldFlatten;
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 #ifndef NDEBUG 1231 #ifndef NDEBUG
1241 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer) 1232 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer)
1242 { 1233 {
1243 if (!layer) 1234 if (!layer)
1244 return; 1235 return;
1245 1236
1246 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo); 1237 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo);
1247 fprintf(stderr, "%s\n", output.utf8().data()); 1238 fprintf(stderr, "%s\n", output.utf8().data());
1248 } 1239 }
1249 #endif 1240 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698