diff options
author | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-25 01:27:04 +0000 |
---|---|---|
committer | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-25 01:27:04 +0000 |
commit | 441c33c09aaaf44500293205c5ae5fce7a8585f5 (patch) | |
tree | 80b94a0a1b5b36806b923e9d183f7394dd9cba18 /android_webview/public/browser | |
parent | 931989fdce2fae066fb260e21b53f66676a7f678 (diff) | |
download | chromium_src-441c33c09aaaf44500293205c5ae5fce7a8585f5.zip chromium_src-441c33c09aaaf44500293205c5ae5fce7a8585f5.tar.gz chromium_src-441c33c09aaaf44500293205c5ae5fce7a8585f5.tar.bz2 |
Define public inteface for accessing Canvas pixels
The embedder can supply implementations of the declared functions, allowing
the software draw path to have direct access to the pixels underlying
the java Canvas object from native code.
BUG=
Review URL: https://chromiumcodereview.appspot.com/11665020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174592 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/public/browser')
-rw-r--r-- | android_webview/public/browser/draw_sw.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/android_webview/public/browser/draw_sw.h b/android_webview/public/browser/draw_sw.h new file mode 100644 index 0000000..e2e1dbf --- /dev/null +++ b/android_webview/public/browser/draw_sw.h @@ -0,0 +1,44 @@ +// Copyright (c) 2012 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 ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ +#define ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ + +#include <jni.h> +#include <stddef.h> + +#ifndef __cplusplus +#error "Can't mix C and C++ when using jni.h" +#endif + +// Holds the information required to implement the SW draw to system canvas. +struct AwPixelInfo { + int config; // In SkBitmap::Config format. + int width; // In pixels. + int height; // In pixels. + int row_bytes; // Number of bytes from start of one line to next. + void* pixels; // The pixels, all (height * row_bytes) of them. + float matrix[9]; // The matrix currently in effect on the canvas. + void* clip_region; // Flattened clip region. + size_t clip_region_size; // Number of bytes in |clip_region|. +}; + +// Function that can be called to fish out the underlying native pixel data +// from a Java canvas object, for optimized rendering path. +// Returns the pixel info on success, which must be freed via a call to +// AwReleasePixelsFunction, or NULL. +typedef AwPixelInfo* (AwAccessPixelsFunction)(JNIEnv* env, jobject canvas); + +// Must be called to balance every *successful* call to AwAccessPixelsFunction +// (i.e. that returned true). +typedef void (AwReleasePixelsFunction)(AwPixelInfo* pixels); + +// "vtable" for the functions declared in this file. An instance must be set via +// AwContents.setAwDrawSWFunctionTable +struct AwDrawSWFunctionTable { + AwAccessPixelsFunction* access_pixels; + AwReleasePixelsFunction* release_pixels; +}; + +#endif // ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ |