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

Side by Side Diff: sky/sdk/lib/widgets/icon.dart

Issue 1236043004: Improve drawer performance (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: cache paint Created 5 years, 5 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
« no previous file with comments | « sky/sdk/lib/widgets/drawer_item.dart ('k') | sky/services/engine/input_event.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:sky' as sky;
6
5 import 'package:sky/mojo/asset_bundle.dart'; 7 import 'package:sky/mojo/asset_bundle.dart';
6 import 'package:sky/widgets/basic.dart'; 8 import 'package:sky/widgets/basic.dart';
7 import 'package:sky/widgets/theme.dart'; 9 import 'package:sky/widgets/theme.dart';
8 import 'package:sky/widgets/widget.dart'; 10 import 'package:sky/widgets/widget.dart';
9 11
10 enum IconThemeColor { white, black } 12 enum IconThemeColor { white, black }
11 13
12 class IconThemeData { 14 class IconThemeData {
13 const IconThemeData({ this.color }); 15 const IconThemeData({ this.color });
14 final IconThemeColor color; 16 final IconThemeColor color;
(...skipping 24 matching lines...) Expand all
39 AssetBundle _initIconBundle() { 41 AssetBundle _initIconBundle() {
40 if (rootBundle != null) 42 if (rootBundle != null)
41 return rootBundle; 43 return rootBundle;
42 const String _kAssetBase = '/packages/sky/assets/material-design-icons/'; 44 const String _kAssetBase = '/packages/sky/assets/material-design-icons/';
43 return new NetworkAssetBundle(Uri.base.resolve(_kAssetBase)); 45 return new NetworkAssetBundle(Uri.base.resolve(_kAssetBase));
44 } 46 }
45 47
46 final AssetBundle _iconBundle = _initIconBundle(); 48 final AssetBundle _iconBundle = _initIconBundle();
47 49
48 class Icon extends Component { 50 class Icon extends Component {
49 Icon({ String key, this.size, this.type: '', this.color }) : super(key: key); 51 Icon({
52 String key,
53 this.size,
54 this.type: '',
55 this.color,
56 this.colorFilter
57 }) : super(key: key);
50 58
51 final int size; 59 final int size;
52 final String type; 60 final String type;
53 final IconThemeColor color; 61 final IconThemeColor color;
62 final sky.ColorFilter colorFilter;
54 63
55 String get colorSuffix { 64 String get colorSuffix {
56 IconThemeColor iconThemeColor = color; 65 IconThemeColor iconThemeColor = color;
57 if (iconThemeColor == null) { 66 if (iconThemeColor == null) {
58 IconThemeData iconThemeData = IconTheme.of(this); 67 IconThemeData iconThemeData = IconTheme.of(this);
59 iconThemeColor = iconThemeData == null ? null : iconThemeData.color; 68 iconThemeColor = iconThemeData == null ? null : iconThemeData.color;
60 } 69 }
61 if (iconThemeColor == null) { 70 if (iconThemeColor == null) {
62 ThemeBrightness themeBrightness = Theme.of(this).brightness; 71 ThemeBrightness themeBrightness = Theme.of(this).brightness;
63 iconThemeColor = themeBrightness == ThemeBrightness.dark ? IconThemeColor. white : IconThemeColor.black; 72 iconThemeColor = themeBrightness == ThemeBrightness.dark ? IconThemeColor. white : IconThemeColor.black;
(...skipping 13 matching lines...) Expand all
77 if (parts.length == 2) { 86 if (parts.length == 2) {
78 category = parts[0]; 87 category = parts[0];
79 subtype = parts[1]; 88 subtype = parts[1];
80 } 89 }
81 // TODO(eseidel): This clearly isn't correct. Not sure what would be. 90 // TODO(eseidel): This clearly isn't correct. Not sure what would be.
82 // Should we use the ios images on ios? 91 // Should we use the ios images on ios?
83 String density = 'drawable-xxhdpi'; 92 String density = 'drawable-xxhdpi';
84 return new AssetImage( 93 return new AssetImage(
85 bundle: _iconBundle, 94 bundle: _iconBundle,
86 name: '${category}/${density}/ic_${subtype}_${colorSuffix}_${size}dp.png', 95 name: '${category}/${density}/ic_${subtype}_${colorSuffix}_${size}dp.png',
87 size: new Size(size.toDouble(), size.toDouble()) 96 size: new Size(size.toDouble(), size.toDouble()),
97 colorFilter: colorFilter
88 ); 98 );
89 } 99 }
90 } 100 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/drawer_item.dart ('k') | sky/services/engine/input_event.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698