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 ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ 6 #define ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ 7 8 #include <jni.h> 9 #include <stddef.h> 10 11 #ifndef __cplusplus 12 #error "Can't mix C and C++ when using jni.h" 13 #endif 14 15 class SkCanvasState; 16 class SkPicture; 17 18 static const int kAwPixelInfoVersion = 3; 19 20 // Holds the information required to implement the SW draw to system canvas. 21 struct AwPixelInfo { 22 int version; // The kAwPixelInfoVersion this struct was built with. 23 SkCanvasState* state; // The externalize state in skia format. 24 // NOTE: If you add more members, bump kAwPixelInfoVersion. 25 }; 26 27 // Function that can be called to fish out the underlying native pixel data 28 // from a Java canvas object, for optimized rendering path. 29 // Returns the pixel info on success, which must be freed via a call to 30 // AwReleasePixelsFunction, or NULL. 31 typedef AwPixelInfo* (AwAccessPixelsFunction)(JNIEnv* env, jobject canvas); 32 33 // Must be called to balance every *successful* call to AwAccessPixelsFunction 34 // (i.e. that returned true). 35 typedef void (AwReleasePixelsFunction)(AwPixelInfo* pixels); 36 37 // Called to create an Android Picture object encapsulating a native SkPicture. 38 typedef jobject (AwCreatePictureFunction)(JNIEnv* env, SkPicture* picture); 39 40 // Method that returns the current Skia function. 41 typedef void (SkiaVersionFunction)(int* major, int* minor, int* patch); 42 43 // Called to verify if the Skia versions are compatible. 44 typedef bool (AwIsSkiaVersionCompatibleFunction)(SkiaVersionFunction function); 45 46 static const int kAwDrawSWFunctionTableVersion = 1; 47 48 // "vtable" for the functions declared in this file. An instance must be set via 49 // AwContents.setAwDrawSWFunctionTable 50 struct AwDrawSWFunctionTable { 51 int version; 52 AwAccessPixelsFunction* access_pixels; 53 AwReleasePixelsFunction* release_pixels; 54 }; 55 56 #endif // ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ 57