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

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

Issue 23431021: Refactoring animation code in accelerated path. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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
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 17 matching lines...) Expand all
28 #include "core/platform/graphics/GraphicsLayer.h" 28 #include "core/platform/graphics/GraphicsLayer.h"
29 29
30 #include "SkImageFilter.h" 30 #include "SkImageFilter.h"
31 #include "SkMatrix44.h" 31 #include "SkMatrix44.h"
32 #include "core/platform/ScrollableArea.h" 32 #include "core/platform/ScrollableArea.h"
33 #include "core/platform/graphics/FloatPoint.h" 33 #include "core/platform/graphics/FloatPoint.h"
34 #include "core/platform/graphics/FloatRect.h" 34 #include "core/platform/graphics/FloatRect.h"
35 #include "core/platform/graphics/GraphicsContext.h" 35 #include "core/platform/graphics/GraphicsContext.h"
36 #include "core/platform/graphics/GraphicsLayerFactory.h" 36 #include "core/platform/graphics/GraphicsLayerFactory.h"
37 #include "core/platform/graphics/LayoutRect.h" 37 #include "core/platform/graphics/LayoutRect.h"
38 #include "core/platform/graphics/chromium/AnimationTranslationUtil.h"
39 #include "core/platform/graphics/chromium/TransformSkMatrix44Conversions.h" 38 #include "core/platform/graphics/chromium/TransformSkMatrix44Conversions.h"
40 #include "core/platform/graphics/filters/SkiaImageFilterBuilder.h" 39 #include "core/platform/graphics/filters/SkiaImageFilterBuilder.h"
41 #include "core/platform/graphics/skia/NativeImageSkia.h" 40 #include "core/platform/graphics/skia/NativeImageSkia.h"
42 #include "core/platform/text/TextStream.h" 41 #include "core/platform/text/TextStream.h"
43 42
44 #include "wtf/CurrentTime.h" 43 #include "wtf/CurrentTime.h"
45 #include "wtf/HashMap.h" 44 #include "wtf/HashMap.h"
46 #include "wtf/HashSet.h" 45 #include "wtf/HashSet.h"
47 #include "wtf/text/CString.h"
48 #include "wtf/text/StringBuilder.h"
49 #include "wtf/text/StringHash.h"
50 #include "wtf/text/WTFString.h" 46 #include "wtf/text/WTFString.h"
51 47
52 #include "public/platform/Platform.h" 48 #include "public/platform/Platform.h"
53 #include "public/platform/WebAnimation.h" 49 #include "public/platform/WebAnimation.h"
54 #include "public/platform/WebCompositorSupport.h" 50 #include "public/platform/WebCompositorSupport.h"
55 #include "public/platform/WebFilterOperations.h" 51 #include "public/platform/WebFilterOperations.h"
56 #include "public/platform/WebFloatPoint.h" 52 #include "public/platform/WebFloatPoint.h"
57 #include "public/platform/WebFloatRect.h" 53 #include "public/platform/WebFloatRect.h"
58 #include "public/platform/WebLayer.h" 54 #include "public/platform/WebLayer.h"
59 #include "public/platform/WebPoint.h" 55 #include "public/platform/WebPoint.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } 332 }
337 333
338 void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const I ntRect& clip) 334 void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const I ntRect& clip)
339 { 335 {
340 if (!m_client) 336 if (!m_client)
341 return; 337 return;
342 incrementPaintCount(); 338 incrementPaintCount();
343 m_client->paintContents(this, context, m_paintingPhase, clip); 339 m_client->paintContents(this, context, m_paintingPhase, clip);
344 } 340 }
345 341
346 String GraphicsLayer::animationNameForTransition(AnimatedPropertyID property)
347 {
348 // | is not a valid identifier character in CSS, so this can never conflict with a keyframe identifier.
349 StringBuilder id;
350 id.appendLiteral("-|transition");
351 id.appendNumber(static_cast<int>(property));
352 id.append('-');
353 return id.toString();
354 }
355
356 void GraphicsLayer::setZPosition(float position) 342 void GraphicsLayer::setZPosition(float position)
357 { 343 {
358 m_zPosition = position; 344 m_zPosition = position;
359 } 345 }
360 346
361 float GraphicsLayer::accumulatedOpacity() const 347 float GraphicsLayer::accumulatedOpacity() const
362 { 348 {
363 if (!preserves3D()) 349 if (!preserves3D())
364 return 1; 350 return 1;
365 351
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 void GraphicsLayer::setContentsToCanvas(WebLayer* layer) 956 void GraphicsLayer::setContentsToCanvas(WebLayer* layer)
971 { 957 {
972 setContentsTo(ContentsLayerForCanvas, layer); 958 setContentsTo(ContentsLayerForCanvas, layer);
973 } 959 }
974 960
975 void GraphicsLayer::setContentsToMedia(WebLayer* layer) 961 void GraphicsLayer::setContentsToMedia(WebLayer* layer)
976 { 962 {
977 setContentsTo(ContentsLayerForVideo, layer); 963 setContentsTo(ContentsLayerForVideo, layer);
978 } 964 }
979 965
980 bool GraphicsLayer::addAnimation(const KeyframeValueList& values, const IntSize& boxSize, const CSSAnimationData* animation, const String& animationName, double timeOffset) 966 bool GraphicsLayer::addAnimation(WebAnimation* animation)
981 { 967 {
968 ASSERT(animation);
982 platformLayer()->setAnimationDelegate(this); 969 platformLayer()->setAnimationDelegate(this);
983 970
984 int animationId = 0; 971 // Remove any existing animations with the same animation id and target prop erty.
985 972 platformLayer()->removeAnimation(animation->id(), animation->targetProperty( ));
986 if (m_animationIdMap.contains(animationName)) 973 return platformLayer()->addAnimation(animation);
987 animationId = m_animationIdMap.get(animationName);
988
989 OwnPtr<WebAnimation> toAdd(createWebAnimation(values, animation, animationId , timeOffset, boxSize));
990
991 if (toAdd) {
992 animationId = toAdd->id();
993 m_animationIdMap.set(animationName, animationId);
994
995 // Remove any existing animations with the same animation id and target property.
996 platformLayer()->removeAnimation(animationId, toAdd->targetProperty());
997 return platformLayer()->addAnimation(toAdd.get());
998 }
999
1000 return false;
1001 } 974 }
1002 975
1003 void GraphicsLayer::pauseAnimation(const String& animationName, double timeOffse t) 976 void GraphicsLayer::pauseAnimation(int animationId, double timeOffset)
1004 { 977 {
1005 if (m_animationIdMap.contains(animationName)) 978 platformLayer()->pauseAnimation(animationId, timeOffset);
1006 platformLayer()->pauseAnimation(m_animationIdMap.get(animationName), tim eOffset);
1007 } 979 }
1008 980
1009 void GraphicsLayer::removeAnimation(const String& animationName) 981 void GraphicsLayer::removeAnimation(int animationId)
1010 { 982 {
1011 if (m_animationIdMap.contains(animationName)) 983 platformLayer()->removeAnimation(animationId);
1012 platformLayer()->removeAnimation(m_animationIdMap.get(animationName));
1013 } 984 }
1014 985
1015 void GraphicsLayer::suspendAnimations(double wallClockTime) 986 void GraphicsLayer::suspendAnimations(double wallClockTime)
1016 { 987 {
1017 // |wallClockTime| is in the wrong time base. Need to convert here. 988 // |wallClockTime| is in the wrong time base. Need to convert here.
1018 // FIXME: find a more reliable way to do this. 989 // FIXME: find a more reliable way to do this.
1019 double monotonicTime = wallClockTime + monotonicallyIncreasingTime() - curre ntTime(); 990 double monotonicTime = wallClockTime + monotonicallyIncreasingTime() - curre ntTime();
1020 platformLayer()->suspendAnimations(monotonicTime); 991 platformLayer()->suspendAnimations(monotonicTime);
1021 } 992 }
1022 993
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 #ifndef NDEBUG 1170 #ifndef NDEBUG
1200 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer) 1171 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer)
1201 { 1172 {
1202 if (!layer) 1173 if (!layer)
1203 return; 1174 return;
1204 1175
1205 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo); 1176 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo);
1206 fprintf(stderr, "%s\n", output.utf8().data()); 1177 fprintf(stderr, "%s\n", output.utf8().data());
1207 } 1178 }
1208 #endif 1179 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698