Support alpha in backgroundColor
This commit is contained in:
parent
9b28b0e943
commit
2fcd3ce7cd
2 changed files with 5 additions and 5 deletions
|
@ -552,11 +552,11 @@ void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
|||
}
|
||||
|
||||
SkColor NativeWindow::ParseHexColor(const std::string& name) {
|
||||
SkColor result = 0xFF000000;
|
||||
unsigned value = 0;
|
||||
auto color = name.substr(1);
|
||||
unsigned length = color.size();
|
||||
if (length != 3 && length != 6)
|
||||
SkColor result = (length != 8 ? 0xFF000000 : 0x00000000);
|
||||
unsigned value = 0;
|
||||
if (length != 3 && length != 6 && length != 8)
|
||||
return result;
|
||||
for (unsigned i = 0; i < length; ++i) {
|
||||
if (!base::IsHexDigit(color[i]))
|
||||
|
@ -564,7 +564,7 @@ SkColor NativeWindow::ParseHexColor(const std::string& name) {
|
|||
value <<= 4;
|
||||
value |= (color[i] < 'A' ? color[i] - '0' : (color[i] - 'A' + 10) & 0xF);
|
||||
}
|
||||
if (length == 6) {
|
||||
if (length == 6 || length == 8) {
|
||||
result |= value;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -710,7 +710,7 @@ void NativeWindowMac::SetBackgroundColor(const std::string& color_name) {
|
|||
NSColor *color = [NSColor colorWithCalibratedRed:SkColorGetR(background_color)
|
||||
green:SkColorGetG(background_color)
|
||||
blue:SkColorGetB(background_color)
|
||||
alpha:1.0];
|
||||
alpha:SkColorGetA(background_color)/255.0f];
|
||||
[window_ setBackgroundColor:color];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue