Browse Source

Android: disable hardware acceleration on ComponentPeerView level rather than application level to allow embedded views to use hardware acceleration if needed.

This circumvents the issue in web view scrolling that happens only when using software rendering (a potential bug in chromium).
tags/2021-05-28
Lukasz Kozakiewicz 8 years ago
parent
commit
87831624cb
3 changed files with 25 additions and 2 deletions
  1. +19
    -1
      extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h
  2. +2
    -0
      modules/juce_core/native/java/JuceAppActivity.java
  3. +4
    -1
      modules/juce_gui_extra/native/juce_AndroidViewComponent.cpp

+ 19
- 1
extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Android.h View File

@@ -1606,9 +1606,14 @@ private:
}
if (androidMinimumSDK.get().getIntValue() >= 11)
app->setAttribute ("android:hardwareAccelerated", "false"); // (using the 2D acceleration slows down openGL)
{
if (! app->hasAttribute ("android:hardwareAccelerated"))
app->setAttribute ("android:hardwareAccelerated", "false"); // (using the 2D acceleration slows down openGL)
}
else
{
app->removeAttribute ("android:hardwareAccelerated");
}
auto* act = getOrCreateChildWithName (*app, "activity");
@@ -1652,6 +1657,19 @@ private:
setAttributeIfNotPresent (*act, "android:launchMode", "singleTask");
// Using the 2D acceleration slows down OpenGL. We *do* enable it here for the activity though, and we disable it
// in each ComponentPeerView instead. This way any embedded native views, which are not children of ComponentPeerView,
// can still use hardware acceleration if needed (e.g. web view).
if (androidMinimumSDK.get().getIntValue() >= 11)
{
if (! act->hasAttribute ("android:hardwareAccelerated"))
act->setAttribute ("android:hardwareAccelerated", "true"); // (using the 2D acceleration slows down openGL)
}
else
{
act->removeAttribute ("android:hardwareAccelerated");
}
auto* intent = getOrCreateChildWithName (*act, "intent-filter");
auto* action = getOrCreateChildWithName (*intent, "action");


+ 2
- 0
modules/juce_core/native/java/JuceAppActivity.java View File

@@ -568,6 +568,8 @@ public class JuceAppActivity extends Activity
colorMatrix.set (colorTransform);
paint.setColorFilter (new ColorMatrixColorFilter (colorMatrix));
setLayerType (View.LAYER_TYPE_NONE, null);
}
//==============================================================================


+ 4
- 1
modules/juce_gui_extra/native/juce_AndroidViewComponent.cpp View File

@@ -106,8 +106,11 @@ private:
{
jobject peerView = (jobject) currentPeer->getNativeHandle();
auto* env = getEnv();
auto parentView = env->CallObjectMethod (peerView, AndroidView.getParent);
// Assuming a parent is always of ViewGroup type
getEnv()->CallVoidMethod (peerView, AndroidViewGroup.addView, view.get());
env->CallVoidMethod (parentView, AndroidViewGroup.addView, view.get());
componentMovedOrResized (false, false);
}


Loading…
Cancel
Save