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

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: Fix typo 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 330 }
335 331
336 void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const I ntRect& clip) 332 void GraphicsLayer::paintGraphicsLayerContents(GraphicsContext& context, const I ntRect& clip)
337 { 333 {
338 if (!m_client) 334 if (!m_client)
339 return; 335 return;
340 incrementPaintCount(); 336 incrementPaintCount();
341 m_client->paintContents(this, context, m_paintingPhase, clip); 337 m_client->paintContents(this, context, m_paintingPhase, clip);
342 } 338 }
343 339
344 String GraphicsLayer::animationNameForTransition(AnimatedPropertyID property)
345 {
346 // | is not a valid identifier character in CSS, so this can never conflict with a keyframe identifier.
347 StringBuilder id;
348 id.appendLiteral("-|transition");
349 id.appendNumber(static_cast<int>(property));
350 id.append('-');
351 return id.toString();
352 }
353
354 void GraphicsLayer::setZPosition(float position) 340 void GraphicsLayer::setZPosition(float position)
355 { 341 {
356 m_zPosition = position; 342 m_zPosition = position;
357 } 343 }
358 344
359 float GraphicsLayer::accumulatedOpacity() const 345 float GraphicsLayer::accumulatedOpacity() const
360 { 346 {
361 if (!preserves3D()) 347 if (!preserves3D())
362 return 1; 348 return 1;
363 349
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 void GraphicsLayer::setContentsToCanvas(WebLayer* layer) 962 void GraphicsLayer::setContentsToCanvas(WebLayer* layer)
977 { 963 {
978 setContentsTo(ContentsLayerForCanvas, layer); 964 setContentsTo(ContentsLayerForCanvas, layer);
979 } 965 }
980 966
981 void GraphicsLayer::setContentsToMedia(WebLayer* layer) 967 void GraphicsLayer::setContentsToMedia(WebLayer* layer)
982 { 968 {
983 setContentsTo(ContentsLayerForVideo, layer); 969 setContentsTo(ContentsLayerForVideo, layer);
984 } 970 }
985 971
986 bool GraphicsLayer::addAnimation(const KeyframeValueList& values, const IntSize& boxSize, const CSSAnimationData* animation, const String& animationName, double timeOffset) 972 bool GraphicsLayer::addAnimation(WebAnimation* animation)
987 { 973 {
974 ASSERT(animation);
988 platformLayer()->setAnimationDelegate(this); 975 platformLayer()->setAnimationDelegate(this);
989 976
990 int animationId = 0; 977 // Remove any existing animations with the same animation id and target prop erty.
991 978 platformLayer()->removeAnimation(animation->id(), animation->targetProperty( ));
992 if (m_animationIdMap.contains(animationName)) 979 return platformLayer()->addAnimation(animation);
993 animationId = m_animationIdMap.get(animationName);
994
995 OwnPtr<WebAnimation> toAdd(createWebAnimation(values, animation, animationId , timeOffset, boxSize));
996
997 if (toAdd) {
998 animationId = toAdd->id();
999 m_animationIdMap.set(animationName, animationId);
1000
1001 // Remove any existing animations with the same animation id and target property.
1002 platformLayer()->removeAnimation(animationId, toAdd->targetProperty());
1003 return platformLayer()->addAnimation(toAdd.get());
1004 }
1005
1006 return false;
1007 } 980 }
1008 981
1009 void GraphicsLayer::pauseAnimation(const String& animationName, double timeOffse t) 982 void GraphicsLayer::pauseAnimation(int animationId, double timeOffset)
1010 { 983 {
1011 if (m_animationIdMap.contains(animationName)) 984 platformLayer()->pauseAnimation(animationId, timeOffset);
1012 platformLayer()->pauseAnimation(m_animationIdMap.get(animationName), tim eOffset);
1013 } 985 }
1014 986
1015 void GraphicsLayer::removeAnimation(const String& animationName) 987 void GraphicsLayer::removeAnimation(int animationId)
1016 { 988 {
1017 if (m_animationIdMap.contains(animationName)) 989 platformLayer()->removeAnimation(animationId);
1018 platformLayer()->removeAnimation(m_animationIdMap.get(animationName));
1019 } 990 }
1020 991
1021 void GraphicsLayer::suspendAnimations(double wallClockTime) 992 void GraphicsLayer::suspendAnimations(double wallClockTime)
1022 { 993 {
1023 // |wallClockTime| is in the wrong time base. Need to convert here. 994 // |wallClockTime| is in the wrong time base. Need to convert here.
1024 // FIXME: find a more reliable way to do this. 995 // FIXME: find a more reliable way to do this.
1025 double monotonicTime = wallClockTime + monotonicallyIncreasingTime() - curre ntTime(); 996 double monotonicTime = wallClockTime + monotonicallyIncreasingTime() - curre ntTime();
1026 platformLayer()->suspendAnimations(monotonicTime); 997 platformLayer()->suspendAnimations(monotonicTime);
1027 } 998 }
1028 999
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 #ifndef NDEBUG 1182 #ifndef NDEBUG
1212 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer) 1183 void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer)
1213 { 1184 {
1214 if (!layer) 1185 if (!layer)
1215 return; 1186 return;
1216 1187
1217 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo); 1188 String output = layer->layerTreeAsText(WebCore::LayerTreeIncludesDebugInfo);
1218 fprintf(stderr, "%s\n", output.utf8().data()); 1189 fprintf(stderr, "%s\n", output.utf8().data());
1219 } 1190 }
1220 #endif 1191 #endif
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/GraphicsLayer.h ('k') | Source/core/platform/graphics/chromium/AnimationTranslationUtil.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698