Home | History | Annotate | Download | only in android
      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 "base/android/jni_helper.h"
      9 #include "base/logging.h"
     10 #include "base/memory/scoped_ptr.h"
     11 #include "base/memory/weak_ptr.h"
     12 #include "content/public/browser/android/compositor_client.h"
     13 #include "ui/gfx/native_widget_types.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(JNIEnv* env,
     24                         jobject obj,
     25                         gfx::NativeWindow root_window);
     26 
     27   // Methods called from Java via JNI -----------------------------------------
     28   void Destroy(JNIEnv* env, jobject obj);
     29   void SetCurrentContentView(JNIEnv* env, jobject obj, int native_content_view);
     30   void SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface);
     31   void SurfaceDestroyed(JNIEnv* env, jobject obj);
     32   void SurfaceSetSize(JNIEnv* env, jobject obj, jint width, jint height);
     33   jboolean Composite(JNIEnv* env, jobject obj);
     34   jboolean CompositeToBitmap(JNIEnv* env, jobject obj, jobject java_bitmap);
     35 
     36   // CompositorClient ---------------------------------------------------------
     37   virtual void ScheduleComposite() OVERRIDE;
     38   virtual void OnSwapBuffersPosted() OVERRIDE;
     39   virtual void OnSwapBuffersCompleted() OVERRIDE;
     40 
     41  private:
     42   virtual ~ContentViewRenderView();
     43 
     44   void InitCompositor();
     45 
     46   bool buffers_swapped_during_composite_;
     47 
     48   base::android::ScopedJavaGlobalRef<jobject> java_obj_;
     49 
     50   scoped_ptr<content::Compositor> compositor_;
     51 
     52   gfx::NativeWindow root_window_;
     53 
     54   DISALLOW_COPY_AND_ASSIGN(ContentViewRenderView);
     55 };
     56 
     57 
     58 
     59 }
     60 
     61 #endif  // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_RENDER_VIEW_H_
     62