Add libhwui, to hardware accelerate the Canvas API using OpenGL ES 2.0.

This is the initial checkin to setup the library and turn on OEGL ES 2.0
in ViewRoot, not a functional renderer.

Change-Id: I6655c54166e2967da2e21e7d6dcfba78bf113b44
This commit is contained in:
Romain Guy
2010-06-16 18:44:05 -07:00
parent 5e81e5b96b
commit e4d011201c
12 changed files with 946 additions and 27 deletions

View File

@@ -0,0 +1,542 @@
/*
* Copyright (C) 2010 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.
*/
package android.view;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.DrawFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Picture;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
import javax.microedition.khronos.opengles.GL;
/**
* An implementation of Canvas on top of OpenGL ES 2.0.
*/
@SuppressWarnings({"deprecation"})
class GLES20Canvas extends Canvas {
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
private final GL mGl;
private final boolean mOpaque;
private final int mRenderer;
private int mWidth;
private int mHeight;
///////////////////////////////////////////////////////////////////////////
// Constructors
///////////////////////////////////////////////////////////////////////////
GLES20Canvas(GL gl, boolean translucent) {
mGl = gl;
mOpaque = !translucent;
mRenderer = nCreateRenderer();
}
private native int nCreateRenderer();
@Override
protected void finalize() throws Throwable {
try {
super.finalize();
} finally {
nDestroyRenderer(mRenderer);
}
}
private native void nDestroyRenderer(int renderer);
///////////////////////////////////////////////////////////////////////////
// Canvas management
///////////////////////////////////////////////////////////////////////////
@Override
public boolean isHardwareAccelerated() {
return true;
}
@Override
public GL getGL() {
throw new UnsupportedOperationException();
}
@Override
public void setBitmap(Bitmap bitmap) {
throw new UnsupportedOperationException();
}
@Override
public boolean isOpaque() {
return mOpaque;
}
@Override
public int getWidth() {
return mWidth;
}
@Override
public int getHeight() {
return mHeight;
}
///////////////////////////////////////////////////////////////////////////
// Setup
///////////////////////////////////////////////////////////////////////////
@Override
public void setViewport(int width, int height) {
mWidth = width;
mHeight = height;
nSetViewport(mRenderer, width, height);
}
private native void nSetViewport(int renderer, int width, int height);
void onPreDraw() {
nPrepare(mRenderer);
}
private native void nPrepare(int renderer);
///////////////////////////////////////////////////////////////////////////
// Clipping
///////////////////////////////////////////////////////////////////////////
@Override
public boolean clipPath(Path path) {
throw new UnsupportedOperationException();
}
@Override
public boolean clipPath(Path path, Region.Op op) {
throw new UnsupportedOperationException();
}
@Override
public boolean clipRect(float left, float top, float right, float bottom) {
// TODO: Implement
return false;
}
@Override
public boolean clipRect(float left, float top, float right, float bottom, Region.Op op) {
throw new UnsupportedOperationException();
}
@Override
public boolean clipRect(int left, int top, int right, int bottom) {
// TODO: Implement
return false;
}
@Override
public boolean clipRect(Rect rect) {
// TODO: Implement
return false;
}
@Override
public boolean clipRect(Rect rect, Region.Op op) {
throw new UnsupportedOperationException();
}
@Override
public boolean clipRect(RectF rect) {
// TODO: Implement
return false;
}
@Override
public boolean clipRect(RectF rect, Region.Op op) {
throw new UnsupportedOperationException();
}
@Override
public boolean clipRegion(Region region) {
throw new UnsupportedOperationException();
}
@Override
public boolean clipRegion(Region region, Region.Op op) {
throw new UnsupportedOperationException();
}
@Override
public boolean getClipBounds(Rect bounds) {
// TODO: Implement
return false;
}
@Override
public boolean quickReject(float left, float top, float right, float bottom, EdgeType type) {
// TODO: Implement
return false;
}
@Override
public boolean quickReject(Path path, EdgeType type) {
// TODO: Implement
return false;
}
@Override
public boolean quickReject(RectF rect, EdgeType type) {
// TODO: Implement
return false;
}
///////////////////////////////////////////////////////////////////////////
// Transformations
///////////////////////////////////////////////////////////////////////////
@Override
public void translate(float dx, float dy) {
// TODO: Implement
}
@Override
public void skew(float sx, float sy) {
throw new UnsupportedOperationException();
}
@Override
public void rotate(float degrees) {
// TODO: Implement
}
@Override
public void scale(float sx, float sy) {
// TODO: Implement
}
@Override
public void setMatrix(Matrix matrix) {
// TODO: Implement
}
@Override
public void getMatrix(Matrix ctm) {
// TODO: Implement
}
@Override
public void concat(Matrix matrix) {
// TODO: Implement
}
///////////////////////////////////////////////////////////////////////////
// State management
///////////////////////////////////////////////////////////////////////////
@Override
public int save() {
// TODO: Implement
return 0;
}
@Override
public int save(int saveFlags) {
// TODO: Implement
return 0;
}
@Override
public int saveLayer(RectF bounds, Paint paint, int saveFlags) {
// TODO: Implement
return 0;
}
@Override
public int saveLayer(float left, float top, float right, float bottom, Paint paint,
int saveFlags) {
// TODO: Implement
return 0;
}
@Override
public int saveLayerAlpha(RectF bounds, int alpha, int saveFlags) {
// TODO: Implement
return 0;
}
@Override
public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha,
int saveFlags) {
// TODO: Implement
return 0;
}
@Override
public void restore() {
// TODO: Implement
}
@Override
public void restoreToCount(int saveCount) {
// TODO: Implement
}
@Override
public int getSaveCount() {
// TODO: Implement
return 0;
}
///////////////////////////////////////////////////////////////////////////
// Filtering
///////////////////////////////////////////////////////////////////////////
@Override
public void setDrawFilter(DrawFilter filter) {
throw new UnsupportedOperationException();
}
@Override
public DrawFilter getDrawFilter() {
throw new UnsupportedOperationException();
}
///////////////////////////////////////////////////////////////////////////
// Drawing
///////////////////////////////////////////////////////////////////////////
@Override
public void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter,
Paint paint) {
throw new UnsupportedOperationException();
}
@Override
public void drawARGB(int a, int r, int g, int b) {
// TODO: Implement
}
@Override
public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) {
// TODO: Implement
}
@Override
public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) {
// TODO: Implement
}
@Override
public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) {
// TODO: Implement
}
@Override
public void drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) {
// TODO: Implement
}
@Override
public void drawBitmap(int[] colors, int offset, int stride, float x, float y,
int width, int height, boolean hasAlpha, Paint paint) {
// TODO: Implement
}
@Override
public void drawBitmap(int[] colors, int offset, int stride, int x, int y,
int width, int height, boolean hasAlpha, Paint paint) {
// TODO: Implement
}
@Override
public void drawBitmapMesh(Bitmap bitmap, int meshWidth, int meshHeight, float[] verts,
int vertOffset, int[] colors, int colorOffset, Paint paint) {
throw new UnsupportedOperationException();
}
@Override
public void drawCircle(float cx, float cy, float radius, Paint paint) {
throw new UnsupportedOperationException();
}
@Override
public void drawColor(int color) {
// TODO: Implement
}
@Override
public void drawColor(int color, PorterDuff.Mode mode) {
// TODO: Implement
}
@Override
public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) {
// TODO: Implement
}
@Override
public void drawLines(float[] pts, int offset, int count, Paint paint) {
// TODO: Implement
}
@Override
public void drawLines(float[] pts, Paint paint) {
// TODO: Implement
}
@Override
public void drawOval(RectF oval, Paint paint) {
throw new UnsupportedOperationException();
}
@Override
public void drawPaint(Paint paint) {
// TODO: Implement
}
@Override
public void drawPath(Path path, Paint paint) {
throw new UnsupportedOperationException();
}
@Override
public void drawPicture(Picture picture) {
throw new UnsupportedOperationException();
}
@Override
public void drawPicture(Picture picture, Rect dst) {
throw new UnsupportedOperationException();
}
@Override
public void drawPicture(Picture picture, RectF dst) {
throw new UnsupportedOperationException();
}
@Override
public void drawPoint(float x, float y, Paint paint) {
// TODO: Implement
}
@Override
public void drawPoints(float[] pts, int offset, int count, Paint paint) {
// TODO: Implement
}
@Override
public void drawPoints(float[] pts, Paint paint) {
// TODO: Implement
}
@Override
public void drawPosText(char[] text, int index, int count, float[] pos, Paint paint) {
throw new UnsupportedOperationException();
}
@Override
public void drawPosText(String text, float[] pos, Paint paint) {
throw new UnsupportedOperationException();
}
@Override
public void drawRect(float left, float top, float right, float bottom, Paint paint) {
// TODO: Implement
}
@Override
public void drawRect(Rect r, Paint paint) {
// TODO: Implement
}
@Override
public void drawRect(RectF rect, Paint paint) {
// TODO: Implement
}
@Override
public void drawRGB(int r, int g, int b) {
// TODO: Implement
}
@Override
public void drawRoundRect(RectF rect, float rx, float ry, Paint paint) {
throw new UnsupportedOperationException();
}
@Override
public void drawText(char[] text, int index, int count, float x, float y, Paint paint) {
// TODO: Implement
}
@Override
public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) {
// TODO: Implement
}
@Override
public void drawText(String text, int start, int end, float x, float y, Paint paint) {
// TODO: Implement
}
@Override
public void drawText(String text, float x, float y, Paint paint) {
// TODO: Implement
}
@Override
public void drawTextOnPath(char[] text, int index, int count, Path path, float hOffset,
float vOffset, Paint paint) {
throw new UnsupportedOperationException();
}
@Override
public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint) {
throw new UnsupportedOperationException();
}
@Override
public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount,
float x, float y, int dir, Paint paint) {
throw new UnsupportedOperationException();
}
@Override
public void drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd,
float x, float y, int dir, Paint paint) {
throw new UnsupportedOperationException();
}
@Override
public void drawVertices(VertexMode mode, int vertexCount, float[] verts, int vertOffset,
float[] texs, int texOffset, int[] colors, int colorOffset, short[] indices,
int indexOffset, int indexCount, Paint paint) {
throw new UnsupportedOperationException();
}
}

