OLD | NEW |
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 void ContentViewRenderView::SurfaceChanged(JNIEnv* env, jobject obj, | 111 void ContentViewRenderView::SurfaceChanged(JNIEnv* env, jobject obj, |
112 jint format, jint width, jint height, jobject surface) { | 112 jint format, jint width, jint height, jobject surface) { |
113 if (current_surface_format_ != format) { | 113 if (current_surface_format_ != format) { |
114 current_surface_format_ = format; | 114 current_surface_format_ = format; |
115 compositor_->SetSurface(surface); | 115 compositor_->SetSurface(surface); |
116 } | 116 } |
117 compositor_->SetWindowBounds(gfx::Size(width, height)); | 117 compositor_->SetWindowBounds(gfx::Size(width, height)); |
118 } | 118 } |
119 | 119 |
120 jboolean ContentViewRenderView::CompositeToBitmap(JNIEnv* env, jobject obj, | |
121 jobject java_bitmap) { | |
122 gfx::JavaBitmap bitmap(java_bitmap); | |
123 if (!compositor_ || bitmap.format() != ANDROID_BITMAP_FORMAT_RGBA_8888) | |
124 return false; | |
125 return compositor_->CompositeAndReadback(bitmap.pixels(), | |
126 gfx::Rect(bitmap.size())); | |
127 } | |
128 | |
129 void ContentViewRenderView::SetOverlayVideoMode( | 120 void ContentViewRenderView::SetOverlayVideoMode( |
130 JNIEnv* env, jobject obj, bool enabled) { | 121 JNIEnv* env, jobject obj, bool enabled) { |
131 compositor_->SetHasTransparentBackground(enabled); | 122 compositor_->SetHasTransparentBackground(enabled); |
132 } | 123 } |
133 | 124 |
134 void ContentViewRenderView::Layout() { | 125 void ContentViewRenderView::Layout() { |
135 JNIEnv* env = base::android::AttachCurrentThread(); | 126 JNIEnv* env = base::android::AttachCurrentThread(); |
136 Java_ContentViewRenderView_onCompositorLayout(env, java_obj_.obj()); | 127 Java_ContentViewRenderView_onCompositorLayout(env, java_obj_.obj()); |
137 } | 128 } |
138 | 129 |
139 void ContentViewRenderView::OnSwapBuffersCompleted(int pending_swap_buffers) { | 130 void ContentViewRenderView::OnSwapBuffersCompleted(int pending_swap_buffers) { |
140 JNIEnv* env = base::android::AttachCurrentThread(); | 131 JNIEnv* env = base::android::AttachCurrentThread(); |
141 Java_ContentViewRenderView_onSwapBuffersCompleted(env, java_obj_.obj()); | 132 Java_ContentViewRenderView_onSwapBuffersCompleted(env, java_obj_.obj()); |
142 } | 133 } |
143 | 134 |
144 void ContentViewRenderView::InitCompositor() { | 135 void ContentViewRenderView::InitCompositor() { |
145 if (!compositor_) | 136 if (!compositor_) |
146 compositor_.reset(Compositor::Create(this, root_window_)); | 137 compositor_.reset(Compositor::Create(this, root_window_)); |
147 } | 138 } |
148 } // namespace content | 139 } // namespace content |
OLD | NEW |