-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the active memory footprint calculation so that the core logic can be used in the ambient calculation as well, to optimise the way we evaluate nodes under multiple combinations of user styles. This change also removes some code that was unused after changes were made to the ambient calculation.
- Loading branch information
Showing
6 changed files
with
138 additions
and
275 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...t/src/main/java/com/google/wear/watchface/dfx/memory/ActiveMemoryFootprintCalculator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.google.wear.watchface.dfx.memory; | ||
|
||
import static com.google.wear.watchface.dfx.memory.WatchFaceDocuments.findSceneNode; | ||
|
||
import org.w3c.dom.Document; | ||
|
||
import java.util.Map; | ||
|
||
/** Computes the memory footprint of a watch face in active. */ | ||
public class ActiveMemoryFootprintCalculator { | ||
private final VariantConfigValue activeConfigValue; | ||
private final Document document; | ||
private final Map<String, DrawableResourceDetails> resourceMemoryMap; | ||
private final EvaluationSettings evaluationSettings; | ||
|
||
ActiveMemoryFootprintCalculator( | ||
Document document, | ||
Map<String, DrawableResourceDetails> resourceMemoryMap, | ||
EvaluationSettings evaluationSettings) { | ||
this.activeConfigValue = VariantConfigValue.active(evaluationSettings); | ||
this.document = document; | ||
this.resourceMemoryMap = resourceMemoryMap; | ||
this.evaluationSettings = evaluationSettings; | ||
} | ||
|
||
long computeAmbientMemoryFootprint() { | ||
DrawableNodeConfigTable drawableNodeConfigTable = | ||
DrawableNodeConfigTable.create(findSceneNode(document), activeConfigValue); | ||
WatchFaceResourceCollector resourceCollector = | ||
new WatchFaceResourceCollector(document, resourceMemoryMap, evaluationSettings); | ||
return new DynamicNodePerConfigurationFootprintCalculator( | ||
document, | ||
resourceMemoryMap, | ||
evaluationSettings, | ||
activeConfigValue, | ||
resourceCollector, | ||
drawableNodeConfigTable) | ||
.calculateMaxFootprintBytes(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.