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

Side by Side Diff: content/browser/android/content_view_render_view.cc

Issue 1489453003: jni: Pass method parameters as JavaParamRef in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/android/content_view_render_view.h" 5 #include "content/browser/android/content_view_render_view.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/android/scoped_java_ref.h" 9 #include "base/android/scoped_java_ref.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 static jlong Init(JNIEnv* env, 45 static jlong Init(JNIEnv* env,
46 const JavaParamRef<jobject>& obj, 46 const JavaParamRef<jobject>& obj,
47 jlong native_root_window) { 47 jlong native_root_window) {
48 gfx::NativeWindow root_window = 48 gfx::NativeWindow root_window =
49 reinterpret_cast<gfx::NativeWindow>(native_root_window); 49 reinterpret_cast<gfx::NativeWindow>(native_root_window);
50 ContentViewRenderView* content_view_render_view = 50 ContentViewRenderView* content_view_render_view =
51 new ContentViewRenderView(env, obj, root_window); 51 new ContentViewRenderView(env, obj, root_window);
52 return reinterpret_cast<intptr_t>(content_view_render_view); 52 return reinterpret_cast<intptr_t>(content_view_render_view);
53 } 53 }
54 54
55 void ContentViewRenderView::Destroy(JNIEnv* env, jobject obj) { 55 void ContentViewRenderView::Destroy(JNIEnv* env,
56 const JavaParamRef<jobject>& obj) {
56 delete this; 57 delete this;
57 } 58 }
58 59
59 void ContentViewRenderView::SetCurrentContentViewCore( 60 void ContentViewRenderView::SetCurrentContentViewCore(
60 JNIEnv* env, jobject obj, jlong native_content_view_core) { 61 JNIEnv* env,
62 const JavaParamRef<jobject>& obj,
63 jlong native_content_view_core) {
61 InitCompositor(); 64 InitCompositor();
62 ContentViewCoreImpl* content_view_core = 65 ContentViewCoreImpl* content_view_core =
63 reinterpret_cast<ContentViewCoreImpl*>(native_content_view_core); 66 reinterpret_cast<ContentViewCoreImpl*>(native_content_view_core);
64 compositor_->SetRootLayer(content_view_core ? content_view_core->GetLayer() 67 compositor_->SetRootLayer(content_view_core ? content_view_core->GetLayer()
65 : scoped_refptr<cc::Layer>()); 68 : scoped_refptr<cc::Layer>());
66 } 69 }
67 70
68 void ContentViewRenderView::SurfaceCreated( 71 void ContentViewRenderView::SurfaceCreated(JNIEnv* env,
69 JNIEnv* env, jobject obj) { 72 const JavaParamRef<jobject>& obj) {
70 current_surface_format_ = 0; 73 current_surface_format_ = 0;
71 InitCompositor(); 74 InitCompositor();
72 } 75 }
73 76
74 void ContentViewRenderView::SurfaceDestroyed(JNIEnv* env, jobject obj) { 77 void ContentViewRenderView::SurfaceDestroyed(JNIEnv* env,
78 const JavaParamRef<jobject>& obj) {
75 compositor_->SetSurface(NULL); 79 compositor_->SetSurface(NULL);
76 current_surface_format_ = 0; 80 current_surface_format_ = 0;
77 } 81 }
78 82
79 void ContentViewRenderView::SurfaceChanged(JNIEnv* env, jobject obj, 83 void ContentViewRenderView::SurfaceChanged(
80 jint format, jint width, jint height, jobject surface) { 84 JNIEnv* env,
85 const JavaParamRef<jobject>& obj,
86 jint format,
87 jint width,
88 jint height,
89 const JavaParamRef<jobject>& surface) {
81 if (current_surface_format_ != format) { 90 if (current_surface_format_ != format) {
82 current_surface_format_ = format; 91 current_surface_format_ = format;
83 compositor_->SetSurface(surface); 92 compositor_->SetSurface(surface);
84 } 93 }
85 compositor_->SetWindowBounds(gfx::Size(width, height)); 94 compositor_->SetWindowBounds(gfx::Size(width, height));
86 } 95 }
87 96
88 void ContentViewRenderView::SetOverlayVideoMode( 97 void ContentViewRenderView::SetOverlayVideoMode(
89 JNIEnv* env, jobject obj, bool enabled) { 98 JNIEnv* env,
99 const JavaParamRef<jobject>& obj,
100 bool enabled) {
90 compositor_->SetHasTransparentBackground(enabled); 101 compositor_->SetHasTransparentBackground(enabled);
91 SetNeedsComposite(env, obj); 102 SetNeedsComposite(env, obj);
92 } 103 }
93 104
94 void ContentViewRenderView::SetNeedsComposite(JNIEnv* env, jobject obj) { 105 void ContentViewRenderView::SetNeedsComposite(
106 JNIEnv* env,
107 const JavaParamRef<jobject>& obj) {
95 if (compositor_) 108 if (compositor_)
96 compositor_->SetNeedsComposite(); 109 compositor_->SetNeedsComposite();
97 } 110 }
98 111
99 void ContentViewRenderView::UpdateLayerTreeHost() { 112 void ContentViewRenderView::UpdateLayerTreeHost() {
100 // TODO(wkorman): Rename Layout to UpdateLayerTreeHost in all Android 113 // TODO(wkorman): Rename Layout to UpdateLayerTreeHost in all Android
101 // Compositor related classes. 114 // Compositor related classes.
102 } 115 }
103 116
104 void ContentViewRenderView::OnSwapBuffersCompleted(int pending_swap_buffers) { 117 void ContentViewRenderView::OnSwapBuffersCompleted(int pending_swap_buffers) {
105 JNIEnv* env = base::android::AttachCurrentThread(); 118 JNIEnv* env = base::android::AttachCurrentThread();
106 Java_ContentViewRenderView_onSwapBuffersCompleted(env, java_obj_.obj()); 119 Java_ContentViewRenderView_onSwapBuffersCompleted(env, java_obj_.obj());
107 } 120 }
108 121
109 void ContentViewRenderView::InitCompositor() { 122 void ContentViewRenderView::InitCompositor() {
110 if (!compositor_) 123 if (!compositor_)
111 compositor_.reset(Compositor::Create(this, root_window_)); 124 compositor_.reset(Compositor::Create(this, root_window_));
112 } 125 }
113 126
114 jlong ContentViewRenderView::GetUIResourceProvider(JNIEnv* env, 127 jlong ContentViewRenderView::GetUIResourceProvider(
115 jobject obj) { 128 JNIEnv* env,
129 const JavaParamRef<jobject>& obj) {
116 if (!compositor_) 130 if (!compositor_)
117 return 0; 131 return 0;
118 return reinterpret_cast<intptr_t>(&compositor_->GetUIResourceProvider()); 132 return reinterpret_cast<intptr_t>(&compositor_->GetUIResourceProvider());
119 } 133 }
120 } // namespace content 134 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698