Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "chrome/browser/android/compositor/scene_layer/static_tab_scene_layer.h " | 5 #include "chrome/browser/android/compositor/scene_layer/static_tab_scene_layer.h " |
| 6 | 6 |
| 7 #include "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
| 8 #include "chrome/browser/android/compositor/layer/content_layer.h" | 8 #include "chrome/browser/android/compositor/layer/content_layer.h" |
| 9 #include "chrome/browser/android/compositor/layer_title_cache.h" | 9 #include "chrome/browser/android/compositor/layer_title_cache.h" |
| 10 #include "chrome/browser/android/compositor/tab_content_manager.h" | 10 #include "chrome/browser/android/compositor/tab_content_manager.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 jint default_background_color, | 50 jint default_background_color, |
| 51 jfloat x, | 51 jfloat x, |
| 52 jfloat y, | 52 jfloat y, |
| 53 jfloat width, | 53 jfloat width, |
| 54 jfloat height, | 54 jfloat height, |
| 55 jfloat content_offset_y, | 55 jfloat content_offset_y, |
| 56 jfloat static_to_view_blend, | 56 jfloat static_to_view_blend, |
| 57 jfloat saturation, | 57 jfloat saturation, |
| 58 jfloat brightness) { | 58 jfloat brightness) { |
| 59 background_color_ = default_background_color; | 59 background_color_ = default_background_color; |
| 60 gfx::Size content_viewport_size(content_viewport_width, | |
| 61 content_viewport_height); | |
| 62 gfx::Point content_viewport_offset(content_viewport_x, content_viewport_y); | |
| 63 if (!content_layer_.get()) { | 60 if (!content_layer_.get()) { |
| 64 android::TabContentManager* tab_content_manager = | 61 android::TabContentManager* tab_content_manager = |
| 65 android::TabContentManager::FromJavaObject(jtab_content_manager); | 62 android::TabContentManager::FromJavaObject(jtab_content_manager); |
| 66 content_layer_ = android::ContentLayer::Create(tab_content_manager); | 63 content_layer_ = android::ContentLayer::Create(tab_content_manager); |
| 67 layer_->AddChild(content_layer_->layer()); | 64 layer_->AddChild(content_layer_->layer()); |
| 68 } | 65 } |
| 69 | 66 |
| 70 // Only override the alpha of content layers when the static tab is first | 67 // Only override the alpha of content layers when the static tab is first |
| 71 // assigned to the layer tree. | 68 // assigned to the layer tree. |
| 72 float content_alpha_override = 1.f; | 69 float content_alpha_override = 1.f; |
| 73 bool should_override_content_alpha = last_set_tab_id_ != id; | 70 bool should_override_content_alpha = last_set_tab_id_ != id; |
| 74 last_set_tab_id_ = id; | 71 last_set_tab_id_ = id; |
| 75 | 72 |
| 76 // Set up the content layer and move it to the proper position. | |
| 77 content_layer_->layer()->SetBounds(gfx::Size(width, height)); | |
| 78 content_layer_->layer()->SetPosition(gfx::PointF(x, y)); | |
| 79 content_layer_->SetProperties( | 73 content_layer_->SetProperties( |
| 80 id, can_use_live_layer, static_to_view_blend, | 74 id, can_use_live_layer, static_to_view_blend, |
| 81 should_override_content_alpha, content_alpha_override, saturation, | 75 should_override_content_alpha, content_alpha_override, saturation, |
| 82 gfx::Rect(content_viewport_size), content_viewport_size); | 76 false, gfx::Rect()); |
| 83 | 77 |
| 84 gfx::Size content_bounds(0, 0); | 78 x += content_viewport_x; |
|
Changwan Ryu
2016/12/12 07:38:04
Probably content_viewport_x is always 0 here. If t
aelias_OOO_until_Jul13
2016/12/13 02:16:05
OK, removed this addition as you're right it doesn
| |
| 85 content_bounds = content_layer_->layer()->bounds(); | 79 y += content_offset_y; |
|
Changwan Ryu
2016/12/12 07:38:04
This is a great reduction. But now we're passing l
aelias_OOO_until_Jul13
2016/12/13 02:16:05
Done. I also removed content_offset_y and added i
| |
| 86 | |
| 87 gfx::Size actual_content_size(content_layer_->GetContentSize()); | |
| 88 | |
| 89 bool view_and_content_have_same_orientation = | |
| 90 (content_viewport_size.width() > content_viewport_size.height()) == | |
| 91 (actual_content_size.width() > actual_content_size.height()) && | |
| 92 actual_content_size.width() > 0 && actual_content_size.height() > 0 && | |
| 93 content_viewport_size.width() > 0 && content_viewport_size.height() > 0; | |
| 94 | |
| 95 // This may not be true for frames during rotation. | |
| 96 bool content_has_consistent_width = | |
| 97 actual_content_size.width() == content_bounds.width() && | |
| 98 actual_content_size.width() == content_viewport_size.width(); | |
| 99 | |
| 100 if (view_and_content_have_same_orientation || | |
| 101 (content_has_consistent_width && content_layer_->ShowingLiveLayer())) { | |
| 102 y += content_offset_y; | |
| 103 } else { | |
| 104 // If our orientations are off and we have a static texture, or if we have | |
| 105 // a live layer of an unexpected width, move the texture in by the | |
| 106 // appropriate amount. | |
| 107 x += content_viewport_offset.x(); | |
| 108 y += content_viewport_offset.y(); | |
| 109 } | |
| 110 | 80 |
| 111 content_layer_->layer()->SetPosition(gfx::PointF(x, y)); | 81 content_layer_->layer()->SetPosition(gfx::PointF(x, y)); |
| 112 content_layer_->layer()->SetIsDrawable(true); | 82 content_layer_->layer()->SetIsDrawable(true); |
| 113 | 83 |
| 114 // Only applies the brightness filter if the value has changed and is less | 84 // Only applies the brightness filter if the value has changed and is less |
| 115 // than 1. | 85 // than 1. |
| 116 if (brightness != brightness_) { | 86 if (brightness != brightness_) { |
| 117 brightness_ = brightness; | 87 brightness_ = brightness; |
| 118 cc::FilterOperations filters; | 88 cc::FilterOperations filters; |
| 119 if (brightness_ < 1.f) | 89 if (brightness_ < 1.f) |
| 120 filters.Append(cc::FilterOperation::CreateBrightnessFilter(brightness_)); | 90 filters.Append(cc::FilterOperation::CreateBrightnessFilter(brightness_)); |
| 121 layer_->SetFilters(filters); | 91 layer_->SetFilters(filters); |
| 122 } | 92 } |
| 123 } | 93 } |
| 124 | 94 |
| 125 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& jobj) { | 95 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& jobj) { |
| 126 // This will automatically bind to the Java object and pass ownership there. | 96 // This will automatically bind to the Java object and pass ownership there. |
| 127 StaticTabSceneLayer* scene_layer = new StaticTabSceneLayer(env, jobj); | 97 StaticTabSceneLayer* scene_layer = new StaticTabSceneLayer(env, jobj); |
| 128 return reinterpret_cast<intptr_t>(scene_layer); | 98 return reinterpret_cast<intptr_t>(scene_layer); |
| 129 } | 99 } |
| 130 | 100 |
| 131 bool RegisterStaticTabSceneLayer(JNIEnv* env) { | 101 bool RegisterStaticTabSceneLayer(JNIEnv* env) { |
| 132 return RegisterNativesImpl(env); | 102 return RegisterNativesImpl(env); |
| 133 } | 103 } |
| 134 | 104 |
| 135 } // namespace android | 105 } // namespace android |
| OLD | NEW |