| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 jboolean ContentViewRenderView::CompositeToBitmap(JNIEnv* env, jobject obj, | 88 jboolean ContentViewRenderView::CompositeToBitmap(JNIEnv* env, jobject obj, |
| 89 jobject java_bitmap) { | 89 jobject java_bitmap) { |
| 90 gfx::JavaBitmap bitmap(java_bitmap); | 90 gfx::JavaBitmap bitmap(java_bitmap); |
| 91 if (!compositor_ || bitmap.format() != ANDROID_BITMAP_FORMAT_RGBA_8888) | 91 if (!compositor_ || bitmap.format() != ANDROID_BITMAP_FORMAT_RGBA_8888) |
| 92 return false; | 92 return false; |
| 93 return compositor_->CompositeAndReadback(bitmap.pixels(), | 93 return compositor_->CompositeAndReadback(bitmap.pixels(), |
| 94 gfx::Rect(bitmap.size())); | 94 gfx::Rect(bitmap.size())); |
| 95 } | 95 } |
| 96 | 96 |
| 97 jint ContentViewRenderView::GetNativeCompositorProviderPtr(JNIEnv* env, |
| 98 jobject obj) { |
| 99 return reinterpret_cast<jint>(static_cast<CompositorProvider*>(this)); |
| 100 } |
| 101 |
| 97 void ContentViewRenderView::ScheduleComposite() { | 102 void ContentViewRenderView::ScheduleComposite() { |
| 98 JNIEnv* env = base::android::AttachCurrentThread(); | 103 JNIEnv* env = base::android::AttachCurrentThread(); |
| 99 Java_ContentViewRenderView_requestRender(env, java_obj_.obj()); | 104 Java_ContentViewRenderView_requestRender(env, java_obj_.obj()); |
| 100 } | 105 } |
| 101 | 106 |
| 102 void ContentViewRenderView::OnSwapBuffersPosted() { | 107 void ContentViewRenderView::OnSwapBuffersPosted() { |
| 103 buffers_swapped_during_composite_ = true; | 108 buffers_swapped_during_composite_ = true; |
| 104 } | 109 } |
| 105 | 110 |
| 106 void ContentViewRenderView::OnSwapBuffersCompleted() { | 111 void ContentViewRenderView::OnSwapBuffersCompleted() { |
| 107 JNIEnv* env = base::android::AttachCurrentThread(); | 112 JNIEnv* env = base::android::AttachCurrentThread(); |
| 108 Java_ContentViewRenderView_onSwapBuffersCompleted(env, java_obj_.obj()); | 113 Java_ContentViewRenderView_onSwapBuffersCompleted(env, java_obj_.obj()); |
| 109 } | 114 } |
| 110 | 115 |
| 111 void ContentViewRenderView::InitCompositor() { | 116 void ContentViewRenderView::InitCompositor() { |
| 112 if (!compositor_) | 117 if (!compositor_) |
| 113 compositor_.reset(Compositor::Create(this)); | 118 compositor_.reset(Compositor::Create(this)); |
| 114 } | 119 } |
| 115 | 120 |
| 121 Compositor* ContentViewRenderView::GetCompositor() { |
| 122 return compositor_.get(); |
| 123 } |
| 124 |
| 116 } // namespace content | 125 } // namespace content |
| OLD | NEW |