View File

@@ -110,15 +110,16 @@ abstract class HardwareRenderer {
* Creates a hardware renderer using OpenGL.
*
* @param glVersion The version of OpenGL to use (1 for OpenGL 1, 11 for OpenGL 1.1, etc.)
* @param translucent True if the surface is translucent, false otherwise
*
* @return A hardware renderer backed by OpenGL.
*/
static HardwareRenderer createGlRenderer(int glVersion) {
static HardwareRenderer createGlRenderer(int glVersion, boolean translucent) {
switch (glVersion) {
case 1:
return new Gl10Renderer();
return new Gl10Renderer(translucent);
case 2:
return new Gl20Renderer();
return new Gl20Renderer(translucent);
}
throw new IllegalArgumentException("Unknown GL version: " + glVersion);
}
@@ -174,10 +175,12 @@ abstract class HardwareRenderer {
GL mGl;
Canvas mCanvas;
int mGlVersion;
final int mGlVersion;
final boolean mTranslucent;
GlRenderer(int glVersion) {
GlRenderer(int glVersion, boolean translucent) {
mGlVersion = glVersion;
mTranslucent = translucent;
}
/**
@@ -362,7 +365,7 @@ abstract class HardwareRenderer {
* @param glVersion
*/
EglConfigChooser getConfigChooser(int glVersion) {
return new ComponentSizeChooser(glVersion, 8, 8, 8, 0, 0, 0);
return new ComponentSizeChooser(glVersion, 8, 8, 8, mTranslucent ? 8 : 0, 0, 0);
}
@Override
@@ -520,13 +523,20 @@ abstract class HardwareRenderer {
* Hardware renderer using OpenGL ES 2.0.
*/
static class Gl20Renderer extends GlRenderer {
Gl20Renderer() {
super(2);
private GLES20Canvas mGlCanvas;
Gl20Renderer(boolean translucent) {
super(2, translucent);
}
@Override
Canvas createCanvas() {
return null;
return mGlCanvas = new GLES20Canvas(mGl, mTranslucent);
}
@Override
void onPreDraw() {
mGlCanvas.onPreDraw();
}
}
@@ -535,8 +545,8 @@ abstract class HardwareRenderer {
*/
@SuppressWarnings({"deprecation"})
static class Gl10Renderer extends GlRenderer {
Gl10Renderer() {
super(1);
Gl10Renderer(boolean translucent) {
super(1, translucent);
}
@Override

View File

@@ -259,17 +259,6 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
mAttachInfo = new View.AttachInfo(sWindowSession, mWindow, this, this);
mViewConfiguration = ViewConfiguration.get(context);
mDensity = context.getResources().getDisplayMetrics().densityDpi;
// Only enable hardware acceleration if we are not in the system process
// The window manager creates ViewRoots to display animated preview windows
// of launching apps and we don't want those to be hardware accelerated
if (Process.myUid() != Process.SYSTEM_UID) {
// Try to enable hardware acceleration if requested
if ((context.getApplicationInfo().flags &
ApplicationInfo.FLAG_HARDWARE_ACCELERATED) != 0) {
mHwRenderer = HardwareRenderer.createGlRenderer(1);
}
}
}
// For debug only
@@ -331,13 +320,15 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
/**
* We have one child
*/
public void setView(View view, WindowManager.LayoutParams attrs,
View panelParentView) {
public void setView(View view, WindowManager.LayoutParams attrs, View panelParentView) {
synchronized (this) {
if (mView == null) {
mView = view;
mWindowAttributes.copyFrom(attrs);
attrs = mWindowAttributes;
enableHardwareAcceleration(view, attrs);
if (view instanceof RootViewSurfaceTaker) {
mSurfaceHolderCallback =
((RootViewSurfaceTaker)view).willYouTakeTheSurface();
@@ -459,6 +450,20 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
}
}
private void enableHardwareAcceleration(View view, WindowManager.LayoutParams attrs) {
// Only enable hardware acceleration if we are not in the system process
// The window manager creates ViewRoots to display animated preview windows
// of launching apps and we don't want those to be hardware accelerated
if (Process.myUid() != Process.SYSTEM_UID) {
// Try to enable hardware acceleration if requested
if ((view.getContext().getApplicationInfo().flags &
ApplicationInfo.FLAG_HARDWARE_ACCELERATED) != 0) {
final boolean translucent = attrs.format != PixelFormat.OPAQUE;
mHwRenderer = HardwareRenderer.createGlRenderer(2, translucent);
}
}
}
public View getView() {
return mView;
}

View File

@@ -48,6 +48,8 @@ LOCAL_SRC_FILES:= \
android_view_InputQueue.cpp \
android_view_InputTarget.cpp \
android_view_KeyEvent.cpp \
android_view_HardwareRenderer.cpp \
android_view_GLES20Canvas.cpp \
android_view_MotionEvent.cpp \
android_text_AndroidCharacter.cpp \
android_text_AndroidBidi.cpp \
@@ -136,12 +138,12 @@ LOCAL_SRC_FILES:= \
android_backup_BackupDataInput.cpp \
android_backup_BackupDataOutput.cpp \
android_backup_FileBackupHelperBase.cpp \
android_backup_BackupHelperDispatcher.cpp \
android_view_HardwareRenderer.cpp \
android_backup_BackupHelperDispatcher.cpp
LOCAL_C_INCLUDES += \
$(JNI_H_INCLUDE) \
$(LOCAL_PATH)/android/graphics \
$(LOCAL_PATH)/../../libs/hwui \
$(call include-path-for, bluedroid) \
$(call include-path-for, libhardware)/hardware \
$(call include-path-for, libhardware_legacy)/hardware_legacy \
@@ -171,6 +173,7 @@ LOCAL_SHARED_LIBRARIES := \
libbinder \
libnetutils \
libui \
libhwui \
libsurfaceflinger_client \
libcamera_client \
libskiagl \

View File

@@ -114,6 +114,7 @@ extern int register_android_graphics_Xfermode(JNIEnv* env);
extern int register_android_graphics_PixelFormat(JNIEnv* env);
extern int register_com_android_internal_graphics_NativeUtils(JNIEnv *env);
extern int register_android_view_Display(JNIEnv* env);
extern int register_android_view_GLES20Canvas(JNIEnv* env);
extern int register_android_view_HardwareRenderer(JNIEnv* env);
extern int register_android_view_Surface(JNIEnv* env);
extern int register_android_view_ViewRoot(JNIEnv* env);
@@ -1213,6 +1214,7 @@ static const RegJNIRec gRegJNI[] = {
REG_JNI(register_android_nio_utils),
REG_JNI(register_android_graphics_PixelFormat),
REG_JNI(register_android_graphics_Graphics),
REG_JNI(register_android_view_GLES20Canvas),
REG_JNI(register_android_view_HardwareRenderer),
REG_JNI(register_android_view_Surface),
REG_JNI(register_android_view_ViewRoot),

View File

@@ -0,0 +1,71 @@
/*
* Copyright (C) 2010 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.
*/
#include "jni.h"
#include <nativehelper/JNIHelp.h>
#include <android_runtime/AndroidRuntime.h>
#include <UIOpenGLRenderer.h>
#define UI ((UIOpenGLRenderer*) renderer)
namespace android {
// ----------------------------------------------------------------------------
// Constructors
// ----------------------------------------------------------------------------
static UIOpenGLRenderer* android_view_GLES20Renderer_createRenderer(JNIEnv* env, jobject canvas) {
return new UIOpenGLRenderer;
}
static void android_view_GLES20Renderer_destroyRenderer(JNIEnv* env, jobject canvas, jint renderer) {
delete UI;
}
// ----------------------------------------------------------------------------
// Setup
// ----------------------------------------------------------------------------
static void android_view_GLES20Renderer_setViewport(JNIEnv* env, jobject canvas, jint renderer,
jint width, jint height) {
UI->setViewport(width, height);
}
static void android_view_GLES20Renderer_prepare(JNIEnv* env, jobject canvas, jint renderer) {
UI->prepare();
}
// ----------------------------------------------------------------------------
// JNI Glue
// ----------------------------------------------------------------------------
const char* const kClassPathName = "android/view/GLES20Canvas";
static JNINativeMethod gMethods[] = {
{ "nCreateRenderer", "()I", (void*) android_view_GLES20Renderer_createRenderer },
{ "nDestroyRenderer", "(I)V", (void*) android_view_GLES20Renderer_destroyRenderer },
{ "nSetViewport", "(III)V", (void*) android_view_GLES20Renderer_setViewport },
{ "nPrepare", "(I)V", (void*) android_view_GLES20Renderer_prepare },
};
int register_android_view_GLES20Canvas(JNIEnv* env) {
return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods));
}
};

12
libs/hwui/Android.mk Normal file
View File

@@ -0,0 +1,12 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
UIOpenGLRenderer.cpp
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_SHARED_LIBRARIES := libcutils libutils libGLESv2
LOCAL_MODULE:= libhwui
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)

View File

190
libs/hwui/NOTICE Normal file
View File

@@ -0,0 +1,190 @@
Copyright (c) 2005-2008, 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.
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.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2010 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.
*/
#define LOG_TAG "UIOpenGLRenderer"
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <utils/Errors.h>
#include <utils/Log.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include "UIOpenGLRenderer.h"
namespace android {
UIOpenGLRenderer::UIOpenGLRenderer() {
LOGD("Create UIOpenGLRenderer");
}
UIOpenGLRenderer::~UIOpenGLRenderer() {
LOGD("Destroy UIOpenGLRenderer");
}
void UIOpenGLRenderer::setViewport(int width, int height) {
LOGD("Setting viewport");
}
void UIOpenGLRenderer::prepare() {
LOGD("Prepare");
}
}; // namespace android

View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2010 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.
*/
#ifndef ANDROID_UI_OPENGL_RENDERER_H
#define ANDROID_UI_OPENGL_RENDERER_H
namespace android {
class UIOpenGLRenderer {
public:
UIOpenGLRenderer();
~UIOpenGLRenderer();
void setViewport(int width, int height);
void prepare();
};
}; // namespace android
#endif // ANDROID_UI_OPENGL_RENDERER_H

View File

@@ -17,7 +17,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.test.hwui">
<application android:label="HwUi">
<application
android:label="HwUi"
android:hardwareAccelerated="true">
<activity android:name="HwUiActivity">
<intent-filter>