|
4 | 4 |
|
5 | 5 | #include "render_handler.h" |
6 | 6 |
|
| 7 | +#include <vector> |
| 8 | + |
7 | 9 | #include "client_handler.h" |
8 | 10 | #include "jni_util.h" |
9 | 11 |
|
@@ -305,6 +307,55 @@ void RenderHandler::OnAcceleratedPaint(CefRefPtr<CefBrowser> browser, |
305 | 307 | SetJNIFieldInt(env, cls, jpaintInfo, "width", viewRect.width); |
306 | 308 | SetJNIFieldInt(env, cls, jpaintInfo, "height", viewRect.height); |
307 | 309 |
|
| 310 | +#if defined(OS_LINUX) |
| 311 | + SetJNIFieldInt(env, cls, jpaintInfo, "plane_count", info.plane_count); |
| 312 | + SetJNIFieldLong(env, cls, jpaintInfo, "modifier", |
| 313 | + static_cast<jlong>(info.modifier)); |
| 314 | + |
| 315 | + const int plane_count = info.plane_count; |
| 316 | + if (plane_count > 0) { |
| 317 | + std::vector<jint> fds(plane_count); |
| 318 | + std::vector<jint> strides(plane_count); |
| 319 | + std::vector<jlong> offsets(plane_count); |
| 320 | + std::vector<jlong> sizes(plane_count); |
| 321 | + |
| 322 | + for (int i = 0; i < plane_count; ++i) { |
| 323 | + fds[i] = info.planes[i].fd; |
| 324 | + strides[i] = static_cast<jint>(info.planes[i].stride); |
| 325 | + offsets[i] = static_cast<jlong>(info.planes[i].offset); |
| 326 | + sizes[i] = static_cast<jlong>(info.planes[i].size); |
| 327 | + } |
| 328 | + |
| 329 | + jclass paintInfoClass = cls.get(); |
| 330 | + jfieldID fdsField = env->GetFieldID(paintInfoClass, "plane_fds", "[I"); |
| 331 | + jfieldID stridesField = env->GetFieldID(paintInfoClass, "plane_strides", "[I"); |
| 332 | + jfieldID offsetsField = env->GetFieldID(paintInfoClass, "plane_offsets", "[J"); |
| 333 | + jfieldID sizesField = env->GetFieldID(paintInfoClass, "plane_sizes", "[J"); |
| 334 | + |
| 335 | + if (fdsField && stridesField && offsetsField && sizesField) { |
| 336 | + jintArray fdsArray = env->NewIntArray(plane_count); |
| 337 | + jintArray stridesArray = env->NewIntArray(plane_count); |
| 338 | + jlongArray offsetsArray = env->NewLongArray(plane_count); |
| 339 | + jlongArray sizesArray = env->NewLongArray(plane_count); |
| 340 | + |
| 341 | + if (fdsArray && stridesArray && offsetsArray && sizesArray) { |
| 342 | + env->SetIntArrayRegion(fdsArray, 0, plane_count, fds.data()); |
| 343 | + env->SetIntArrayRegion(stridesArray, 0, plane_count, strides.data()); |
| 344 | + env->SetLongArrayRegion(offsetsArray, 0, plane_count, offsets.data()); |
| 345 | + env->SetLongArrayRegion(sizesArray, 0, plane_count, sizes.data()); |
| 346 | + |
| 347 | + env->SetObjectField(jpaintInfo.get(), fdsField, fdsArray); |
| 348 | + env->SetObjectField(jpaintInfo.get(), stridesField, stridesArray); |
| 349 | + env->SetObjectField(jpaintInfo.get(), offsetsField, offsetsArray); |
| 350 | + env->SetObjectField(jpaintInfo.get(), sizesField, sizesArray); |
| 351 | + } |
| 352 | + } |
| 353 | + } |
| 354 | +#else |
| 355 | + SetJNIFieldInt(env, cls, jpaintInfo, "plane_count", 0); |
| 356 | + SetJNIFieldLong(env, cls, jpaintInfo, "modifier", 0); |
| 357 | +#endif |
| 358 | + |
308 | 359 | JNI_CALL_VOID_METHOD(env, handle_, "onAcceleratedPaint", |
309 | 360 | "(Lorg/cef/browser/CefBrowser;Z[Ljava/awt/" |
310 | 361 | "Rectangle;Lorg/cef/handler/CefAcceleratedPaintInfo;)V", |
|
0 commit comments