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

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

Issue 281003002: Make ui::Snapshot asynchronous on Android, remove CompositeAndReadback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // static 48 // static
49 bool ContentViewRenderView::RegisterContentViewRenderView(JNIEnv* env) { 49 bool ContentViewRenderView::RegisterContentViewRenderView(JNIEnv* env) {
50 return RegisterNativesImpl(env); 50 return RegisterNativesImpl(env);
51 } 51 }
52 52
53 ContentViewRenderView::ContentViewRenderView(JNIEnv* env, 53 ContentViewRenderView::ContentViewRenderView(JNIEnv* env,
54 jobject obj, 54 jobject obj,
55 gfx::NativeWindow root_window) 55 gfx::NativeWindow root_window)
56 : layer_tree_build_helper_(new LayerTreeBuildHelperImpl()), 56 : layer_tree_build_helper_(new LayerTreeBuildHelperImpl()),
57 root_window_(root_window), 57 root_window_(root_window),
58 current_surface_format_(0) { 58 current_surface_format_(0),
59 weak_ptr_factory_(this) {
59 java_obj_.Reset(env, obj); 60 java_obj_.Reset(env, obj);
60 } 61 }
61 62
62 ContentViewRenderView::~ContentViewRenderView() { 63 ContentViewRenderView::~ContentViewRenderView() {
63 } 64 }
64 65
65 void ContentViewRenderView::SetLayerTreeBuildHelper(JNIEnv* env, 66 void ContentViewRenderView::SetLayerTreeBuildHelper(JNIEnv* env,
66 jobject obj, 67 jobject obj,
67 jlong native_build_helper) { 68 jlong native_build_helper) {
68 CHECK(native_build_helper); 69 CHECK(native_build_helper);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 111
111 void ContentViewRenderView::SurfaceChanged(JNIEnv* env, jobject obj, 112 void ContentViewRenderView::SurfaceChanged(JNIEnv* env, jobject obj,
112 jint format, jint width, jint height, jobject surface) { 113 jint format, jint width, jint height, jobject surface) {
113 if (current_surface_format_ != format) { 114 if (current_surface_format_ != format) {
114 current_surface_format_ = format; 115 current_surface_format_ = format;
115 compositor_->SetSurface(surface); 116 compositor_->SetSurface(surface);
116 } 117 }
117 compositor_->SetWindowBounds(gfx::Size(width, height)); 118 compositor_->SetWindowBounds(gfx::Size(width, height));
118 } 119 }
119 120
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( 121 void ContentViewRenderView::SetOverlayVideoMode(
130 JNIEnv* env, jobject obj, bool enabled) { 122 JNIEnv* env, jobject obj, bool enabled) {
131 compositor_->SetHasTransparentBackground(enabled); 123 compositor_->SetHasTransparentBackground(enabled);
132 } 124 }
133 125
134 void ContentViewRenderView::Layout() { 126 void ContentViewRenderView::Layout() {
135 JNIEnv* env = base::android::AttachCurrentThread(); 127 JNIEnv* env = base::android::AttachCurrentThread();
136 Java_ContentViewRenderView_onCompositorLayout(env, java_obj_.obj()); 128 Java_ContentViewRenderView_onCompositorLayout(env, java_obj_.obj());
137 } 129 }
138 130
139 void ContentViewRenderView::OnSwapBuffersCompleted(int pending_swap_buffers) { 131 void ContentViewRenderView::OnSwapBuffersCompleted(int pending_swap_buffers) {
140 JNIEnv* env = base::android::AttachCurrentThread(); 132 JNIEnv* env = base::android::AttachCurrentThread();
141 Java_ContentViewRenderView_onSwapBuffersCompleted(env, java_obj_.obj()); 133 Java_ContentViewRenderView_onSwapBuffersCompleted(env, java_obj_.obj());
142 } 134 }
143 135
144 void ContentViewRenderView::InitCompositor() { 136 void ContentViewRenderView::InitCompositor() {
145 if (!compositor_) 137 if (!compositor_)
146 compositor_.reset(Compositor::Create(this, root_window_)); 138 compositor_.reset(Compositor::Create(this, root_window_));
147 } 139 }
148 } // namespace content 140 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698