Index: ui/compositor/layer.cc |
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc |
index 57fd1ccf340ca04d0b163d3707c027bb14575e46..64faa6a1418a7f56175b47817e0a521397ef6afe 100644 |
--- a/ui/compositor/layer.cc |
+++ b/ui/compositor/layer.cc |
@@ -97,6 +97,9 @@ Layer::Layer() |
layer_brightness_(0.0f), |
layer_grayscale_(0.0f), |
layer_inverted_(false), |
+ layer_temperature_(0.0f), |
+ layer_blue_scale_(1.0f), |
+ layer_green_scale_(1.0f), |
layer_mask_(NULL), |
layer_mask_back_link_(NULL), |
zoom_(1), |
@@ -120,6 +123,9 @@ Layer::Layer(LayerType type) |
layer_brightness_(0.0f), |
layer_grayscale_(0.0f), |
layer_inverted_(false), |
+ layer_temperature_(0.0f), |
+ layer_blue_scale_(1.0f), |
+ layer_green_scale_(1.0f), |
layer_mask_(NULL), |
layer_mask_back_link_(NULL), |
zoom_(1), |
@@ -372,6 +378,10 @@ float Layer::GetCombinedOpacity() const { |
return opacity; |
} |
+void Layer::SetLayerTemperature(float value) { |
+ GetAnimator()->SetTemperature(value); |
+} |
+ |
void Layer::SetBackgroundBlur(int blur_radius) { |
background_blur_radius_ = blur_radius; |
@@ -458,6 +468,15 @@ void Layer::SetLayerFilters() { |
filters.Append(cc::FilterOperation::CreateGrayscaleFilter( |
layer_grayscale_)); |
} |
+ if (layer_temperature_) { |
+ float color_matrix[] = { |
+ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, |
+ 0.0f, layer_green_scale_, 0.0f, 0.0f, 0.0f, |
+ 0.0f, 0.0f, layer_blue_scale_, 0.0f, 0.0f, |
+ 0.0f, 0.0f, 0.0f, 1.0f, 0.0f |
+ }; |
+ filters.Append(cc::FilterOperation::CreateColorMatrixFilter(color_matrix)); |
+ } |
if (layer_inverted_) |
filters.Append(cc::FilterOperation::CreateInvertFilter(1.0)); |
// Brightness goes last, because the resulting colors neeed clamping, which |
@@ -1054,6 +1073,17 @@ void Layer::SetColorFromAnimation(SkColor color) { |
SetFillsBoundsOpaquely(SkColorGetA(color) == 0xFF); |
} |
+void Layer::SetTemperatureFromAnimation(float temperature) { |
+ layer_temperature_ = temperature; |
+ |
+ // If we only tone down the blue scale, the screen will look very green so we |
+ // also need to tone down the green, but with a less value compared to the |
+ // blue scale to avoid making things look very red. |
+ layer_blue_scale_ = 1.0f - temperature; |
+ layer_green_scale_ = 1.0f - 0.3f * temperature; |
+ SetLayerFilters(); |
+} |
+ |
void Layer::ScheduleDrawForAnimation() { |
ScheduleDraw(); |
} |
@@ -1090,6 +1120,10 @@ SkColor Layer::GetColorForAnimation() const { |
solid_color_layer_->background_color() : SK_ColorBLACK; |
} |
+float Layer::GetTemperatureFromAnimation() const { |
+ return layer_temperature_; |
+} |
+ |
float Layer::GetDeviceScaleFactor() const { |
return device_scale_factor_; |
} |