Commit 1cab2921 authored by Derek Sollenberger's avatar Derek Sollenberger Committed by Derek Sollenberger
Browse files

Skia merge (revision 3022)

This CL has companion changes to account for API updates in...
 (1) frameworks/base
 (2) external/webkit

Change-Id: Ibb989e76e8bd24313849f9631dbef42cdef9eb7d
parent d7176fd5

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
BASE_PATH := $(call my-dir)
LOCAL_PATH:= $(call my-dir)
###############################################################################
#
# PROBLEMS WITH SKIA DEBUGGING?? READ THIS...
#
# The debug build results in changes to the Skia headers. This means that those
# using libskia must also be built with the debug version of the Skia headers.
# There are a few scenarios where this comes into play:
#
# (1) You're building debug code that depends on libskia.
# (a) If libskia is built in release, then define SK_RELEASE when building
# your sources.
# (b) If libskia is built with debugging (see step 2), then no changes are
# needed since your sources and libskia have been built with SK_DEBUG.
# (2) You're building libskia in debug mode.
# (a) RECOMMENDED: You can build the entire system in debug mode. Do this by
# updating your buildspec.mk to include TARGET_BUILD_TYPE=debug
# (b) You can update all the users of libskia to define SK_DEBUG when they are
# building their sources.
#
# NOTE: If neither SK_DEBUG or SK_RELEASE are defined then Skia checks NDEBUG to
# determine which build type to use.
###############################################################################
#############################################################
# build the skia+fretype+png+jpeg+zlib+gif+webp library
#
......@@ -25,86 +49,16 @@ endif
LOCAL_SRC_FILES:= \
src/core/Sk64.cpp \
src/core/SkBuffer.cpp \
src/core/SkChunkAlloc.cpp \
src/core/SkCordic.cpp \
src/core/SkDebug.cpp \
src/core/SkFloatBits.cpp \
src/core/SkFontHost.cpp \
src/core/SkPoint.cpp \
src/core/SkRect.cpp \
src/core/SkRegion.cpp \
src/core/SkString.cpp \
src/core/SkUtils.cpp \
src/core/SkFlate.cpp \
src/core/SkMallocPixelRef.cpp \
src/core/SkRegion_rects.cpp \
src/core/SkScalar.cpp \
src/ports/SkDebug_android.cpp \
src/effects/Sk1DPathEffect.cpp \
src/effects/Sk2DPathEffect.cpp \
src/effects/SkAvoidXfermode.cpp \
src/effects/SkBitmapCache.cpp \
src/effects/SkBlurDrawLooper.cpp \
src/effects/SkBlurMask.cpp \
src/effects/SkBlurMaskFilter.cpp \
src/effects/SkColorFilters.cpp \
src/effects/SkColorMatrixFilter.cpp \
src/effects/SkCornerPathEffect.cpp \
src/effects/SkDashPathEffect.cpp \
src/effects/SkDiscretePathEffect.cpp \
src/effects/SkEmbossMask.cpp \
src/effects/SkEmbossMaskFilter.cpp \
src/effects/SkGradientShader.cpp \
src/effects/SkGroupShape.cpp \
src/effects/SkLayerDrawLooper.cpp \
src/effects/SkLayerRasterizer.cpp \
src/effects/SkPaintFlagsDrawFilter.cpp \
src/effects/SkPixelXorXfermode.cpp \
src/effects/SkPorterDuff.cpp \
src/effects/SkRectShape.cpp \
src/effects/SkTableMaskFilter.cpp \
src/effects/SkTransparentShader.cpp \
src/images/bmpdecoderhelper.cpp \
src/images/SkFDStream.cpp \
src/images/SkFlipPixelRef.cpp \
src/images/SkImageDecoder.cpp \
src/images/SkImageDecoder_libbmp.cpp \
src/images/SkImageDecoder_libgif.cpp \
src/images/SkImageDecoder_libjpeg.cpp \
src/images/SkImageDecoder_libpng.cpp \
src/images/SkImageDecoder_libwebp.cpp \
src/images/SkImageDecoder_libico.cpp \
src/images/SkImageDecoder_wbmp.cpp \
src/images/SkImageEncoder.cpp \
src/images/SkImageRef.cpp \
src/images/SkImageRef_GlobalPool.cpp \
src/images/SkImageRefPool.cpp \
src/images/SkJpegUtility.cpp \
src/images/SkBitmapRegionDecoder.cpp \
src/images/SkMovie.cpp \
src/images/SkMovie_gif.cpp \
src/images/SkPageFlipper.cpp \
src/images/SkScaledBitmapSampler.cpp \
src/images/SkCreateRLEPixelRef.cpp \
src/images/SkImageDecoder_Factory.cpp \
src/images/SkImageEncoder_Factory.cpp \
src/ports/FontHostConfiguration_android.cpp \
src/ports/SkFontHost_android.cpp \
src/ports/SkFontHost_gamma.cpp \
src/ports/SkFontHost_FreeType.cpp \
src/ports/SkFontHost_tables.cpp \
src/ports/SkGlobals_global.cpp \
src/ports/SkImageRef_ashmem.cpp \
src/ports/SkOSFile_stdio.cpp \
src/ports/SkTime_Unix.cpp \
src/core/SkAAClip.cpp \
src/core/SkAdvancedTypefaceMetrics.cpp \
src/core/SkAlphaRuns.cpp \
src/core/SkBitmap.cpp \
src/core/SkBitmap_scroll.cpp \
src/core/SkBitmapProcShader.cpp \
src/core/SkBitmapProcState.cpp \
src/core/SkBitmapProcState_matrixProcs.cpp \
src/core/SkBitmapSampler.cpp \
src/core/SkBitmap_scroll.cpp \
src/core/SkBlitMask_D32.cpp \
src/core/SkBlitRow_D16.cpp \
src/core/SkBlitRow_D32.cpp \
src/core/SkBlitRow_D4444.cpp \
......@@ -115,35 +69,43 @@ LOCAL_SRC_FILES:= \
src/core/SkBlitter_ARGB32.cpp \
src/core/SkBlitter_RGB16.cpp \
src/core/SkBlitter_Sprite.cpp \
src/core/SkBuffer.cpp \
src/core/SkCanvas.cpp \
src/core/SkChunkAlloc.cpp \
src/core/SkClampRange.cpp \
src/core/SkClipStack.cpp \
src/core/SkColor.cpp \
src/core/SkColorFilter.cpp \
src/core/SkColorTable.cpp \
src/core/SkComposeShader.cpp \
src/core/SkConcaveToTriangles.cpp \
src/core/SkCordic.cpp \
src/core/SkCubicClipper.cpp \
src/core/SkData.cpp \
src/core/SkDebug.cpp \
src/core/SkDeque.cpp \
src/core/SkDevice.cpp \
src/core/SkDither.cpp \
src/core/SkDraw.cpp \
src/core/SkEdge.cpp \
src/core/SkEdgeBuilder.cpp \
src/core/SkEdgeBuilder.cpp \
src/core/SkEdgeClipper.cpp \
src/core/SkEdge.cpp \
src/core/SkFilterProc.cpp \
src/core/SkFlattenable.cpp \
src/core/SkFloat.cpp \
src/core/SkFloatBits.cpp \
src/core/SkFontHost.cpp \
src/core/SkGeometry.cpp \
src/core/SkGlobals.cpp \
src/core/SkGlyphCache.cpp \
src/core/SkGraphics.cpp \
src/core/SkLineClipper.cpp \
src/core/SkMMapStream.cpp \
src/core/SkMallocPixelRef.cpp \
src/core/SkMask.cpp \
src/core/SkMaskFilter.cpp \
src/core/SkMath.cpp \
src/core/SkMatrix.cpp \
src/core/SkMemory_stdlib.cpp \
src/core/SkMetaData.cpp \
src/core/SkMMapStream.cpp \
src/core/SkPackBits.cpp \
src/core/SkPaint.cpp \
src/core/SkPath.cpp \
......@@ -155,13 +117,18 @@ LOCAL_SRC_FILES:= \
src/core/SkPicturePlayback.cpp \
src/core/SkPictureRecord.cpp \
src/core/SkPixelRef.cpp \
src/core/SkPoint.cpp \
src/core/SkProcSpriteBlitter.cpp \
src/core/SkPtrRecorder.cpp \
src/core/SkQuadClipper.cpp \
src/core/SkRasterClip.cpp \
src/core/SkRasterizer.cpp \
src/core/SkRect.cpp \
src/core/SkRefDict.cpp \
src/core/SkRegion.cpp \
src/core/SkRegion_path.cpp \
src/core/SkScalerContext.cpp \
src/core/SkScalar.cpp \
src/core/SkScalerContext.cpp \
src/core/SkScan.cpp \
src/core/SkScan_AntiPath.cpp \
src/core/SkScan_Antihair.cpp \
......@@ -172,26 +139,101 @@ LOCAL_SRC_FILES:= \
src/core/SkSpriteBlitter_ARGB32.cpp \
src/core/SkSpriteBlitter_RGB16.cpp \
src/core/SkStream.cpp \
src/core/SkString.cpp \
src/core/SkStroke.cpp \
src/core/SkStrokerPriv.cpp \
src/core/SkTSearch.cpp \
src/core/SkTypeface.cpp \
src/core/SkTypefaceCache.cpp \
src/core/SkUnPreMultiply.cpp \
src/core/SkXfermode.cpp \
src/core/SkUtils.cpp \
src/core/SkFlate.cpp \
src/core/SkWriter32.cpp \
src/core/SkXfermode.cpp \
src/effects/Sk1DPathEffect.cpp \
src/effects/Sk2DPathEffect.cpp \
src/effects/SkAvoidXfermode.cpp \
src/effects/SkArithmeticMode.cpp \
src/effects/SkBitmapCache.cpp \
src/effects/SkBlurDrawLooper.cpp \
src/effects/SkBlurImageFilter.cpp \
src/effects/SkBlurMask.cpp \
src/effects/SkBlurMaskFilter.cpp \
src/effects/SkColorFilters.cpp \
src/effects/SkColorMatrixFilter.cpp \
src/effects/SkCornerPathEffect.cpp \
src/effects/SkDashPathEffect.cpp \
src/effects/SkDiscretePathEffect.cpp \
src/effects/SkEffects.cpp \
src/effects/SkEmbossMask.cpp \
src/effects/SkEmbossMaskFilter.cpp \
src/effects/SkGradientShader.cpp \
src/effects/SkGroupShape.cpp \
src/effects/SkKernel33MaskFilter.cpp \
src/effects/SkLayerDrawLooper.cpp \
src/effects/SkLayerRasterizer.cpp \
src/effects/SkPaintFlagsDrawFilter.cpp \
src/effects/SkPixelXorXfermode.cpp \
src/effects/SkPorterDuff.cpp \
src/effects/SkRectShape.cpp \
src/effects/SkTableColorFilter.cpp \
src/effects/SkTableMaskFilter.cpp \
src/effects/SkTestImageFilters.cpp \
src/effects/SkTransparentShader.cpp \
src/images/bmpdecoderhelper.cpp \
src/images/SkBitmapRegionDecoder.cpp \
src/images/SkCreateRLEPixelRef.cpp \
src/images/SkFDStream.cpp \
src/images/SkFlipPixelRef.cpp \
src/images/SkImageDecoder.cpp \
src/images/SkImageDecoder_Factory.cpp \
src/images/SkImageDecoder_libbmp.cpp \
src/images/SkImageDecoder_libgif.cpp \
src/images/SkImageDecoder_libico.cpp \
src/images/SkImageDecoder_libjpeg.cpp \
src/images/SkImageDecoder_libpng.cpp \
src/images/SkImageDecoder_libwebp.cpp \
src/images/SkImageDecoder_wbmp.cpp \
src/images/SkImageEncoder.cpp \
src/images/SkImageEncoder_Factory.cpp \
src/images/SkImageRef.cpp \
src/images/SkImageRefPool.cpp \
src/images/SkImageRef_GlobalPool.cpp \
src/images/SkJpegUtility.cpp \
src/images/SkMovie.cpp \
src/images/SkMovie_gif.cpp \
src/images/SkPageFlipper.cpp \
src/images/SkScaledBitmapSampler.cpp \
src/ports/FontHostConfiguration_android.cpp \
src/ports/SkDebug_android.cpp \
src/ports/SkGlobalInitialization_default.cpp \
src/ports/SkFontHost_FreeType.cpp \
src/ports/SkFontHost_sandbox_none.cpp \
src/ports/SkFontHost_android.cpp \
src/ports/SkFontHost_gamma.cpp \
src/ports/SkFontHost_tables.cpp \
src/ports/SkImageRef_ashmem.cpp \
src/ports/SkMemory_malloc.cpp \
src/ports/SkOSFile_stdio.cpp \
src/ports/SkTime_Unix.cpp \
src/utils/SkBoundaryPatch.cpp \
src/utils/SkCamera.cpp \
src/utils/SkColorMatrix.cpp \
src/utils/SkCubicInterval.cpp \
src/utils/SkCullPoints.cpp \
src/utils/SkDumpCanvas.cpp \
src/utils/SkEGLContext_none.cpp \
src/utils/SkInterpolator.cpp \
src/utils/SkLayer.cpp \
src/utils/SkOSFile.cpp \
src/utils/SkMatrix44.cpp \
src/utils/SkMeshUtils.cpp \
src/utils/SkNinePatch.cpp \
src/utils/SkNWayCanvas.cpp \
src/utils/SkOSFile.cpp \
src/utils/SkParse.cpp \
src/utils/SkParseColor.cpp \
src/utils/SkParsePath.cpp \
src/utils/SkProxyCanvas.cpp \
src/utils/SkSfntUtils.cpp \
src/utils/SkUnitMappers.cpp
ifeq ($(TARGET_ARCH),arm)
......@@ -203,14 +245,15 @@ LOCAL_SRC_FILES += \
endif
LOCAL_SRC_FILES += \
src/opts/SkBlitRow_opts_arm.cpp \
src/opts/SkBitmapProcState_opts_arm.cpp \
src/opts/opts_check_arm.cpp \
src/opts/memset.arm.S
src/opts/memset.arm.S \
src/opts/SkBitmapProcState_opts_arm.cpp \
src/opts/SkBlitRow_opts_arm.cpp
else
LOCAL_SRC_FILES += \
src/opts/SkBlitRow_opts_none.cpp \
src/opts/SkBitmapProcState_opts_none.cpp
src/opts/SkBitmapProcState_opts_none.cpp \
src/opts/SkUtils_opts_none.cpp
endif
# these are for emoji support, needed by webkit
......@@ -235,6 +278,7 @@ LOCAL_STATIC_LIBRARIES := \
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/src/core \
$(LOCAL_PATH)/include/core \
$(LOCAL_PATH)/include/config \
$(LOCAL_PATH)/include/effects \
$(LOCAL_PATH)/include/images \
$(LOCAL_PATH)/include/utils \
......@@ -271,48 +315,65 @@ ifneq ($(ARCH_ARM_HAVE_VFP),true)
endif
ifeq ($(ARCH_ARM_HAVE_NEON),true)
LOCAL_CFLAGS += -D__ARM_HAVE_NEON
LOCAL_CFLAGS += -DGR_ANDROID_BUILD=1
endif
LOCAL_SRC_FILES:= \
gpu/src/GrAllocPool.cpp \
gpu/src/GrAtlas.cpp \
gpu/src/GrClip.cpp \
gpu/src/GrContext.cpp \
gpu/src/GrCreatePathRenderer_none.cpp \
gpu/src/GrDrawTarget.cpp \
gpu/src/android/GrGLDefaultInterface_android.cpp \
gpu/src/GrGLIndexBuffer.cpp \
gpu/src/GrGLInterface.cpp \
gpu/src/GrGLProgram.cpp \
gpu/src/GrGLTexture.cpp \
gpu/src/GrGLVertexBuffer.cpp \
gpu/src/GrGpu.cpp \
gpu/src/GrGpuGLFixed.cpp \
gpu/src/GrGpuFactory.cpp \
gpu/src/GrGLUtil.cpp \
gpu/src/GrGpuGL.cpp \
gpu/src/GrGpuGLShaders.cpp \
gpu/src/GrInOrderDrawBuffer.cpp \
gpu/src/GrMatrix.cpp \
gpu/src/GrMemory.cpp \
gpu/src/GrPathUtils.cpp \
gpu/src/GrRectanizer_fifo.cpp \
gpu/src/GrResource.cpp \
gpu/src/GrTexture.cpp \
gpu/src/GrTextureCache.cpp \
gpu/src/GrTextContext.cpp \
gpu/src/GrTextStrike.cpp \
gpu/src/GrBufferAllocPool.cpp\
gpu/src/GrPathRenderer.cpp \
gpu/src/GrStencil.cpp \
src/gpu/SkGpuCanvas.cpp \
src/gpu/GrPrintf_skia.cpp \
src/gpu/SkGLContext.cpp \
src/gpu/SkGpuCanvas.cpp \
src/gpu/SkGpuDevice.cpp \
src/gpu/SkGr.cpp \
src/gpu/SkGrTexturePixelRef.cpp \
src/gpu/SkGrFontScaler.cpp \
src/gpu/GrPrintf_skia.cpp
src/gpu/SkGrTexturePixelRef.cpp \
src/gpu/SkNullGLContext.cpp \
src/gpu/android/SkNativeGLContext_android.cpp
LOCAL_SRC_FILES += \
src/gpu/GrAAHairLinePathRenderer.cpp \
src/gpu/GrAddPathRenderers_aahairline.cpp \
src/gpu/GrAllocPool.cpp \
src/gpu/GrAtlas.cpp \
src/gpu/GrBufferAllocPool.cpp \
src/gpu/GrClip.cpp \
src/gpu/GrContext.cpp \
src/gpu/GrDefaultPathRenderer.cpp \
src/gpu/GrDrawTarget.cpp \
src/gpu/GrGLCreateNullInterface.cpp \
src/gpu/GrGLDefaultInterface_native.cpp \
src/gpu/GrGLIndexBuffer.cpp \
src/gpu/GrGLInterface.cpp \
src/gpu/GrGLProgram.cpp \
src/gpu/GrGLRenderTarget.cpp \
src/gpu/GrGLSL.cpp \
src/gpu/GrGLStencilBuffer.cpp \
src/gpu/GrGLTexture.cpp \
src/gpu/GrGLUtil.cpp \
src/gpu/GrGLVertexBuffer.cpp \
src/gpu/GrGpu.cpp \
src/gpu/GrGpuFactory.cpp \
src/gpu/GrGpuGL.cpp \
src/gpu/GrGpuGLShaders.cpp \
src/gpu/GrInOrderDrawBuffer.cpp \
src/gpu/GrMatrix.cpp \
src/gpu/GrMemory.cpp \
src/gpu/GrPathRendererChain.cpp \
src/gpu/GrPathRenderer.cpp \
src/gpu/GrPathUtils.cpp \
src/gpu/GrRectanizer.cpp \
src/gpu/GrRenderTarget.cpp \
src/gpu/GrResource.cpp \
src/gpu/GrResourceCache.cpp \
src/gpu/GrStencil.cpp \
src/gpu/GrStencilBuffer.cpp \
src/gpu/GrTesselatedPathRenderer.cpp \
src/gpu/GrTextContext.cpp \
src/gpu/GrTextStrike.cpp \
src/gpu/GrTexture.cpp \
src/gpu/gr_unittests.cpp \
src/gpu/android/GrGLCreateNativeInterface_android.cpp
LOCAL_STATIC_LIBRARIES := libskiatess
LOCAL_SHARED_LIBRARIES := \
libcutils \
libutils \
......@@ -321,12 +382,13 @@ LOCAL_SHARED_LIBRARIES := \
libGLESv2
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/gpu/include \
$(LOCAL_PATH)/gpu/src \
$(LOCAL_PATH)/include/core \
$(LOCAL_PATH)/include/config \
$(LOCAL_PATH)/include/gpu \
$(LOCAL_PATH)/src/core \
frameworks/base/opengl/include/GLES2
$(LOCAL_PATH)/src/gpu \
$(LOCAL_PATH)/third_party/glu \
frameworks/base/opengl/include
LOCAL_LDLIBS += -lpthread
......@@ -335,6 +397,44 @@ LOCAL_MODULE_TAGS := optional
include $(BUILD_STATIC_LIBRARY)
#############################################################
# Build the skia gpu (ganesh) library
#
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_SRC_FILES := \
third_party/glu/libtess/dict.c \
third_party/glu/libtess/geom.c \
third_party/glu/libtess/memalloc.c \
third_party/glu/libtess/mesh.c \
third_party/glu/libtess/normal.c \
third_party/glu/libtess/priorityq.c \
third_party/glu/libtess/render.c \
third_party/glu/libtess/sweep.c \
third_party/glu/libtess/tess.c \
third_party/glu/libtess/tessmono.c
LOCAL_SHARED_LIBRARIES := \
libcutils \
libutils \
libEGL \
libGLESv2
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/third_party/glu \
$(LOCAL_PATH)/third_party/glu/libtess \
frameworks/base/opengl/include
LOCAL_LDLIBS += -lpthread
LOCAL_MODULE:= libskiatess
LOCAL_MODULE_TAGS := optional
include $(BUILD_STATIC_LIBRARY)
#############################################################
# Build the skia tools
#
......
// Copyright (c) 2011 Google Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
File moved
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
// Copyright (c) 2011 Google Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================
The SKIA library also includes a third-party dependency on a nearly
verbatim copy of the GLU tessellator source code from SGI's OpenGL Sample
Implementation at http://oss.sgi.com/projects/ogl-sample/. Per
http://oss.sgi.com/projects/FreeB/, the code is covered under the SGI
Free Software License B, version 2.0, a copy of which is included below.
SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
Copyright (C) [dates of first publication] Silicon Graphics, Inc. All
Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice including the dates of first publication
and either this permission notice or a reference to HYPERLINK
"http://oss.sgi.com/projects/FreeB/"http://oss.sgi.com/projects/FreeB/
shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Silicon Graphics,
Inc. shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written
authorization from Silicon Graphics, Inc.
Skia is a complete 2D graphic library for drawing Text, Geometries, and Images.
See full details, and build instructions, at http://code.google.com/p/skia/wiki/DocRoot
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkBenchmark.h"
#include "SkAAClip.h"
#include "SkPath.h"
#include "SkRegion.h"
#include "SkString.h"
class AAClipBuilderBench : public SkBenchmark {
SkString fName;
SkPath fPath;
SkRect fRect;
SkRegion fRegion;
bool fDoPath;
bool fDoAA;
enum {
N = SkBENCHLOOP(200),
};
public:
AAClipBuilderBench(void* param, bool doPath, bool doAA) : INHERITED(param) {
fDoPath = doPath;
fDoAA = doAA;
fName.printf("aaclip_build_%s_%s", doPath ? "path" : "rect",
doAA ? "AA" : "BW");
fRegion.setRect(0, 0, 640, 480);
fRect.set(fRegion.getBounds());
fRect.inset(SK_Scalar1/4, SK_Scalar1/4);
fPath.addRoundRect(fRect, SkIntToScalar(20), SkIntToScalar(20));
}
protected:
virtual const char* onGetName() { return fName.c_str(); }
virtual void onDraw(SkCanvas* canvas) {
SkPaint paint;
this->setupPaint(&paint);
for (int i = 0; i < N; ++i) {
SkAAClip clip;
if (fDoPath) {
clip.setPath(fPath, &fRegion, fDoAA);
} else {
clip.setRect(fRect, fDoAA);
}
}
}
private:
typedef SkBenchmark INHERITED;
};
class AAClipRegionBench : public SkBenchmark {
public:
AAClipRegionBench(void* param) : INHERITED(param) {
SkPath path;
// test conversion of a complex clip to a aaclip
path.addCircle(0, 0, SkIntToScalar(200));
path.addCircle(0, 0, SkIntToScalar(180));
// evenodd means we've constructed basically a stroked circle
path.setFillType(SkPath::kEvenOdd_FillType);
SkIRect bounds;
path.getBounds().roundOut(&bounds);
fRegion.setPath(path, SkRegion(bounds));
}
protected:
virtual const char* onGetName() { return "aaclip_setregion"; }
virtual void onDraw(SkCanvas* canvas) {
for (int i = 0; i < N; ++i) {
SkAAClip clip;
clip.setRegion(fRegion);
}
}
private:
enum {
N = SkBENCHLOOP(400),
};
SkRegion fRegion;
typedef SkBenchmark INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
static SkBenchmark* Fact0(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, false, false)); }
static SkBenchmark* Fact1(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, false, true)); }
static SkBenchmark* Fact2(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, true, false)); }
static SkBenchmark* Fact3(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, true, true)); }
static BenchRegistry gReg0(Fact0);
static BenchRegistry gReg1(Fact1);
static BenchRegistry gReg2(Fact2);
static BenchRegistry gReg3(Fact3);
static SkBenchmark* Fact01(void* p) { return SkNEW_ARGS(AAClipRegionBench, (p)); }
static BenchRegistry gReg01(Fact01);
......@@ -3,36 +3,42 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
BenchGpuTimer_none.cpp \
BenchSysTimer_posix.cpp \
benchmain.cpp \
BenchTimer.cpp \
BenchSysTimer_posix.cpp \
BenchGpuTimer_gl.cpp \
SkBenchmark.cpp
LOCAL_SRC_FILES += \
AAClipBench.cpp \
BitmapBench.cpp \
BlurBench.cpp \
ChromeBench.cpp \
DecodeBench.cpp \
FPSBench.cpp \
FontScalerBench.cpp \
GradientBench.cpp \
MathBench.cpp \
MatrixBench.cpp \
MutexBench.cpp \
PathBench.cpp \
RectBench.cpp \
RepeatTileBench.cpp \
ScalarBench.cpp \
ShaderMaskBench.cpp \
TextBench.cpp \
SkBenchmark.cpp \
benchmain.cpp
# additional optional class for this tool
LOCAL_SRC_FILES += \
../src/utils/SkNWayCanvas.cpp \
../src/utils/SkParse.cpp
VertBench.cpp
LOCAL_SHARED_LIBRARIES := libcutils libskia libGLESv2
LOCAL_SHARED_LIBRARIES := libcutils libskia libGLESv2 libEGL
LOCAL_STATIC_LIBRARIES := libskiagpu
LOCAL_C_INCLUDES := \
external/skia/include/config \
external/skia/include/core \
external/skia/include/config \
external/skia/include/effects \
external/skia/include/gpu \
external/skia/include/images \
external/skia/include/utils \
external/skia/include/effects \
external/skia/gpu/include \
external/skia/include/gpu
external/skia/src/core \
external/skia/src/gpu
#LOCAL_CFLAGS :=
......
#include "BenchGpuTimer_gl.h"
#include <string.h>
//GL
#define BENCH_GL_FUNCTION_TYPE
#if defined(SK_MESA)
#include <GL/osmesa.h>
#define SK_BENCH_CONTEXT_CHECK (NULL != OSMesaGetCurrentContext())
#define SK_GL_GET_PROC(F) gBenchGL.f ## F = (BenchGL ## F ## Proc) \
OSMesaGetProcAddress("gl" #F);
#define SK_GL_GET_PROC_SUFFIX(F, S) gBenchGL.f ## F = (BenchGL##F##Proc)\
OSMesaGetProcAddress("gl" #F #S);
#elif defined(SK_BUILD_FOR_WIN32)
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
#include <GL/GL.h>
#define SK_BENCH_CONTEXT_CHECK (NULL != wglGetCurrentContext())
#undef BENCH_GL_FUNCTION_TYPE
#define BENCH_GL_FUNCTION_TYPE __stdcall
#define SK_GL_GET_PROC(F) gBenchGL.f ## F = (BenchGL ## F ## Proc) \
wglGetProcAddress("gl" #F);
#define SK_GL_GET_PROC_SUFFIX(F, S) gBenchGL.f ## F = (BenchGL##F##Proc)\
wglGetProcAddress("gl" #F #S);
#elif defined(SK_BUILD_FOR_MAC)
#include <OpenGL/gl.h>
#include <OpenGL/CGLCurrent.h>
#define SK_BENCH_CONTEXT_CHECK (NULL != CGLGetCurrentContext())
#elif defined(SK_BUILD_FOR_UNIX)
#include <GL/gl.h>
#include <GL/glx.h>
#define SK_BENCH_CONTEXT_CHECK (NULL != glXGetCurrentContext())
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "BenchGpuTimer_gl.h"
#include "SkGLContext.h"
BenchGpuTimer::BenchGpuTimer(const SkGLContext* glctx) {
fContext = glctx;
glctx->ref();
glctx->makeCurrent();
fStarted = false;
fSupported = GrGLGetVersion(glctx->gl()) > GR_GL_VER(3,3) ||
GrGLHasExtension(glctx->gl(), "GL_ARB_timer_query") ||
GrGLHasExtension(glctx->gl(), "GL_EXT_timer_query");
#define SK_GL_GET_PROC(F) gBenchGL.f ## F = (BenchGL ## F ## Proc) \
glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("gl" #F));
#define SK_GL_GET_PROC_SUFFIX(F, S) gBenchGL.f ## F = (BenchGL##F##Proc)\
glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("gl" #F #S));
#else
#error unsupported platform
#endif
#define BenchGL_TIME_ELAPSED 0x88BF
#define BenchGL_QUERY_RESULT 0x8866
#define BenchGL_QUERY_RESULT_AVAILABLE 0x8867
#if defined(SK_BUILD_FOR_WIN32)
typedef UINT64 BenchGLuint64;
#else
#include <stdint.h>
typedef uint64_t BenchGLuint64;
#endif
typedef void (BENCH_GL_FUNCTION_TYPE *BenchGLGenQueriesProc) (GLsizei n, GLuint *ids);
typedef void (BENCH_GL_FUNCTION_TYPE *BenchGLBeginQueryProc) (GLenum target, GLuint id);
typedef void (BENCH_GL_FUNCTION_TYPE *BenchGLEndQueryProc) (GLenum target);
typedef void (BENCH_GL_FUNCTION_TYPE *BenchGLDeleteQueriesProc) (GLsizei n, const GLuint *ids);
typedef void (BENCH_GL_FUNCTION_TYPE *BenchGLGetQueryObjectivProc) (GLuint id, GLenum pname, GLint *params);
typedef void (BENCH_GL_FUNCTION_TYPE *BenchGLGetQueryObjectui64vProc) (GLuint id, GLenum pname, BenchGLuint64 *params);
struct BenchGLInterface {
bool fHasTimer;
BenchGLGenQueriesProc fGenQueries;
BenchGLBeginQueryProc fBeginQuery;
BenchGLEndQueryProc fEndQuery;
BenchGLDeleteQueriesProc fDeleteQueries;
BenchGLGetQueryObjectivProc fGetQueryObjectiv;
BenchGLGetQueryObjectui64vProc fGetQueryObjectui64v;
};
static bool BenchGLCheckExtension(const char* ext,
const char* extensionString) {
int extLength = strlen(ext);
while (true) {
int n = strcspn(extensionString, " ");
if (n == extLength && 0 == strncmp(ext, extensionString, n)) {
return true;
}
if (0 == extensionString[n]) {
return false;
}
extensionString += n+1;
}
return false;
}
static BenchGLInterface gBenchGL;
static bool gBenchGLInterfaceInit = false;
static void BenchGLSetDefaultGLInterface() {
gBenchGL.fHasTimer = false;
if (gBenchGLInterfaceInit || !SK_BENCH_CONTEXT_CHECK) return;
const char* glExts =
reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
const GLboolean ext =
BenchGLCheckExtension("GL_EXT_timer_query", glExts);
const GLboolean arb =
BenchGLCheckExtension("GL_ARB_timer_query", glExts);
if (ext || arb) {
#if defined(SK_BUILD_FOR_MAC)
#if GL_EXT_timer_query || GL_ARB_timer_query
gBenchGL.fHasTimer = true;
gBenchGL.fGenQueries = glGenQueries;
gBenchGL.fBeginQuery = glBeginQuery;
gBenchGL.fEndQuery = glEndQuery;
gBenchGL.fDeleteQueries = glDeleteQueries;
gBenchGL.fGetQueryObjectiv = glGetQueryObjectiv;
#endif
#if GL_ARB_timer_query
gBenchGL.fGetQueryObjectui64v = glGetQueryObjectui64v;
#elif GL_EXT_timer_query
gBenchGL.fGetQueryObjectui64v = glGetQueryObjectui64vEXT;
#endif
#else
gBenchGL.fHasTimer = true;
SK_GL_GET_PROC(GenQueries)
SK_GL_GET_PROC(BeginQuery)
SK_GL_GET_PROC(EndQuery)
SK_GL_GET_PROC(DeleteQueries)
SK_GL_GET_PROC(GetQueryObjectiv)
if (arb) {
SK_GL_GET_PROC(GetQueryObjectui64v)
} else {
SK_GL_GET_PROC_SUFFIX(GetQueryObjectui64v, EXT)
}
#endif
}
gBenchGLInterfaceInit = true;
}
BenchGpuTimer::BenchGpuTimer() {
BenchGLSetDefaultGLInterface();
if (gBenchGL.fHasTimer) {
gBenchGL.fGenQueries(1, &this->fQuery);
if (fSupported) {
SK_GL(*glctx, GenQueries(1, &fQuery));
}
}
BenchGpuTimer::~BenchGpuTimer() {
if (gBenchGL.fHasTimer) {
gBenchGL.fDeleteQueries(1, &this->fQuery);
if (fSupported) {
fContext->makeCurrent();
SK_GL(*fContext, DeleteQueries(1, &fQuery));
}
fContext->unref();
}
void BenchGpuTimer::startGpu() {
if (!gBenchGL.fHasTimer) return;
this->fStarted = true;
gBenchGL.fBeginQuery(BenchGL_TIME_ELAPSED, this->fQuery);
if (fSupported) {
fContext->makeCurrent();
fStarted = true;
SK_GL(*fContext, BeginQuery(GR_GL_TIME_ELAPSED, fQuery));
}
}
/**
......@@ -161,21 +43,24 @@ void BenchGpuTimer::startGpu() {
* as this will cpu wait for the gpu to finish.
*/
double BenchGpuTimer::endGpu() {
if (!gBenchGL.fHasTimer) return 0;
this->fStarted = false;
gBenchGL.fEndQuery(BenchGL_TIME_ELAPSED);
GLint available = 0;
while (!available) {
gBenchGL.fGetQueryObjectiv(this->fQuery
, BenchGL_QUERY_RESULT_AVAILABLE
, &available);
if (fSupported) {
fStarted = false;
fContext->makeCurrent();
SK_GL(*fContext, EndQuery(GR_GL_TIME_ELAPSED));
GrGLint available = 0;
while (!available) {
SK_GL(*fContext, GetQueryObjectiv(fQuery,
GR_GL_QUERY_RESULT_AVAILABLE,
&available));
}
GrGLuint64 totalGPUTimeElapsed = 0;
SK_GL(*fContext, GetQueryObjectui64v(fQuery,
GR_GL_QUERY_RESULT,
&totalGPUTimeElapsed));
return totalGPUTimeElapsed / 1000000.0;
} else {
return 0;
}
BenchGLuint64 totalGPUTimeElapsed = 0;
gBenchGL.fGetQueryObjectui64v(this->fQuery
, BenchGL_QUERY_RESULT
, &totalGPUTimeElapsed);
return totalGPUTimeElapsed / 1000000.0;
}
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkBenchGpuTimer_DEFINED
#define SkBenchGpuTimer_DEFINED
#if defined(SK_MESA)
#include <GL/osmesa.h>
#elif defined(SK_BUILD_FOR_WIN32)
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
#include <GL/GL.h>
#elif defined(SK_BUILD_FOR_MAC)
#include <OpenGL/gl.h>
#elif defined(SK_BUILD_FOR_UNIX)
#include <GL/gl.h>
#else
#error unsupported platform
#endif
class SkGLContext;
class BenchGpuTimer {
public:
BenchGpuTimer();
BenchGpuTimer(const SkGLContext* glctx);
~BenchGpuTimer();
void startGpu();
double endGpu();
private:
GLuint fQuery;
unsigned fQuery;
int fStarted;
const SkGLContext* fContext;
bool fSupported;
};
#endif
#include "BenchGpuTimer_none.h"
BenchGpuTimer::BenchGpuTimer() {
}
BenchGpuTimer::~BenchGpuTimer() {
}
void BenchGpuTimer::startGpu() {
}
double BenchGpuTimer::endGpu() {
return -1.0;
}
#ifndef SkBenchGpuTimer_DEFINED
#define SkBenchGpuTimer_DEFINED
class BenchGpuTimer {
public:
BenchGpuTimer();
~BenchGpuTimer();
void startGpu();
double endGpu();
};
#endif
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "BenchSysTimer_c.h"
//Time
......
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkBenchSysTimer_DEFINED
#define SkBenchSysTimer_DEFINED
......
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "BenchSysTimer_mach.h"
//Time
......
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkBenchSysTimer_DEFINED
#define SkBenchSysTimer_DEFINED
......
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "BenchSysTimer_posix.h"
//Time
......
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkBenchSysTimer_DEFINED
#define SkBenchSysTimer_DEFINED
......
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "BenchSysTimer_windows.h"
//Time
......@@ -35,7 +42,7 @@ void BenchSysTimer::startCpu() {
double BenchSysTimer::endCpu() {
ULONGLONG end_cpu = winCpuTime();
return (end_cpu - this->fStartCpu) / 10000;
return static_cast<double>((end_cpu - this->fStartCpu)) / 10000.0L;
}
double BenchSysTimer::endWall() {
LARGE_INTEGER end_wall;
......@@ -48,8 +55,10 @@ double BenchSysTimer::endWall() {
LARGE_INTEGER frequency;
if (0 == ::QueryPerformanceFrequency(&frequency)) {
return 0;
return 0.0L;
} else {
return (double)ticks_elapsed.QuadPart / frequency.QuadPart * 1000;
return static_cast<double>(ticks_elapsed.QuadPart)
/ static_cast<double>(frequency.QuadPart)
* 1000.0L;
}
}
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkBenchSysTimer_DEFINED
#define SkBenchSysTimer_DEFINED
......@@ -5,7 +12,7 @@
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
struct BenchSysTimer {
class BenchSysTimer {
public:
void startWall();
void startCpu();
......
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "BenchTimer.h"
#if defined(SK_BUILD_FOR_WIN32)
#include "BenchSysTimer_windows.h"
#elif defined(SK_BUILD_FOR_MAC)
#include "BenchSysTimer_mach.h"
#elif defined(SK_BUILD_FOR_UNIX)
#elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
#include "BenchSysTimer_posix.h"
#else
#include "BenchSysTimer_c.h"
#endif
#if defined(SK_MESA) || \
defined(SK_BUILD_FOR_WIN32) || \
defined(SK_BUILD_FOR_MAC) || \
defined(SK_BUILD_FOR_UNIX)
#include "BenchGpuTimer_gl.h"
#else
#include "BenchGpuTimer_none.h"
#endif
#include "BenchGpuTimer_gl.h"
BenchTimer::BenchTimer()
BenchTimer::BenchTimer(SkGLContext* gl)
: fCpu(-1.0)
, fWall(-1.0)
, fGpu(-1.0)
{
this->fSysTimer = new BenchSysTimer();
this->fGpuTimer = new BenchGpuTimer();
fSysTimer = new BenchSysTimer();
if (gl) {
fGpuTimer = new BenchGpuTimer(gl);
} else {
fGpuTimer = NULL;
}
}
BenchTimer::~BenchTimer() {
delete this->fSysTimer;
delete this->fGpuTimer;
delete fSysTimer;
delete fGpuTimer;
}
void BenchTimer::start() {
this->fSysTimer->startWall();
this->fGpuTimer->startGpu();
this->fSysTimer->startCpu();
fSysTimer->startWall();
if (fGpuTimer) {
fGpuTimer->startGpu();
}
fSysTimer->startCpu();
}
void BenchTimer::end() {
this->fCpu = this->fSysTimer->endCpu();
fCpu = fSysTimer->endCpu();
//It is important to stop the cpu clocks first,
//as the following will cpu wait for the gpu to finish.
this->fGpu = this->fGpuTimer->endGpu();
this->fWall = this->fSysTimer->endWall();
if (fGpuTimer) {
fGpu = fGpuTimer->endGpu();
}
fWall = fSysTimer->endWall();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment