Skip to content

Commit

Permalink
Camera: support devices without accelerated GL
Browse files Browse the repository at this point in the history
Platforms without a GPU such as the msm7x25 (or that for some reason are
missing an EGL library) don't have a stencil, and have limited alpha
capabilities. This patch adds support for those devices via a
"softwareGLOnly" build-time config option.

Change-Id: Iaad6fe3880dc392315bc930050bf53b0561746e3
  • Loading branch information
rmcc committed Oct 23, 2010
1 parent 9dd5e37 commit 0f1ea91
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
26 changes: 26 additions & 0 deletions res/values/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2009, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->

<!-- These resources are around just to allow their values to be customized
for different hardware and product builds. -->
<resources>
<!-- set this to true if the device doesn't have a GPU, or an EGL
library is for some reason unavailable -->
<bool name="softwareGLOnly">false</bool>
</resources>
13 changes: 11 additions & 2 deletions src/com/android/camera/ui/GLRootView.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.android.camera.ui;

import com.android.camera.Util;
import com.android.camera.R;

import android.app.Activity;
import android.content.Context;
Expand Down Expand Up @@ -174,7 +175,11 @@ public void runInGLThread(Runnable runnable) {

private void initialize() {
mFlags |= FLAG_INITIALIZED;
setEGLConfigChooser(8, 8, 8, 8, 0, 4);
if (getResources().getBoolean(R.bool.softwareGLOnly)) {
setEGLConfigChooser(8, 8, 8, 8, 0, 0);
} else {
setEGLConfigChooser(8, 8, 8, 8, 0, 4);
}
getHolder().setFormat(PixelFormat.TRANSLUCENT);
setZOrderOnTop(true);

Expand Down Expand Up @@ -441,7 +446,11 @@ public void onDrawFrame(GL10 gl) {
clearClip();
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_STENCIL_BUFFER_BIT);
gl.glEnable(GL11.GL_BLEND);
gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (getResources().getBoolean(R.bool.softwareGLOnly)) {
gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
} else {
gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
}

mAnimationTime = SystemClock.uptimeMillis();
if (mContentView != null) {
Expand Down
8 changes: 7 additions & 1 deletion src/com/android/camera/ui/PopupWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.android.camera.ui;

import com.android.camera.R;

import android.graphics.Rect;
import android.view.View.MeasureSpec;
import android.view.animation.AlphaAnimation;
Expand Down Expand Up @@ -139,7 +141,11 @@ protected void renderBackground(GLRootView root, GL11 gl) {

gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ZERO);
backup.draw(root, aXoffset, aYoffset, aWidth, aHeight, 1);
gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (getGLRootView().getContext().getResources().getBoolean(R.bool.softwareGLOnly)) {
gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
} else {
gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
}

public void setContent(GLView content) {
Expand Down

0 comments on commit 0f1ea91

Please sign in to comment.