0
Files
src/content/browser/android/content_readback_handler.h
siva.gunturi 59e171f76d Support error handling for Surface read-backs.
CopyFromCompositingSurface, CopyFromBackingStore
return callbacks with a result value of boolean
(pass or fail) and the resultant SkBitmap.But in
few cases for example, we want to request output in
a differnt format say RGB_565. It depends on the
hardware whether it supports that texture format for
readback, so on few systems CopyFromCompositingSurface
may fail and return false status, with empty SkBitmap.

The user of the api should be able to know the exact
reason of failure,(there can be a different reasons)
to take appropriate action,say in the above case
FORMAT_NOT_SUPPORTED.

1.This patch defines enum to support
possible failure reasons.

2.Changes the signature of readback callback
by removing boolean and passing ReadbackResponse enum.

BUG=430871

Review URL: https://codereview.chromium.org/593503003

Cr-Commit-Position: refs/heads/master@{#304244}
2014-11-14 19:06:19 +00:00

64 lines
2.0 KiB
C++

// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_ANDROID_CONTENT_READBACK_HANDLER_H_
#define CONTENT_BROWSER_ANDROID_CONTENT_READBACK_HANDLER_H_
#include <jni.h>
#include "base/android/jni_weak_ref.h"
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/readback_types.h"
class SkBitmap;
namespace cc {
class CopyOutputResult;
}
namespace content {
// Native side of the ContentReadbackHandler.java, which issues content
// readbacks from the Java side.
class ContentReadbackHandler {
public:
// Registers the JNI methods for ContentViewRender.
static bool RegisterContentReadbackHandler(JNIEnv* env);
// Methods called from Java via JNI -----------------------------------------
ContentReadbackHandler(JNIEnv* env, jobject obj);
void Destroy(JNIEnv* env, jobject obj);
void GetContentBitmap(JNIEnv* env,
jobject obj,
jint readback_id,
jfloat scale,
jobject config,
jfloat x,
jfloat y,
jfloat width,
jfloat height,
jobject content_view_core);
void GetCompositorBitmap(JNIEnv* env,
jobject obj,
jint readback_id,
jlong native_window_android);
private:
virtual ~ContentReadbackHandler();
void OnFinishReadback(int readback_id,
const SkBitmap& bitmap,
ReadbackResponse response);
base::android::ScopedJavaGlobalRef<jobject> java_obj_;
base::WeakPtrFactory<ContentReadbackHandler> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ContentReadbackHandler);
};
} // namespace content
#endif // CONTENT_BROWSER_ANDROID_CONTENT_READBACK_HANDLER_H_