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