Home | History | Annotate | Download | only in android
      1 // Copyright 2014 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_READBACK_HANDLER_H_
      6 #define CONTENT_BROWSER_ANDROID_CONTENT_READBACK_HANDLER_H_
      7 
      8 #include <jni.h>
      9 
     10 #include "base/android/jni_weak_ref.h"
     11 #include "base/callback.h"
     12 #include "base/memory/weak_ptr.h"
     13 
     14 class SkBitmap;
     15 
     16 namespace cc {
     17 class CopyOutputResult;
     18 }
     19 
     20 namespace content {
     21 
     22 // Native side of the ContentReadbackHandler.java, which issues content
     23 // readbacks from the Java side.
     24 class ContentReadbackHandler {
     25  public:
     26   // Registers the JNI methods for ContentViewRender.
     27   static bool RegisterContentReadbackHandler(JNIEnv* env);
     28 
     29   // Methods called from Java via JNI -----------------------------------------
     30   ContentReadbackHandler(JNIEnv* env, jobject obj);
     31   void Destroy(JNIEnv* env, jobject obj);
     32   void GetContentBitmap(JNIEnv* env,
     33                         jobject obj,
     34                         jint readback_id,
     35                         jfloat scale,
     36                         jobject config,
     37                         jfloat x,
     38                         jfloat y,
     39                         jfloat width,
     40                         jfloat height,
     41                         jobject content_view_core);
     42   void GetCompositorBitmap(JNIEnv* env,
     43                            jobject obj,
     44                            jint readback_id,
     45                            jlong native_window_android);
     46 
     47  private:
     48   virtual ~ContentReadbackHandler();
     49 
     50   void OnFinishReadback(int readback_id,
     51                         bool success,
     52                         const SkBitmap& bitmap);
     53 
     54   base::android::ScopedJavaGlobalRef<jobject> java_obj_;
     55   base::WeakPtrFactory<ContentReadbackHandler> weak_factory_;
     56 
     57   DISALLOW_COPY_AND_ASSIGN(ContentReadbackHandler);
     58 };
     59 
     60 }  // namespace content
     61 
     62 #endif  // CONTENT_BROWSER_ANDROID_CONTENT_READBACK_HANDLER_H_
     63