draw_sw.h 2.0 KB

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