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

Side by Side Diff: chrome/browser/android/compositor/scene_layer/reader_mode_scene_layer.cc

Issue 2142263002: Remove ContentViewCore dependency from OverlayPanel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: var name Created 4 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 | « chrome/browser/android/compositor/scene_layer/contextual_search_scene_layer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/reader_mode_scene_layer. h" 5 #include "chrome/browser/android/compositor/scene_layer/reader_mode_scene_layer. h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "cc/layers/solid_color_layer.h" 9 #include "cc/layers/solid_color_layer.h"
10 #include "chrome/browser/android/compositor/layer/reader_mode_layer.h" 10 #include "chrome/browser/android/compositor/layer/reader_mode_layer.h"
11 #include "content/public/browser/android/compositor.h" 11 #include "content/public/browser/android/compositor.h"
12 #include "content/public/browser/android/content_view_core.h" 12 #include "content/public/browser/web_contents.h"
13 #include "jni/ReaderModeSceneLayer_jni.h" 13 #include "jni/ReaderModeSceneLayer_jni.h"
14 #include "ui/android/resources/resource_manager_impl.h" 14 #include "ui/android/resources/resource_manager_impl.h"
15 #include "ui/android/view_android.h"
15 #include "ui/gfx/android/java_bitmap.h" 16 #include "ui/gfx/android/java_bitmap.h"
16 17
17 namespace chrome { 18 namespace chrome {
18 namespace android { 19 namespace android {
19 20
20 ReaderModeSceneLayer::ReaderModeSceneLayer(JNIEnv* env, jobject jobj) 21 ReaderModeSceneLayer::ReaderModeSceneLayer(JNIEnv* env, jobject jobj)
21 : SceneLayer(env, jobj), 22 : SceneLayer(env, jobj),
22 base_page_brightness_(1.0f), 23 base_page_brightness_(1.0f),
23 content_container_(cc::Layer::Create()) { 24 content_container_(cc::Layer::Create()) {
24 // Responsible for moving the base page without modifying the layer itself. 25 // Responsible for moving the base page without modifying the layer itself.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 panel_icon_resource_id, 61 panel_icon_resource_id,
61 close_icon_resource_id); 62 close_icon_resource_id);
62 } 63 }
63 64
64 void ReaderModeSceneLayer::Update( 65 void ReaderModeSceneLayer::Update(
65 JNIEnv* env, 66 JNIEnv* env,
66 const JavaParamRef<jobject>& object, 67 const JavaParamRef<jobject>& object,
67 jfloat dp_to_px, 68 jfloat dp_to_px,
68 jfloat base_page_brightness, 69 jfloat base_page_brightness,
69 jfloat base_page_offset, 70 jfloat base_page_offset,
70 const JavaParamRef<jobject>& jcontent_view_core, 71 const JavaParamRef<jobject>& jweb_contents,
71 jfloat panel_X, 72 jfloat panel_X,
72 jfloat panel_y, 73 jfloat panel_y,
73 jfloat panel_width, 74 jfloat panel_width,
74 jfloat panel_height, 75 jfloat panel_height,
75 jfloat bar_margin_side, 76 jfloat bar_margin_side,
76 jfloat bar_height, 77 jfloat bar_height,
77 jfloat text_opacity, 78 jfloat text_opacity,
78 jboolean bar_border_visible, 79 jboolean bar_border_visible,
79 jfloat bar_border_height, 80 jfloat bar_border_height,
80 jboolean bar_shadow_visible, 81 jboolean bar_shadow_visible,
81 jfloat bar_shadow_opacity) { 82 jfloat bar_shadow_opacity) {
82 // NOTE(mdjones): It is possible to render the panel before content has been 83 // NOTE(mdjones): It is possible to render the panel before content has been
83 // created. If this is the case, do not attempt to access the ContentViewCore 84 // created. If this is the case, do not attempt to access the WebContents
84 // and instead pass null. 85 // and instead pass null.
85 content::ContentViewCore* content_view_core = 86 content::WebContents* web_contents =
86 !jcontent_view_core ? NULL 87 content::WebContents::FromJavaWebContents(jweb_contents);
87 : content::ContentViewCore::GetNativeContentViewCore( 88
88 env, jcontent_view_core); 89 scoped_refptr<cc::Layer> content_layer =
90 web_contents ? web_contents->GetNativeView()->GetLayer() : nullptr;
89 91
90 // Fade the base page out. 92 // Fade the base page out.
91 if (base_page_brightness_ != base_page_brightness) { 93 if (base_page_brightness_ != base_page_brightness) {
92 base_page_brightness_ = base_page_brightness; 94 base_page_brightness_ = base_page_brightness;
93 cc::FilterOperations filters; 95 cc::FilterOperations filters;
94 if (base_page_brightness < 1.f) { 96 if (base_page_brightness < 1.f) {
95 filters.Append( 97 filters.Append(
96 cc::FilterOperation::CreateBrightnessFilter(base_page_brightness)); 98 cc::FilterOperation::CreateBrightnessFilter(base_page_brightness));
97 } 99 }
98 content_container_->SetFilters(filters); 100 content_container_->SetFilters(filters);
99 } 101 }
100 102
101 // Move the base page contents up. 103 // Move the base page contents up.
102 content_container_->SetPosition(gfx::PointF(0.0f, base_page_offset)); 104 content_container_->SetPosition(gfx::PointF(0.0f, base_page_offset));
103 105
104 reader_mode_layer_->SetProperties( 106 reader_mode_layer_->SetProperties(
105 dp_to_px, 107 dp_to_px,
106 content_view_core, 108 content_layer,
107 panel_X, 109 panel_X,
108 panel_y, 110 panel_y,
109 panel_width, 111 panel_width,
110 panel_height, 112 panel_height,
111 bar_margin_side, 113 bar_margin_side,
112 bar_height, 114 bar_height,
113 text_opacity, 115 text_opacity,
114 bar_border_visible, 116 bar_border_visible,
115 bar_border_height, 117 bar_border_height,
116 bar_shadow_visible, 118 bar_shadow_visible,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 new ReaderModeSceneLayer(env, jobj); 155 new ReaderModeSceneLayer(env, jobj);
154 return reinterpret_cast<intptr_t>(reader_mode_scene_layer); 156 return reinterpret_cast<intptr_t>(reader_mode_scene_layer);
155 } 157 }
156 158
157 bool RegisterReaderModeSceneLayer(JNIEnv* env) { 159 bool RegisterReaderModeSceneLayer(JNIEnv* env) {
158 return RegisterNativesImpl(env); 160 return RegisterNativesImpl(env);
159 } 161 }
160 162
161 } // namespace android 163 } // namespace android
162 } // namespace chrome 164 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/android/compositor/scene_layer/contextual_search_scene_layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698