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 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_RENDER_VIEW_H_ 6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_RENDER_VIEW_H_ 7 8 #include <jni.h> 9 10 #include "base/logging.h" 11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/weak_ptr.h" 13 #include "content/public/browser/android/compositor_client.h" 14 15 namespace content { 16 class Compositor; 17 18 class ContentViewRenderView : public CompositorClient { 19 public: 20 // Registers the JNI methods for ContentViewRender. 21 static bool RegisterContentViewRenderView(JNIEnv* env); 22 23 ContentViewRenderView(); 24 25 // -------------------------------------------------------------------------- 26 // Methods called from Java via JNI 27 // -------------------------------------------------------------------------- 28 static jint Init(JNIEnv* env, jclass clazz); 29 void Destroy(JNIEnv* env, jobject obj); 30 void SetCurrentContentView(JNIEnv* env, jobject obj, int native_content_view); 31 void SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface); 32 void SurfaceDestroyed(JNIEnv* env, jobject obj); 33 void SurfaceSetSize(JNIEnv* env, jobject obj, jint width, jint height); 34 35 private: 36 friend class base::RefCounted<ContentViewRenderView>; 37 virtual ~ContentViewRenderView(); 38 39 // CompositorClient implementation. 40 virtual void ScheduleComposite() OVERRIDE; 41 42 void InitCompositor(); 43 void Composite(); 44 45 scoped_ptr<content::Compositor> compositor_; 46 bool scheduled_composite_; 47 48 base::WeakPtrFactory<ContentViewRenderView> weak_factory_; 49 50 // Note that this class does not call back to Java and as a result does not 51 // have a reference to its Java object. 52 53 DISALLOW_COPY_AND_ASSIGN(ContentViewRenderView); 54 }; 55 56 57 58 } 59 60 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_RENDER_VIEW_H_ 61