Commit 4177a8cd authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS Tether] Add the ability for VectorIcons to adjust opacity.

Previously, it was possible specify an ARGB value via the
PATH_COLOR_ARGB command, which takes an alpha as well as RGB properties
as parameters. However, there was no command to specify a change in
opacity without also specifying the color to use.

This presented a problem for system notification. When displayed
on a notification, these icons are drawn in blue or red, depending on
the warning level of the notification, and when displayed in the black
bar at the bottom of the UI, they are drawn in white. Thus, for
notification icons which need to be displayed in a single color with
different opacities, a new command was needed.

This CL introduces the PATH_COLOR_ALPHA command, which takes a single
parameter expressing the opacity of the path. It will be used
immediately in a follow-up CL:
https://chromium-review.googlesource.com/c/chromium/src/+/685304

Bug: 759257, 672263
Change-Id: I00a5dbb28a06de41239cda2fe1c608754f190bf6
Reviewed-on: https://chromium-review.googlesource.com/690706Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505404}
parent 7fdaa459
......@@ -66,6 +66,7 @@ class PathParser {
case V_LINE_TO:
case R_V_LINE_TO:
case CANVAS_DIMENSIONS:
case PATH_COLOR_ALPHA:
return 1;
case MOVE_TO:
......@@ -123,6 +124,7 @@ CommandType CommandFromString(const std::string& source) {
return command;
RETURN_IF_IS(NEW_PATH);
RETURN_IF_IS(PATH_COLOR_ALPHA);
RETURN_IF_IS(PATH_COLOR_ARGB);
RETURN_IF_IS(PATH_MODE_CLEAR);
RETURN_IF_IS(STROKE);
......@@ -213,6 +215,10 @@ void PaintPath(Canvas* canvas,
case NEW_PATH:
break;
case PATH_COLOR_ALPHA:
flags.setAlpha(SkScalarFloorToInt(arg(0)));
break;
case PATH_COLOR_ARGB:
flags.setColor(SkColorSetARGB(
SkScalarFloorToInt(arg(0)), SkScalarFloorToInt(arg(1)),
......
......@@ -22,6 +22,8 @@ const int kReferenceSizeDip = 48;
enum CommandType {
// A new <path> element. For the first path, this is assumed.
NEW_PATH,
// Sets the alpha for the current path.
PATH_COLOR_ALPHA,
// Sets the color for the current path.
PATH_COLOR_ARGB,
// Sets the path to clear mode (Skia's kClear_Mode).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment