| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ | 5 #ifndef ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ |
| 6 #define ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ | 6 #define ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| 11 #ifndef __cplusplus | 11 #ifndef __cplusplus |
| 12 #error "Can't mix C and C++ when using jni.h" | 12 #error "Can't mix C and C++ when using jni.h" |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 class SkPicture; | 15 class SkPicture; |
| 16 | 16 |
| 17 static const int kAwPixelInfoVersion = 2; | 17 static const int kAwPixelInfoVersion = 3; |
| 18 | 18 |
| 19 // Values of the AwPixelInfo::config field. | 19 // Values of the AwPixelInfo::config field. |
| 20 enum AwPixelConfig { | 20 enum AwPixelConfig { |
| 21 AwConfig_RGB_565 = 4, | 21 AwConfig_RGB_565 = 4, |
| 22 AwConfig_ARGB_4444 = 5, | 22 AwConfig_ARGB_4444 = 5, |
| 23 AwConfig_ARGB_8888 = 6, | 23 AwConfig_ARGB_8888 = 6, |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 struct AwBitmapInfo { |
| 27 int x, y; // Position of this bitmap in the canvas. |
| 28 int config; // |pixel| format: a value from AwPixelConfig. |
| 29 int width; // In pixels. |
| 30 int height; // In pixels. |
| 31 int row_bytes; // Number of bytes from start of one line to next. |
| 32 void* pixels; // The pixels, all (height * row_bytes) of them. |
| 33 }; |
| 34 |
| 26 // Holds the information required to implement the SW draw to system canvas. | 35 // Holds the information required to implement the SW draw to system canvas. |
| 27 struct AwPixelInfo { | 36 struct AwPixelInfo { |
| 28 int version; // The kAwPixelInfoVersion this struct was built with. | 37 int version; // The kAwPixelInfoVersion this struct was built with. |
| 29 int config; // |pixel| format: a value from AwPixelConfig. | |
| 30 int width; // In pixels. | |
| 31 int height; // In pixels. | |
| 32 int row_bytes; // Number of bytes from start of one line to next. | |
| 33 void* pixels; // The pixels, all (height * row_bytes) of them. | |
| 34 // The Matrix and Clip are relative to |pixels|, not the source canvas. | 38 // The Matrix and Clip are relative to |pixels|, not the source canvas. |
| 35 float matrix[9]; // The matrix currently in effect on the canvas. | 39 float matrix[9]; // The matrix currently in effect on the canvas. |
| 36 int clip_rect_count; // Number of rects in |clip_rects|. | 40 int clip_rect_count; // Number of rects in |clip_rects|. |
| 37 int* clip_rects; // Clip area: 4 ints per rect in {x,y,w,h} format. | 41 int* clip_rects; // Clip area: 4 ints per rect in {x,y,w,h} format. |
| 42 int layer_count; // Numer of AwBitmapInfo instance in |layers|. |
| 43 AwBitmapInfo* layers; // The bitmap layers, ordered from root upwards. |
| 38 // NOTE: If you add more members, bump kAwPixelInfoVersion. | 44 // NOTE: If you add more members, bump kAwPixelInfoVersion. |
| 39 }; | 45 }; |
| 40 | 46 |
| 41 // Function that can be called to fish out the underlying native pixel data | 47 // Function that can be called to fish out the underlying native pixel data |
| 42 // from a Java canvas object, for optimized rendering path. | 48 // from a Java canvas object, for optimized rendering path. |
| 43 // Returns the pixel info on success, which must be freed via a call to | 49 // Returns the pixel info on success, which must be freed via a call to |
| 44 // AwReleasePixelsFunction, or NULL. | 50 // AwReleasePixelsFunction, or NULL. |
| 45 typedef AwPixelInfo* (AwAccessPixelsFunction)(JNIEnv* env, jobject canvas); | 51 typedef AwPixelInfo* (AwAccessPixelsFunction)(JNIEnv* env, jobject canvas); |
| 46 | 52 |
| 47 // Must be called to balance every *successful* call to AwAccessPixelsFunction | 53 // Must be called to balance every *successful* call to AwAccessPixelsFunction |
| (...skipping 12 matching lines...) Expand all Loading... |
| 60 // "vtable" for the functions declared in this file. An instance must be set via | 66 // "vtable" for the functions declared in this file. An instance must be set via |
| 61 // AwContents.setAwDrawSWFunctionTable | 67 // AwContents.setAwDrawSWFunctionTable |
| 62 struct AwDrawSWFunctionTable { | 68 struct AwDrawSWFunctionTable { |
| 63 AwAccessPixelsFunction* access_pixels; | 69 AwAccessPixelsFunction* access_pixels; |
| 64 AwReleasePixelsFunction* release_pixels; | 70 AwReleasePixelsFunction* release_pixels; |
| 65 AwCreatePictureFunction* create_picture; | 71 AwCreatePictureFunction* create_picture; |
| 66 AwIsSkiaVersionCompatibleFunction* is_skia_version_compatible; | 72 AwIsSkiaVersionCompatibleFunction* is_skia_version_compatible; |
| 67 }; | 73 }; |
| 68 | 74 |
| 69 #endif // ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ | 75 #endif // ANDROID_WEBVIEW_PUBLIC_BROWSER_DRAW_SW_H_ |
| OLD | NEW |