├── .gitignore ├── .npmignore ├── CanvasView.android.js ├── CanvasView.ios.js ├── README.md ├── index.js ├── package.json ├── platforms ├── android │ ├── .npmignore │ └── src │ │ ├── .gitignore │ │ └── canvas │ │ ├── .classpath │ │ ├── .cproject │ │ ├── .gitignore │ │ ├── .project │ │ ├── .settings │ │ └── org.eclipse.jdt.core.prefs │ │ ├── AndroidManifest.xml │ │ ├── Gruntfile.js │ │ ├── build.xml │ │ ├── jni │ │ ├── Android.mk │ │ ├── Application.mk │ │ ├── CanvasRenderingContext2D.cpp │ │ ├── CanvasRenderingContext2D.h │ │ ├── V8GlobalHelpers.cpp │ │ ├── V8GlobalHelpers.h │ │ ├── include │ │ │ ├── skia │ │ │ │ ├── animator │ │ │ │ │ ├── SkAnimator.h │ │ │ │ │ └── SkAnimatorView.h │ │ │ │ ├── c │ │ │ │ │ ├── sk_canvas.h │ │ │ │ │ ├── sk_data.h │ │ │ │ │ ├── sk_image.h │ │ │ │ │ ├── sk_maskfilter.h │ │ │ │ │ ├── sk_matrix.h │ │ │ │ │ ├── sk_paint.h │ │ │ │ │ ├── sk_path.h │ │ │ │ │ ├── sk_picture.h │ │ │ │ │ ├── sk_shader.h │ │ │ │ │ ├── sk_surface.h │ │ │ │ │ └── sk_types.h │ │ │ │ ├── codec │ │ │ │ │ ├── SkAndroidCodec.h │ │ │ │ │ ├── SkCodec.h │ │ │ │ │ └── SkEncodedFormat.h │ │ │ │ ├── config │ │ │ │ │ └── SkUserConfig.h │ │ │ │ ├── core │ │ │ │ │ ├── SkAnnotation.h │ │ │ │ │ ├── SkBBHFactory.h │ │ │ │ │ ├── SkBitmap.h │ │ │ │ │ ├── SkBitmapDevice.h │ │ │ │ │ ├── SkBlitRow.h │ │ │ │ │ ├── SkBlurTypes.h │ │ │ │ │ ├── SkCanvas.h │ │ │ │ │ ├── SkChunkAlloc.h │ │ │ │ │ ├── SkClipStack.h │ │ │ │ │ ├── SkColor.h │ │ │ │ │ ├── SkColorFilter.h │ │ │ │ │ ├── SkColorPriv.h │ │ │ │ │ ├── SkColorTable.h │ │ │ │ │ ├── SkComposeShader.h │ │ │ │ │ ├── SkData.h │ │ │ │ │ ├── SkDataTable.h │ │ │ │ │ ├── SkDeque.h │ │ │ │ │ ├── SkDevice.h │ │ │ │ │ ├── SkDither.h │ │ │ │ │ ├── SkDocument.h │ │ │ │ │ ├── SkDraw.h │ │ │ │ │ ├── SkDrawFilter.h │ │ │ │ │ ├── SkDrawLooper.h │ │ │ │ │ ├── SkDrawable.h │ │ │ │ │ ├── SkError.h │ │ │ │ │ ├── SkFilterQuality.h │ │ │ │ │ ├── SkFixed.h │ │ │ │ │ ├── SkFlattenable.h │ │ │ │ │ ├── SkFlattenableSerialization.h │ │ │ │ │ ├── SkFont.h │ │ │ │ │ ├── SkFontHost.h │ │ │ │ │ ├── SkFontLCDConfig.h │ │ │ │ │ ├── SkFontStyle.h │ │ │ │ │ ├── SkGraphics.h │ │ │ │ │ ├── SkImage.h │ │ │ │ │ ├── SkImageDecoder.h │ │ │ │ │ ├── SkImageEncoder.h │ │ │ │ │ ├── SkImageFilter.h │ │ │ │ │ ├── SkImageGenerator.h │ │ │ │ │ ├── SkImageInfo.h │ │ │ │ │ ├── SkMallocPixelRef.h │ │ │ │ │ ├── SkMask.h │ │ │ │ │ ├── SkMaskFilter.h │ │ │ │ │ ├── SkMath.h │ │ │ │ │ ├── SkMatrix.h │ │ │ │ │ ├── SkMetaData.h │ │ │ │ │ ├── SkMultiPictureDraw.h │ │ │ │ │ ├── SkOSFile.h │ │ │ │ │ ├── SkPackBits.h │ │ │ │ │ ├── SkPaint.h │ │ │ │ │ ├── SkPath.h │ │ │ │ │ ├── SkPathEffect.h │ │ │ │ │ ├── SkPathMeasure.h │ │ │ │ │ ├── SkPathRef.h │ │ │ │ │ ├── SkPicture.h │ │ │ │ │ ├── SkPictureRecorder.h │ │ │ │ │ ├── SkPixelRef.h │ │ │ │ │ ├── SkPixelSerializer.h │ │ │ │ │ ├── SkPixmap.h │ │ │ │ │ ├── SkPoint.h │ │ │ │ │ ├── SkPoint3.h │ │ │ │ │ ├── SkPostConfig.h │ │ │ │ │ ├── SkPreConfig.h │ │ │ │ │ ├── SkRRect.h │ │ │ │ │ ├── SkRSXform.h │ │ │ │ │ ├── SkRasterizer.h │ │ │ │ │ ├── SkRect.h │ │ │ │ │ ├── SkRefCnt.h │ │ │ │ │ ├── SkRegion.h │ │ │ │ │ ├── SkScalar.h │ │ │ │ │ ├── SkShader.h │ │ │ │ │ ├── SkSize.h │ │ │ │ │ ├── SkStream.h │ │ │ │ │ ├── SkString.h │ │ │ │ │ ├── SkStrokeRec.h │ │ │ │ │ ├── SkSurface.h │ │ │ │ │ ├── SkSurfaceProps.h │ │ │ │ │ ├── SkTArray.h │ │ │ │ │ ├── SkTDArray.h │ │ │ │ │ ├── SkTDStack.h │ │ │ │ │ ├── SkTDict.h │ │ │ │ │ ├── SkTInternalLList.h │ │ │ │ │ ├── SkTLazy.h │ │ │ │ │ ├── SkTRegistry.h │ │ │ │ │ ├── SkTSearch.h │ │ │ │ │ ├── SkTextBlob.h │ │ │ │ │ ├── SkTime.h │ │ │ │ │ ├── SkTraceMemoryDump.h │ │ │ │ │ ├── SkTypeface.h │ │ │ │ │ ├── SkTypes.h │ │ │ │ │ ├── SkUnPreMultiply.h │ │ │ │ │ ├── SkUtils.h │ │ │ │ │ ├── SkWriteBuffer.h │ │ │ │ │ ├── SkWriter32.h │ │ │ │ │ └── SkXfermode.h │ │ │ │ ├── device │ │ │ │ │ └── xps │ │ │ │ │ │ ├── SkConstexprMath.h │ │ │ │ │ │ └── SkXPSDevice.h │ │ │ │ ├── effects │ │ │ │ │ ├── Sk1DPathEffect.h │ │ │ │ │ ├── Sk2DPathEffect.h │ │ │ │ │ ├── SkAlphaThresholdFilter.h │ │ │ │ │ ├── SkArcToPathEffect.h │ │ │ │ │ ├── SkArithmeticMode.h │ │ │ │ │ ├── SkBlurDrawLooper.h │ │ │ │ │ ├── SkBlurImageFilter.h │ │ │ │ │ ├── SkBlurMaskFilter.h │ │ │ │ │ ├── SkColorCubeFilter.h │ │ │ │ │ ├── SkColorFilterImageFilter.h │ │ │ │ │ ├── SkColorMatrix.h │ │ │ │ │ ├── SkColorMatrixFilter.h │ │ │ │ │ ├── SkComposeImageFilter.h │ │ │ │ │ ├── SkCornerPathEffect.h │ │ │ │ │ ├── SkDashPathEffect.h │ │ │ │ │ ├── SkDiscretePathEffect.h │ │ │ │ │ ├── SkDisplacementMapEffect.h │ │ │ │ │ ├── SkDrawExtraPathEffect.h │ │ │ │ │ ├── SkDropShadowImageFilter.h │ │ │ │ │ ├── SkEmbossMaskFilter.h │ │ │ │ │ ├── SkGradientShader.h │ │ │ │ │ ├── SkImageSource.h │ │ │ │ │ ├── SkLayerDrawLooper.h │ │ │ │ │ ├── SkLayerRasterizer.h │ │ │ │ │ ├── SkLerpXfermode.h │ │ │ │ │ ├── SkLightingImageFilter.h │ │ │ │ │ ├── SkLumaColorFilter.h │ │ │ │ │ ├── SkMagnifierImageFilter.h │ │ │ │ │ ├── SkMatrixConvolutionImageFilter.h │ │ │ │ │ ├── SkMergeImageFilter.h │ │ │ │ │ ├── SkModeColorFilter.h │ │ │ │ │ ├── SkMorphologyImageFilter.h │ │ │ │ │ ├── SkOffsetImageFilter.h │ │ │ │ │ ├── SkPaintFlagsDrawFilter.h │ │ │ │ │ ├── SkPerlinNoiseShader.h │ │ │ │ │ ├── SkPictureImageFilter.h │ │ │ │ │ ├── SkPixelXorXfermode.h │ │ │ │ │ ├── SkRectShaderImageFilter.h │ │ │ │ │ ├── SkTableColorFilter.h │ │ │ │ │ ├── SkTableMaskFilter.h │ │ │ │ │ ├── SkTestImageFilters.h │ │ │ │ │ ├── SkTileImageFilter.h │ │ │ │ │ └── SkXfermodeImageFilter.h │ │ │ │ ├── gpu │ │ │ │ │ ├── GrBlend.h │ │ │ │ │ ├── GrCaps.h │ │ │ │ │ ├── GrClip.h │ │ │ │ │ ├── GrColor.h │ │ │ │ │ ├── GrConfig.h │ │ │ │ │ ├── GrContext.h │ │ │ │ │ ├── GrContextOptions.h │ │ │ │ │ ├── GrCoordTransform.h │ │ │ │ │ ├── GrDrawContext.h │ │ │ │ │ ├── GrFragmentProcessor.h │ │ │ │ │ ├── GrGpuResource.h │ │ │ │ │ ├── GrGpuResourceRef.h │ │ │ │ │ ├── GrInvariantOutput.h │ │ │ │ │ ├── GrPaint.h │ │ │ │ │ ├── GrProcessor.h │ │ │ │ │ ├── GrProcessorUnitTest.h │ │ │ │ │ ├── GrProgramElement.h │ │ │ │ │ ├── GrRect.h │ │ │ │ │ ├── GrRenderTarget.h │ │ │ │ │ ├── GrResourceKey.h │ │ │ │ │ ├── GrShaderVar.h │ │ │ │ │ ├── GrSurface.h │ │ │ │ │ ├── GrTestUtils.h │ │ │ │ │ ├── GrTexture.h │ │ │ │ │ ├── GrTextureAccess.h │ │ │ │ │ ├── GrTextureParams.h │ │ │ │ │ ├── GrTextureProvider.h │ │ │ │ │ ├── GrTypes.h │ │ │ │ │ ├── GrTypesPriv.h │ │ │ │ │ ├── GrXferProcessor.h │ │ │ │ │ ├── SkGr.h │ │ │ │ │ ├── SkGrPixelRef.h │ │ │ │ │ ├── SkGrTexturePixelRef.h │ │ │ │ │ ├── effects │ │ │ │ │ │ ├── GrConstColorProcessor.h │ │ │ │ │ │ ├── GrCoverageSetOpXP.h │ │ │ │ │ │ ├── GrCustomXfermode.h │ │ │ │ │ │ ├── GrPorterDuffXferProcessor.h │ │ │ │ │ │ └── GrXfermodeFragmentProcessor.h │ │ │ │ │ └── gl │ │ │ │ │ │ ├── GrGLConfig.h │ │ │ │ │ │ ├── GrGLConfig_chrome.h │ │ │ │ │ │ ├── GrGLExtensions.h │ │ │ │ │ │ ├── GrGLFunctions.h │ │ │ │ │ │ ├── GrGLInterface.h │ │ │ │ │ │ ├── GrGLSLPrettyPrint.h │ │ │ │ │ │ ├── GrGLTypes.h │ │ │ │ │ │ ├── SkGLContext.h │ │ │ │ │ │ ├── SkNullGLContext.h │ │ │ │ │ │ ├── angle │ │ │ │ │ │ └── SkANGLEGLContext.h │ │ │ │ │ │ └── command_buffer │ │ │ │ │ │ └── SkCommandBufferGLContext.h │ │ │ │ ├── images │ │ │ │ │ ├── SkDecodingImageGenerator.h │ │ │ │ │ ├── SkForceLinking.h │ │ │ │ │ ├── SkMovie.h │ │ │ │ │ └── SkPageFlipper.h │ │ │ │ ├── pathops │ │ │ │ │ └── SkPathOps.h │ │ │ │ ├── pipe │ │ │ │ │ └── SkGPipe.h │ │ │ │ ├── ports │ │ │ │ │ ├── SkAtomics_atomic.h │ │ │ │ │ ├── SkAtomics_std.h │ │ │ │ │ ├── SkAtomics_sync.h │ │ │ │ │ ├── SkFontConfigInterface.h │ │ │ │ │ ├── SkFontMgr.h │ │ │ │ │ ├── SkFontMgr_android.h │ │ │ │ │ ├── SkFontMgr_custom.h │ │ │ │ │ ├── SkFontMgr_fontconfig.h │ │ │ │ │ ├── SkFontMgr_indirect.h │ │ │ │ │ ├── SkRemotableFontMgr.h │ │ │ │ │ ├── SkTypeface_mac.h │ │ │ │ │ └── SkTypeface_win.h │ │ │ │ ├── private │ │ │ │ │ ├── SkAtomics.h │ │ │ │ │ ├── SkChecksum.h │ │ │ │ │ ├── SkFloatBits.h │ │ │ │ │ ├── SkFloatingPoint.h │ │ │ │ │ ├── SkFunction.h │ │ │ │ │ ├── SkGpuFenceSync.h │ │ │ │ │ ├── SkMiniRecorder.h │ │ │ │ │ ├── SkMutex.h │ │ │ │ │ ├── SkOnce.h │ │ │ │ │ ├── SkOncePtr.h │ │ │ │ │ ├── SkRecords.h │ │ │ │ │ ├── SkSemaphore.h │ │ │ │ │ ├── SkSpinlock.h │ │ │ │ │ ├── SkTHash.h │ │ │ │ │ ├── SkTLogic.h │ │ │ │ │ ├── SkTemplates.h │ │ │ │ │ ├── SkThreadID.h │ │ │ │ │ ├── SkUniquePtr.h │ │ │ │ │ ├── SkUtility.h │ │ │ │ │ └── SkWeakRefCnt.h │ │ │ │ ├── svg │ │ │ │ │ ├── SkSVGCanvas.h │ │ │ │ │ └── parser │ │ │ │ │ │ ├── SkSVGAttribute.h │ │ │ │ │ │ ├── SkSVGBase.h │ │ │ │ │ │ ├── SkSVGPaintState.h │ │ │ │ │ │ ├── SkSVGParser.h │ │ │ │ │ │ └── SkSVGTypes.h │ │ │ │ ├── utils │ │ │ │ │ ├── SkBoundaryPatch.h │ │ │ │ │ ├── SkCamera.h │ │ │ │ │ ├── SkCanvasStateUtils.h │ │ │ │ │ ├── SkCubicInterval.h │ │ │ │ │ ├── SkCullPoints.h │ │ │ │ │ ├── SkDebugUtils.h │ │ │ │ │ ├── SkDumpCanvas.h │ │ │ │ │ ├── SkEventTracer.h │ │ │ │ │ ├── SkFrontBufferedStream.h │ │ │ │ │ ├── SkInterpolator.h │ │ │ │ │ ├── SkJSONCPP.h │ │ │ │ │ ├── SkLayer.h │ │ │ │ │ ├── SkLua.h │ │ │ │ │ ├── SkLuaCanvas.h │ │ │ │ │ ├── SkMatrix44.h │ │ │ │ │ ├── SkMeshUtils.h │ │ │ │ │ ├── SkNWayCanvas.h │ │ │ │ │ ├── SkNinePatch.h │ │ │ │ │ ├── SkNoSaveLayerCanvas.h │ │ │ │ │ ├── SkNullCanvas.h │ │ │ │ │ ├── SkPaintFilterCanvas.h │ │ │ │ │ ├── SkParse.h │ │ │ │ │ ├── SkParsePaint.h │ │ │ │ │ ├── SkParsePath.h │ │ │ │ │ ├── SkPictureUtils.h │ │ │ │ │ ├── SkRTConf.h │ │ │ │ │ ├── SkRandom.h │ │ │ │ │ ├── SkTextBox.h │ │ │ │ │ ├── mac │ │ │ │ │ │ └── SkCGUtils.h │ │ │ │ │ └── win │ │ │ │ │ │ ├── SkAutoCoInitialize.h │ │ │ │ │ │ ├── SkHRESULT.h │ │ │ │ │ │ ├── SkIStream.h │ │ │ │ │ │ └── SkTScopedComPtr.h │ │ │ │ ├── views │ │ │ │ │ ├── SkApplication.h │ │ │ │ │ ├── SkBGViewArtist.h │ │ │ │ │ ├── SkEvent.h │ │ │ │ │ ├── SkEventSink.h │ │ │ │ │ ├── SkKey.h │ │ │ │ │ ├── SkOSMenu.h │ │ │ │ │ ├── SkOSWindow_Android.h │ │ │ │ │ ├── SkOSWindow_Mac.h │ │ │ │ │ ├── SkOSWindow_SDL.h │ │ │ │ │ ├── SkOSWindow_Unix.h │ │ │ │ │ ├── SkOSWindow_Win.h │ │ │ │ │ ├── SkOSWindow_iOS.h │ │ │ │ │ ├── SkStackViewLayout.h │ │ │ │ │ ├── SkSystemEventTypes.h │ │ │ │ │ ├── SkTouchGesture.h │ │ │ │ │ ├── SkView.h │ │ │ │ │ ├── SkViewInflate.h │ │ │ │ │ ├── SkWidget.h │ │ │ │ │ ├── SkWindow.h │ │ │ │ │ └── animated │ │ │ │ │ │ ├── SkBorderView.h │ │ │ │ │ │ ├── SkImageView.h │ │ │ │ │ │ ├── SkProgressBarView.h │ │ │ │ │ │ ├── SkScrollBarView.h │ │ │ │ │ │ └── SkWidgetViews.h │ │ │ │ └── xml │ │ │ │ │ ├── SkBML_WXMLParser.h │ │ │ │ │ ├── SkBML_XMLParser.h │ │ │ │ │ ├── SkDOM.h │ │ │ │ │ ├── SkXMLParser.h │ │ │ │ │ └── SkXMLWriter.h │ │ │ ├── v8-debug.h │ │ │ ├── v8-platform.h │ │ │ ├── v8-profiler.h │ │ │ ├── v8-testing.h │ │ │ ├── v8-util.h │ │ │ ├── v8-version.h │ │ │ ├── v8.h │ │ │ └── v8config.h │ │ └── libs │ │ │ ├── arm │ │ │ ├── libNativeScript.so │ │ │ └── libskia_android.zip │ │ │ └── x86 │ │ │ ├── libNativeScript.so │ │ │ └── libskia_android.zip │ │ ├── package.json │ │ ├── proguard-project.txt │ │ ├── project.properties │ │ ├── res │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ ├── values-v11 │ │ │ └── styles.xml │ │ ├── values-v14 │ │ │ └── styles.xml │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── src │ │ └── com │ │ └── tns │ │ └── CanvasViewBase.java └── ios │ ├── .gitignore │ ├── .npmignore │ └── src │ ├── canvas.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── canvas │ ├── CanvasRenderingContext2d.h │ ├── CanvasRenderingContext2d.mm │ ├── Info.plist │ ├── canvas.h │ └── module.modulemap ├── prepackage.js └── test ├── app ├── App_Resources │ ├── Android │ │ ├── drawable-hdpi │ │ │ └── icon.png │ │ ├── drawable-ldpi │ │ │ └── icon.png │ │ ├── drawable-mdpi │ │ │ └── icon.png │ │ └── drawable-nodpi │ │ │ └── splashscreen.9.png │ └── iOS │ │ ├── Default-568h@2x.png │ │ ├── Default-667h@2x.png │ │ ├── Default-736h@3x.png │ │ ├── Default-Landscape-568h@2x.png │ │ ├── Default-Landscape-667h@2x.png │ │ ├── Default-Landscape.png │ │ ├── Default-Landscape@2x.png │ │ ├── Default-Landscape@3x.png │ │ ├── Default-Portrait.png │ │ ├── Default-Portrait@2x.png │ │ ├── Default.png │ │ ├── Default@2x.png │ │ ├── Icon-Small-50.png │ │ ├── Icon-Small-50@2x.png │ │ ├── Icon-Small.png │ │ ├── Icon-Small@2x.png │ │ ├── icon-40.png │ │ ├── icon-40@2x.png │ │ ├── icon-60.png │ │ ├── icon-60@2x.png │ │ ├── icon-72.png │ │ ├── icon-72@2x.png │ │ ├── icon-76.png │ │ ├── icon-76@2x.png │ │ ├── icon.png │ │ └── icon@2x.png ├── app.css ├── app.js ├── main-page.js ├── main-page.xml ├── main-view-model.js ├── package.json └── references.d.ts └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | .metadata/ 2 | .vscode/ 3 | node_modules/ 4 | 5 | platforms/android/*.jar 6 | platforms/android/jniLibs/ 7 | 8 | *.tgz 9 | *.log 10 | .DS_Store 11 | 12 | test/platforms/ 13 | test/lib/ -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .npmignore 2 | platforms/android/src/ 3 | platforms/ios/src/ 4 | 5 | test/ 6 | 7 | prepackage.js 8 | *.tgz 9 | *.log -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This plugin is no longer supported 2 | About 3 | ============ 4 | This is a proof-of-concept plugin that enables HTML5 like Canvas API for NativeScript. The code is not production ready and a lot of features are currently missing. You can check the overall progress in [this](https://github.com/NativeScript/nativescript-canvas/issues/1) issue. 5 | 6 | Contributing 7 | ============ 8 | 9 | The project encourages hacking, so hack away. Clone the repo and follow the steps to set yourself up for development. 10 | 11 | Prerequisites: 12 | * `npm i -g grunt-cli` 13 | * iOS: XCode 14 | * Android: Android NDK, SDK and Ant 15 | 16 | ```shell 17 | npm install # install canvas library dependencies 18 | cd test 19 | npm install # install test project dependencies 20 | tns run android # fire up the test project on android 21 | tns run ios # fire up the test project on ios 22 | ``` 23 | 24 | After making modifications to the canvas library, regardless whether it's the iOS, Android or JS part, you can re-launch with your changes like so: 25 | 26 | ```shell 27 | npm i .. && rm -rf platforms && tns run 28 | ``` 29 | 30 | You can skip the `rm -rf platforms` part when you don't change the public interface of the native bits. 31 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var view = require('ui/core/view'); 2 | var canvasViewLib = require('./CanvasView'); 3 | 4 | function Canvas() { 5 | view.View.call(this); 6 | 7 | this._drawingContext = null; 8 | } 9 | __extends(Canvas, view.View); 10 | 11 | Canvas.prototype.getContext = function getContext(kind) { 12 | return this._native.getContext(kind); 13 | } 14 | 15 | Canvas.prototype._draw = function _draw(canvas) { 16 | if (this._drawingContext) { 17 | canvas.drawBitmap(this._drawingContext._backbuffer, 0.0, 0.0, null); 18 | } 19 | } 20 | 21 | Canvas.prototype._onSizeChanged = function _onSizeChanged(width, height) { 22 | if (this._native) { 23 | this._native.setSize(width, height); 24 | } 25 | } 26 | 27 | Canvas.prototype.onLayout = function onLayout(left, top, right, bottom) { 28 | view.View.prototype.onLayout.apply(this, arguments); 29 | this._onSizeChanged(right - left, bottom - top); 30 | } 31 | 32 | Canvas.prototype._createUI = function _createUI() { 33 | console.log('Creating CanvasView'); 34 | var view = canvasViewLib.createView(1, 1, this._context); 35 | view._scriptCanvas = this; 36 | this._native = view; 37 | } 38 | 39 | Object.defineProperty(Canvas.prototype, "offsetWidth", { 40 | get: function () { return this.width; }, 41 | }); 42 | 43 | Object.defineProperty(Canvas.prototype, "offsetHeight", { 44 | get: function () { return this.height; }, 45 | }); 46 | 47 | Object.defineProperty(Canvas.prototype, canvasViewLib.platform, { 48 | get: function () { 49 | if (!this._native && canvasViewLib.platform === 'ios') { 50 | this._createUI(); 51 | } 52 | return this._native; 53 | } 54 | }); 55 | 56 | exports.Canvas = Canvas; 57 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-canvas", 3 | "version": "0.0.1", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "prepublish": "node prepackage.js" 9 | }, 10 | "author": "", 11 | "license": "Apache-2.0", 12 | "nativescript": {}, 13 | "devDependencies": { 14 | "mkdirp": "^0.5.1", 15 | "q": "^1.4.1" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /platforms/android/.npmignore: -------------------------------------------------------------------------------- 1 | src/ -------------------------------------------------------------------------------- /platforms/android/src/.gitignore: -------------------------------------------------------------------------------- 1 | .metadata/ 2 | .recommenders/ -------------------------------------------------------------------------------- /platforms/android/src/canvas/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | .gradle 4 | 5 | local.properties 6 | 7 | gen/ 8 | armeabi-v7a/ 9 | obj/ 10 | bin/ 11 | .svn/ 12 | libs/x86/ 13 | 14 | libskia_android.a -------------------------------------------------------------------------------- /platforms/android/src/canvas/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | canvas 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | com.android.ide.eclipse.adt.ResourceManagerBuilder 16 | 17 | 18 | 19 | 20 | com.android.ide.eclipse.adt.PreCompilerBuilder 21 | 22 | 23 | 24 | 25 | org.eclipse.jdt.core.javabuilder 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.ApkBuilder 31 | 32 | 33 | 34 | 35 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 36 | full,incremental, 37 | 38 | 39 | 40 | 41 | 42 | com.android.ide.eclipse.adt.AndroidNature 43 | org.eclipse.jdt.core.javanature 44 | org.eclipse.cdt.core.cnature 45 | org.eclipse.cdt.core.ccnature 46 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 47 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 48 | 49 | 50 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 9 | 10 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | 3 | grunt.initConfig({ 4 | unzip: { 5 | arm: { 6 | src: 'jni/libs/arm/libskia_android.zip', 7 | dest: 'jni/libs/arm/' 8 | }, 9 | x86: { 10 | src: 'jni/libs/x86/libskia_android.zip', 11 | dest: 'jni/libs/x86/' 12 | }, 13 | } 14 | }); 15 | 16 | grunt.loadNpmTasks('grunt-zip'); 17 | 18 | var unzipTasks = []; 19 | var fs = require('fs'); 20 | if (!fs.existsSync('jni/libs/arm/libskia_android.a')) { 21 | unzipTasks.push('unzip:arm'); 22 | } 23 | if (!fs.existsSync('jni/libs/x86/libskia_android.a')) { 24 | unzipTasks.push('unzip:x86'); 25 | } 26 | 27 | grunt.registerTask('libs', unzipTasks); 28 | grunt.registerTask('default', ['libs']); 29 | }; 30 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_MODULE := skia_android 5 | ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) 6 | LOCAL_SRC_FILES := libs/arm/libskia_android.a 7 | else ifeq ($(TARGET_ARCH_ABI),armeabi) 8 | LOCAL_SRC_FILES := libs/arm/libskia_android.a 9 | else ifeq ($(TARGET_ARCH_ABI),x86) 10 | LOCAL_SRC_FILES := libs/x86/libskia_android.a 11 | endif 12 | include $(PREBUILT_STATIC_LIBRARY) 13 | 14 | include $(CLEAR_VARS) 15 | LOCAL_MODULE := NativeScript 16 | ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) 17 | LOCAL_SRC_FILES := libs/arm/libNativeScript.so 18 | else ifeq ($(TARGET_ARCH_ABI),armeabi) 19 | LOCAL_SRC_FILES := libs/arm/libNativeScript.so 20 | else ifeq ($(TARGET_ARCH_ABI),x86) 21 | LOCAL_SRC_FILES := libs/x86/libNativeScript.so 22 | endif 23 | include $(PREBUILT_SHARED_LIBRARY) 24 | 25 | include $(CLEAR_VARS) 26 | 27 | LOCAL_CPPFLAGS += -std=c++11 28 | LOCAL_MODULE := canvas 29 | LOCAL_SRC_FILES := CanvasRenderingContext2D.cpp V8GlobalHelpers.cpp 30 | 31 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/include/skia/core $(LOCAL_PATH)/include/skia/config 32 | LOCAL_LDLIBS := -llog -landroid -lz -lEGL -lGLESv2 -ljnigraphics 33 | LOCAL_STATIC_LIBRARIES := skia_android cpufeatures 34 | LOCAL_SHARED_LIBRARIES := NativeScript 35 | 36 | include $(BUILD_SHARED_LIBRARY) 37 | 38 | $(call import-module,android/cpufeatures) 39 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := armeabi-v7a x86 2 | 3 | APP_STL := stlport_static 4 | #APP_STL := gnustl_static 5 | APP_PLATFORM := android-14 6 | NDK_TOOLCHAIN_VERSION := 4.8 7 | APP_OPTIM := debug 8 | #APP_OPTIM := release 9 | 10 | #The new ndks require this or build fails 11 | APP_CFLAGS += -Wno-error=format-security 12 | APP_CFLAGS += -g 13 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/V8GlobalHelpers.cpp: -------------------------------------------------------------------------------- 1 | #include "V8GlobalHelpers.h" 2 | 3 | using namespace v8; 4 | using namespace std; 5 | 6 | string ConvertToString(const v8::Local& s) 7 | { 8 | if (s.IsEmpty()) 9 | { 10 | return string(); 11 | } 12 | else 13 | { 14 | String::Utf8Value str(s); 15 | return string(*str); 16 | } 17 | } 18 | 19 | Local ConvertToV8String(const jchar* data, int length) 20 | { 21 | auto isolate = Isolate::GetCurrent(); 22 | return String::NewFromTwoByte(isolate, (const uint16_t*)data, String::kNormalString, length); 23 | } 24 | 25 | Local ConvertToV8String(const string& s) 26 | { 27 | auto isolate = Isolate::GetCurrent(); 28 | return String::NewFromUtf8(isolate, s.c_str()); 29 | } 30 | 31 | Local ConvertToV8String(const char *data, int length) 32 | { 33 | auto isolate = Isolate::GetCurrent(); 34 | return String::NewFromUtf8(isolate, (const char *)data, String::kNormalString, length); 35 | } 36 | 37 | Local V8GetHiddenValue(const Local& obj, const string& propName) 38 | { 39 | auto s = ConvertToV8String(propName); 40 | return obj->GetHiddenValue(s); 41 | } 42 | 43 | bool V8SetHiddenValue(const Local& obj, const string& propName, const Local& value) 44 | { 45 | auto s = ConvertToV8String(propName); 46 | return obj->SetHiddenValue(s, value); 47 | } 48 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/V8GlobalHelpers.h: -------------------------------------------------------------------------------- 1 | #ifndef V8GLOBALHELPERS_H_ 2 | #define V8GLOBALHELPERS_H_ 3 | 4 | #include "jni.h" 5 | #include "v8.h" 6 | #include 7 | 8 | std::string ConvertToString(const v8::Local& s); 9 | 10 | jstring ConvertToJavaString(const v8::Local& jsValue); 11 | 12 | template 13 | v8::Local ConvertToV8String(jchar (&data)[N]) 14 | { 15 | auto isolate = v8::Isolate::GetCurrent(); 16 | return v8::String::NewFromUtf8(isolate, (const char *)data, v8::String::kNormalString, N); 17 | } 18 | 19 | v8::Local ConvertToV8String(const jchar* data, int length); 20 | 21 | v8::Local ConvertToV8String(const std::string& s); 22 | 23 | v8::Local ConvertToV8String(const char *data, int length); 24 | 25 | v8::Local V8GetHiddenValue(const v8::Local& obj, const std::string& propName); 26 | 27 | bool V8SetHiddenValue(const v8::Local& obj, const std::string& propName, const v8::Local& value); 28 | 29 | #endif /* V8GLOBALHELPERS_H_ */ 30 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/animator/SkAnimatorView.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkAnimatorView_DEFINED 11 | #define SkAnimatorView_DEFINED 12 | 13 | #include "SkView.h" 14 | #include "SkAnimator.h" 15 | 16 | class SkAnimatorView : public SkView { 17 | public: 18 | SkAnimatorView(); 19 | virtual ~SkAnimatorView(); 20 | 21 | SkAnimator* getAnimator() const { return fAnimator; } 22 | 23 | bool decodeFile(const char path[]); 24 | bool decodeMemory(const void* buffer, size_t size); 25 | bool decodeStream(SkStream* stream); 26 | 27 | protected: 28 | // overrides 29 | virtual bool onEvent(const SkEvent&); 30 | virtual void onDraw(SkCanvas*); 31 | virtual void onInflate(const SkDOM&, const SkDOM::Node*); 32 | 33 | private: 34 | SkAnimator* fAnimator; 35 | 36 | typedef SkView INHERITED; 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/c/sk_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL 9 | // DO NOT USE -- FOR INTERNAL TESTING ONLY 10 | 11 | #ifndef sk_data_DEFINED 12 | #define sk_data_DEFINED 13 | 14 | #include "sk_types.h" 15 | 16 | SK_C_PLUS_PLUS_BEGIN_GUARD 17 | 18 | /** 19 | Returns a new empty sk_data_t. This call must be balanced with a call to 20 | sk_data_unref(). 21 | */ 22 | SK_API sk_data_t* sk_data_new_empty(); 23 | /** 24 | Returns a new sk_data_t by copying the specified source data. 25 | This call must be balanced with a call to sk_data_unref(). 26 | */ 27 | SK_API sk_data_t* sk_data_new_with_copy(const void* src, size_t length); 28 | /** 29 | Pass ownership of the given memory to a new sk_data_t, which will 30 | call free() when the refernce count of the data goes to zero. For 31 | example: 32 | size_t length = 1024; 33 | void* buffer = malloc(length); 34 | memset(buffer, 'X', length); 35 | sk_data_t* data = sk_data_new_from_malloc(buffer, length); 36 | This call must be balanced with a call to sk_data_unref(). 37 | */ 38 | SK_API sk_data_t* sk_data_new_from_malloc(const void* memory, size_t length); 39 | /** 40 | Returns a new sk_data_t using a subset of the data in the 41 | specified source sk_data_t. This call must be balanced with a 42 | call to sk_data_unref(). 43 | */ 44 | SK_API sk_data_t* sk_data_new_subset(const sk_data_t* src, size_t offset, size_t length); 45 | 46 | /** 47 | Increment the reference count on the given sk_data_t. Must be 48 | balanced by a call to sk_data_unref(). 49 | */ 50 | SK_API void sk_data_ref(const sk_data_t*); 51 | /** 52 | Decrement the reference count. If the reference count is 1 before 53 | the decrement, then release both the memory holding the sk_data_t 54 | and the memory it is managing. New sk_data_t are created with a 55 | reference count of 1. 56 | */ 57 | SK_API void sk_data_unref(const sk_data_t*); 58 | 59 | /** 60 | Returns the number of bytes stored. 61 | */ 62 | SK_API size_t sk_data_get_size(const sk_data_t*); 63 | /** 64 | Returns the pointer to the data. 65 | */ 66 | SK_API const void* sk_data_get_data(const sk_data_t*); 67 | 68 | SK_C_PLUS_PLUS_END_GUARD 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/c/sk_image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL 9 | // DO NOT USE -- FOR INTERNAL TESTING ONLY 10 | 11 | #ifndef sk_image_DEFINED 12 | #define sk_image_DEFINED 13 | 14 | #include "sk_types.h" 15 | 16 | SK_C_PLUS_PLUS_BEGIN_GUARD 17 | 18 | /** 19 | * Return a new image that has made a copy of the provided pixels, or NULL on failure. 20 | * Balance with a call to sk_image_unref(). 21 | */ 22 | SK_API sk_image_t* sk_image_new_raster_copy(const sk_imageinfo_t*, const void* pixels, size_t rowBytes); 23 | 24 | /** 25 | * If the specified data can be interpreted as a compressed image (e.g. PNG or JPEG) then this 26 | * returns an image. If the encoded data is not supported, returns NULL. 27 | * 28 | * On success, the encoded data may be processed immediately, or it may be ref()'d for later 29 | * use. 30 | */ 31 | SK_API sk_image_t* sk_image_new_from_encoded(const sk_data_t* encoded, const sk_irect_t* subset); 32 | 33 | /** 34 | * Encode the image's pixels and return the result as a new PNG in a 35 | * sk_data_t, which the caller must manage: call sk_data_unref() when 36 | * they are done. 37 | * 38 | * If the image type cannot be encoded, this will return NULL. 39 | */ 40 | SK_API sk_data_t* sk_image_encode(const sk_image_t*); 41 | 42 | /** 43 | * Increment the reference count on the given sk_image_t. Must be 44 | * balanced by a call to sk_image_unref(). 45 | */ 46 | SK_API void sk_image_ref(const sk_image_t*); 47 | /** 48 | * Decrement the reference count. If the reference count is 1 before 49 | * the decrement, then release both the memory holding the sk_image_t 50 | * and the memory it is managing. New sk_image_t are created with a 51 | reference count of 1. 52 | */ 53 | SK_API void sk_image_unref(const sk_image_t*); 54 | 55 | /** 56 | * Return the width of the sk_image_t/ 57 | */ 58 | SK_API int sk_image_get_width(const sk_image_t*); 59 | /** 60 | * Return the height of the sk_image_t/ 61 | */ 62 | SK_API int sk_image_get_height(const sk_image_t*); 63 | 64 | /** 65 | * Returns a non-zero value unique among all images. 66 | */ 67 | SK_API uint32_t sk_image_get_unique_id(const sk_image_t*); 68 | 69 | SK_C_PLUS_PLUS_END_GUARD 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/c/sk_maskfilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL 9 | // DO NOT USE -- FOR INTERNAL TESTING ONLY 10 | 11 | #ifndef sk_maskfilter_DEFINED 12 | #define sk_maskfilter_DEFINED 13 | 14 | #include "sk_types.h" 15 | 16 | typedef enum { 17 | NORMAL_SK_BLUR_STYLE, //!< fuzzy inside and outside 18 | SOLID_SK_BLUR_STYLE, //!< solid inside, fuzzy outside 19 | OUTER_SK_BLUR_STYLE, //!< nothing inside, fuzzy outside 20 | INNER_SK_BLUR_STYLE, //!< fuzzy inside, nothing outside 21 | } sk_blurstyle_t; 22 | 23 | SK_C_PLUS_PLUS_BEGIN_GUARD 24 | 25 | /** 26 | Increment the reference count on the given sk_maskfilter_t. Must be 27 | balanced by a call to sk_maskfilter_unref(). 28 | */ 29 | void sk_maskfilter_ref(sk_maskfilter_t*); 30 | /** 31 | Decrement the reference count. If the reference count is 1 before 32 | the decrement, then release both the memory holding the 33 | sk_maskfilter_t and any other associated resources. New 34 | sk_maskfilter_t are created with a reference count of 1. 35 | */ 36 | void sk_maskfilter_unref(sk_maskfilter_t*); 37 | 38 | /** 39 | Create a blur maskfilter. 40 | @param sk_blurstyle_t The SkBlurStyle to use 41 | @param sigma Standard deviation of the Gaussian blur to apply. Must be > 0. 42 | */ 43 | sk_maskfilter_t* sk_maskfilter_new_blur(sk_blurstyle_t, float sigma); 44 | 45 | SK_C_PLUS_PLUS_END_GUARD 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/c/sk_matrix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL 9 | // DO NOT USE -- FOR INTERNAL TESTING ONLY 10 | 11 | #ifndef sk_matrix_DEFINED 12 | #define sk_matrix_DEFINED 13 | 14 | #include "sk_types.h" 15 | 16 | SK_C_PLUS_PLUS_BEGIN_GUARD 17 | 18 | /** Set the matrix to identity */ 19 | void sk_matrix_set_identity(sk_matrix_t*); 20 | 21 | /** Set the matrix to translate by (tx, ty). */ 22 | void sk_matrix_set_translate(sk_matrix_t*, float tx, float ty); 23 | /** 24 | Preconcats the matrix with the specified translation. 25 | M' = M * T(dx, dy) 26 | */ 27 | void sk_matrix_pre_translate(sk_matrix_t*, float tx, float ty); 28 | /** 29 | Postconcats the matrix with the specified translation. 30 | M' = T(dx, dy) * M 31 | */ 32 | void sk_matrix_post_translate(sk_matrix_t*, float tx, float ty); 33 | 34 | /** Set the matrix to scale by sx and sy. */ 35 | void sk_matrix_set_scale(sk_matrix_t*, float sx, float sy); 36 | /** 37 | Preconcats the matrix with the specified scale. 38 | M' = M * S(sx, sy) 39 | */ 40 | void sk_matrix_pre_scale(sk_matrix_t*, float sx, float sy); 41 | /** 42 | Postconcats the matrix with the specified scale. 43 | M' = S(sx, sy) * M 44 | */ 45 | void sk_matrix_post_scale(sk_matrix_t*, float sx, float sy); 46 | 47 | SK_C_PLUS_PLUS_END_GUARD 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/codec/SkEncodedFormat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkEncodedFormat_DEFINED 9 | #define SkEncodedFormat_DEFINED 10 | 11 | /** 12 | * Enum describing format of encoded data. 13 | */ 14 | enum SkEncodedFormat { 15 | kUnknown_SkEncodedFormat, 16 | kBMP_SkEncodedFormat, 17 | kGIF_SkEncodedFormat, 18 | kICO_SkEncodedFormat, 19 | kJPEG_SkEncodedFormat, 20 | kPNG_SkEncodedFormat, 21 | kWBMP_SkEncodedFormat, 22 | kWEBP_SkEncodedFormat, 23 | kPKM_SkEncodedFormat, 24 | kKTX_SkEncodedFormat, 25 | kASTC_SkEncodedFormat, 26 | }; 27 | #endif // SkEncodedFormat_DEFINED 28 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/core/SkBBHFactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkBBHFactory_DEFINED 9 | #define SkBBHFactory_DEFINED 10 | 11 | #include "SkTypes.h" 12 | class SkBBoxHierarchy; 13 | struct SkRect; 14 | 15 | class SK_API SkBBHFactory { 16 | public: 17 | /** 18 | * Allocate a new SkBBoxHierarchy. Return NULL on failure. 19 | */ 20 | virtual SkBBoxHierarchy* operator()(const SkRect& bounds) const = 0; 21 | virtual ~SkBBHFactory() {}; 22 | }; 23 | 24 | class SK_API SkRTreeFactory : public SkBBHFactory { 25 | public: 26 | SkBBoxHierarchy* operator()(const SkRect& bounds) const override; 27 | private: 28 | typedef SkBBHFactory INHERITED; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/core/SkBlurTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkBlurTypes_DEFINED 9 | #define SkBlurTypes_DEFINED 10 | 11 | #include "SkTypes.h" 12 | 13 | enum SkBlurStyle { 14 | kNormal_SkBlurStyle, //!< fuzzy inside and outside 15 | kSolid_SkBlurStyle, //!< solid inside, fuzzy outside 16 | kOuter_SkBlurStyle, //!< nothing inside, fuzzy outside 17 | kInner_SkBlurStyle, //!< fuzzy inside, nothing outside 18 | 19 | kLastEnum_SkBlurStyle = kInner_SkBlurStyle 20 | }; 21 | 22 | enum SkBlurQuality { 23 | kLow_SkBlurQuality, //!< e.g. box filter 24 | kHigh_SkBlurQuality, //!< e.g. 3-pass similar to gaussian 25 | 26 | kLastEnum_SkBlurQuality 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/core/SkDrawFilter.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2011 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkDrawFilter_DEFINED 11 | #define SkDrawFilter_DEFINED 12 | 13 | #include "SkRefCnt.h" 14 | 15 | class SkCanvas; 16 | class SkPaint; 17 | 18 | /** 19 | * Right before something is being draw, filter() is called with the 20 | * paint. The filter may modify the paint as it wishes, which will then be 21 | * used for the actual drawing. Note: this modification only lasts for the 22 | * current draw, as a temporary copy of the paint is used. 23 | */ 24 | class SK_API SkDrawFilter : public SkRefCnt { 25 | public: 26 | enum Type { 27 | kPaint_Type, 28 | kPoint_Type, 29 | kLine_Type, 30 | kBitmap_Type, 31 | kRect_Type, 32 | kRRect_Type, 33 | kOval_Type, 34 | kPath_Type, 35 | kText_Type, 36 | }; 37 | 38 | enum { 39 | kTypeCount = kText_Type + 1 40 | }; 41 | 42 | /** 43 | * Called with the paint that will be used to draw the specified type. 44 | * The implementation may modify the paint as they wish. If filter() 45 | * returns false, the draw will be skipped. 46 | */ 47 | virtual bool filter(SkPaint*, Type) = 0; 48 | 49 | private: 50 | typedef SkRefCnt INHERITED; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/core/SkFilterQuality.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkFilterQuality_DEFINED 9 | #define SkFilterQuality_DEFINED 10 | 11 | #include "SkTypes.h" 12 | 13 | /** 14 | * Controls how much filtering to be done when scaling/transforming complex colors 15 | * e.g. images 16 | */ 17 | enum SkFilterQuality { 18 | kNone_SkFilterQuality, //!< fastest but lowest quality, typically nearest-neighbor 19 | kLow_SkFilterQuality, //!< typically bilerp 20 | kMedium_SkFilterQuality, //!< typically bilerp + mipmaps for down-scaling 21 | kHigh_SkFilterQuality //!< slowest but highest quality, typically bicubic or better 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/core/SkFlattenableSerialization.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkFlattenableSerialization_DEFINED 9 | #define SkFlattenableSerialization_DEFINED 10 | 11 | #include "SkFlattenable.h" 12 | 13 | class SkData; 14 | 15 | SK_API SkData* SkValidatingSerializeFlattenable(SkFlattenable*); 16 | SK_API SkFlattenable* SkValidatingDeserializeFlattenable(const void* data, size_t size, 17 | SkFlattenable::Type type); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/core/SkFontLCDConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkFontLCDConfig_DEFINED 9 | #define SkFontLCDConfig_DEFINED 10 | 11 | #include "SkTypes.h" 12 | 13 | class SkFontLCDConfig { 14 | public: 15 | /** LCDs either have their color elements arranged horizontally or 16 | vertically. When rendering subpixel glyphs we need to know which way 17 | round they are. 18 | 19 | Note, if you change this after startup, you'll need to flush the glyph 20 | cache because it'll have the wrong type of masks cached. 21 | 22 | @deprecated use SkPixelGeometry instead. 23 | */ 24 | enum LCDOrientation { 25 | kHorizontal_LCDOrientation = 0, //!< this is the default 26 | kVertical_LCDOrientation = 1 27 | }; 28 | 29 | /** @deprecated set on Device creation. */ 30 | static void SetSubpixelOrientation(LCDOrientation orientation); 31 | /** @deprecated get from Device. */ 32 | static LCDOrientation GetSubpixelOrientation(); 33 | 34 | /** LCD color elements can vary in order. For subpixel text we need to know 35 | the order which the LCDs uses so that the color fringes are in the 36 | correct place. 37 | 38 | Note, if you change this after startup, you'll need to flush the glyph 39 | cache because it'll have the wrong type of masks cached. 40 | 41 | kNONE_LCDOrder means that the subpixel elements are not spatially 42 | separated in any usable fashion. 43 | 44 | @deprecated use SkPixelGeometry instead. 45 | */ 46 | enum LCDOrder { 47 | kRGB_LCDOrder = 0, //!< this is the default 48 | kBGR_LCDOrder = 1, 49 | kNONE_LCDOrder = 2 50 | }; 51 | 52 | /** @deprecated set on Device creation. */ 53 | static void SetSubpixelOrder(LCDOrder order); 54 | /** @deprecated get from Device. */ 55 | static LCDOrder GetSubpixelOrder(); 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/core/SkFontStyle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkFontStyle_DEFINED 9 | #define SkFontStyle_DEFINED 10 | 11 | #include "SkTypes.h" 12 | 13 | class SK_API SkFontStyle { 14 | public: 15 | enum Weight { 16 | kThin_Weight = 100, 17 | kExtraLight_Weight = 200, 18 | kLight_Weight = 300, 19 | kNormal_Weight = 400, 20 | kMedium_Weight = 500, 21 | kSemiBold_Weight = 600, 22 | kBold_Weight = 700, 23 | kExtraBold_Weight = 800, 24 | kBlack_Weight = 900 25 | }; 26 | 27 | enum Width { 28 | kUltraCondensed_Width = 1, 29 | kExtraCondensed_Width = 2, 30 | kCondensed_Width = 3, 31 | kSemiCondensed_Width = 4, 32 | kNormal_Width = 5, 33 | kSemiExpanded_Width = 6, 34 | kExpanded_Width = 7, 35 | kExtraExpanded_Width = 8, 36 | kUltaExpanded_Width = 9 37 | }; 38 | 39 | enum Slant { 40 | kUpright_Slant, 41 | kItalic_Slant, 42 | }; 43 | 44 | SkFontStyle(); 45 | SkFontStyle(int weight, int width, Slant); 46 | /** oldStyle means the style-bits in SkTypeface::Style: bold=1, italic=2 */ 47 | explicit SkFontStyle(unsigned oldStyle); 48 | 49 | bool operator==(const SkFontStyle& rhs) const { 50 | return fUnion.fU32 == rhs.fUnion.fU32; 51 | } 52 | 53 | int weight() const { return fUnion.fR.fWeight; } 54 | int width() const { return fUnion.fR.fWidth; } 55 | Slant slant() const { return (Slant)fUnion.fR.fSlant; } 56 | 57 | bool isItalic() const { 58 | return kItalic_Slant == fUnion.fR.fSlant; 59 | } 60 | 61 | private: 62 | union { 63 | struct { 64 | uint16_t fWeight; // 100 .. 900 65 | uint8_t fWidth; // 1 .. 9 66 | uint8_t fSlant; // 0 .. 2 67 | } fR; 68 | uint32_t fU32; 69 | } fUnion; 70 | }; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/core/SkPackBits.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2008 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkPackBits_DEFINED 11 | #define SkPackBits_DEFINED 12 | 13 | #include "SkTypes.h" 14 | 15 | class SkPackBits { 16 | public: 17 | /** Given the number of 8bit values that will be passed to Pack8, 18 | returns the worst-case size needed for the dst[] buffer. 19 | */ 20 | static size_t ComputeMaxSize8(int count); 21 | 22 | /** Write the src array into a packed format. The packing process may end 23 | up writing more bytes than it read, so dst[] must be large enough. 24 | @param src Input array of 8bit values 25 | @param srcSize Number of entries in src[] 26 | @param dst Buffer (allocated by caller) to write the packed data 27 | into 28 | @param dstSize Number of bytes in the output buffer. 29 | @return the number of bytes written to dst[] 30 | */ 31 | static size_t Pack8(const uint8_t src[], size_t srcSize, uint8_t dst[], 32 | size_t dstSize); 33 | 34 | /** Unpack the data in src[], and expand it into dst[]. The src[] data was 35 | written by a previous call to Pack8. 36 | @param src Input data to unpack, previously created by Pack8. 37 | @param srcSize Number of bytes of src to unpack 38 | @param dst Buffer (allocated by caller) to expand the src[] into. 39 | @param dstSize Number of bytes in the output buffer. 40 | @return the number of bytes written into dst. 41 | */ 42 | static int Unpack8(const uint8_t src[], size_t srcSize, uint8_t dst[], 43 | size_t dstSize); 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/core/SkPixelSerializer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkPixelSerializer_DEFINED 9 | #define SkPixelSerializer_DEFINED 10 | 11 | #include "SkRefCnt.h" 12 | 13 | class SkData; 14 | struct SkImageInfo; 15 | 16 | /** 17 | * Interface for serializing pixels, e.g. SkBitmaps in an SkPicture. 18 | */ 19 | class SkPixelSerializer : public SkRefCnt { 20 | public: 21 | virtual ~SkPixelSerializer() {} 22 | 23 | /** 24 | * Call to determine if the client wants to serialize the encoded data. If 25 | * false, serialize another version (e.g. the result of encodePixels). 26 | */ 27 | bool useEncodedData(const void* data, size_t len) { 28 | return this->onUseEncodedData(data, len); 29 | } 30 | 31 | /** 32 | * Call to get the client's version of encoding these pixels. If it 33 | * returns NULL, serialize the raw pixels. 34 | */ 35 | SkData* encodePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes) { 36 | return this->onEncodePixels(info, pixels, rowBytes); 37 | } 38 | 39 | protected: 40 | /** 41 | * Return true if you want to serialize the encoded data, false if you want 42 | * another version serialized (e.g. the result of encodePixels). 43 | */ 44 | virtual bool onUseEncodedData(const void* data, size_t len) = 0; 45 | 46 | /** 47 | * If you want to encode these pixels, return the encoded data as an SkData 48 | * Return null if you want to serialize the raw pixels. 49 | */ 50 | virtual SkData* onEncodePixels(const SkImageInfo&, const void* pixels, size_t rowBytes) = 0; 51 | }; 52 | #endif // SkPixelSerializer_DEFINED 53 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/core/SkRSXform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkRSXform_DEFINED 9 | #define SkRSXform_DEFINED 10 | 11 | #include "SkScalar.h" 12 | 13 | /** 14 | * A compressed form of a rotation+scale matrix. 15 | * 16 | * [ fSCos -fSSin fTx ] 17 | * [ fSSin fSCos fTy ] 18 | * [ 0 0 1 ] 19 | */ 20 | struct SkRSXform { 21 | static SkRSXform Make(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty) { 22 | SkRSXform xform = { scos, ssin, tx, ty }; 23 | return xform; 24 | } 25 | 26 | /* 27 | * Initialize a new xform based on the scale, rotation (in radians), final tx,ty location 28 | * and anchor-point ax,ay within the src quad. 29 | * 30 | * Note: the anchor point is not normalized (e.g. 0...1) but is in pixels of the src image. 31 | */ 32 | static SkRSXform MakeFromRadians(SkScalar scale, SkScalar radians, SkScalar tx, SkScalar ty, 33 | SkScalar ax, SkScalar ay) { 34 | const SkScalar s = SkScalarSin(radians) * scale; 35 | const SkScalar c = SkScalarCos(radians) * scale; 36 | return Make(c, s, tx + -c * ax + s * ay, ty + -s * ax - c * ay); 37 | } 38 | 39 | SkScalar fSCos; 40 | SkScalar fSSin; 41 | SkScalar fTx; 42 | SkScalar fTy; 43 | 44 | bool rectStaysRect() const { 45 | return 0 == fSCos || 0 == fSSin; 46 | } 47 | 48 | void setIdentity() { 49 | fSCos = 1; 50 | fSSin = fTx = fTy = 0; 51 | } 52 | 53 | void set(SkScalar scos, SkScalar ssin, SkScalar tx, SkScalar ty) { 54 | fSCos = scos; 55 | fSSin = ssin; 56 | fTx = tx; 57 | fTy = ty; 58 | } 59 | 60 | void toQuad(SkScalar width, SkScalar height, SkPoint quad[4]) const; 61 | void toQuad(const SkSize& size, SkPoint quad[4]) const { 62 | this->toQuad(size.width(), size.height(), quad); 63 | } 64 | }; 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/core/SkRasterizer.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkRasterizer_DEFINED 11 | #define SkRasterizer_DEFINED 12 | 13 | #include "SkFlattenable.h" 14 | #include "SkMask.h" 15 | 16 | class SkMaskFilter; 17 | class SkMatrix; 18 | class SkPath; 19 | struct SkIRect; 20 | 21 | class SK_API SkRasterizer : public SkFlattenable { 22 | public: 23 | /** Turn the path into a mask, respecting the specified local->device matrix. 24 | */ 25 | bool rasterize(const SkPath& path, const SkMatrix& matrix, 26 | const SkIRect* clipBounds, SkMaskFilter* filter, 27 | SkMask* mask, SkMask::CreateMode mode) const; 28 | 29 | SK_DEFINE_FLATTENABLE_TYPE(SkRasterizer) 30 | 31 | protected: 32 | SkRasterizer() {} 33 | virtual bool onRasterize(const SkPath& path, const SkMatrix& matrix, 34 | const SkIRect* clipBounds, 35 | SkMask* mask, SkMask::CreateMode mode) const; 36 | 37 | private: 38 | typedef SkFlattenable INHERITED; 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/core/SkTRegistry.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2009 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkTRegistry_DEFINED 11 | #define SkTRegistry_DEFINED 12 | 13 | #include "SkTypes.h" 14 | 15 | /** Template class that registers itself (in the constructor) into a linked-list 16 | and provides a function-pointer. This can be used to auto-register a set of 17 | services, e.g. a set of image codecs. 18 | */ 19 | template class SkTRegistry : SkNoncopyable { 20 | public: 21 | typedef T Factory; 22 | 23 | explicit SkTRegistry(T fact) : fFact(fact) { 24 | #ifdef SK_BUILD_FOR_ANDROID 25 | // work-around for double-initialization bug 26 | { 27 | SkTRegistry* reg = gHead; 28 | while (reg) { 29 | if (reg == this) { 30 | return; 31 | } 32 | reg = reg->fChain; 33 | } 34 | } 35 | #endif 36 | fChain = gHead; 37 | gHead = this; 38 | } 39 | 40 | static const SkTRegistry* Head() { return gHead; } 41 | 42 | const SkTRegistry* next() const { return fChain; } 43 | const Factory& factory() const { return fFact; } 44 | 45 | private: 46 | Factory fFact; 47 | SkTRegistry* fChain; 48 | 49 | static SkTRegistry* gHead; 50 | }; 51 | 52 | // The caller still needs to declare an instance of this somewhere 53 | template SkTRegistry* SkTRegistry::gHead; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/core/SkTime.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkTime_DEFINED 11 | #define SkTime_DEFINED 12 | 13 | #include "SkTypes.h" 14 | 15 | class SkString; 16 | 17 | /** \class SkTime 18 | Platform-implemented utilities to return time of day, and millisecond counter. 19 | */ 20 | class SkTime { 21 | public: 22 | struct DateTime { 23 | int16_t fTimeZoneMinutes; // The number of minutes that GetDateTime() 24 | // is ahead of or behind UTC. 25 | uint16_t fYear; //!< e.g. 2005 26 | uint8_t fMonth; //!< 1..12 27 | uint8_t fDayOfWeek; //!< 0..6, 0==Sunday 28 | uint8_t fDay; //!< 1..31 29 | uint8_t fHour; //!< 0..23 30 | uint8_t fMinute; //!< 0..59 31 | uint8_t fSecond; //!< 0..59 32 | 33 | void toISO8601(SkString* dst) const; 34 | }; 35 | static void GetDateTime(DateTime*); 36 | 37 | static SkMSec GetMSecs() { return (SkMSec)(GetNSecs() * 1e-6); } 38 | static double GetNSecs(); 39 | }; 40 | 41 | #if defined(SK_DEBUG) && defined(SK_BUILD_FOR_WIN32) 42 | extern SkMSec gForceTickCount; 43 | #endif 44 | 45 | #define SK_TIME_FACTOR 1 46 | 47 | /////////////////////////////////////////////////////////////////////////////// 48 | 49 | class SkAutoTime { 50 | public: 51 | // The label is not deep-copied, so its address must remain valid for the 52 | // lifetime of this object 53 | SkAutoTime(const char* label = NULL, SkMSec minToDump = 0) : fLabel(label) 54 | { 55 | fNow = SkTime::GetMSecs(); 56 | fMinToDump = minToDump; 57 | } 58 | ~SkAutoTime() 59 | { 60 | SkMSec dur = SkTime::GetMSecs() - fNow; 61 | if (dur >= fMinToDump) { 62 | SkDebugf("%s %d\n", fLabel ? fLabel : "", dur); 63 | } 64 | } 65 | private: 66 | const char* fLabel; 67 | SkMSec fNow; 68 | SkMSec fMinToDump; 69 | }; 70 | #define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime) 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/core/SkUnPreMultiply.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2008 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | 11 | 12 | 13 | #ifndef SkUnPreMultiply_DEFINED 14 | #define SkUnPreMultiply_DEFINED 15 | 16 | #include "SkColor.h" 17 | 18 | class SK_API SkUnPreMultiply { 19 | public: 20 | typedef uint32_t Scale; 21 | 22 | // index this table with alpha [0..255] 23 | static const Scale* GetScaleTable() { 24 | return gTable; 25 | } 26 | 27 | static Scale GetScale(U8CPU alpha) { 28 | SkASSERT(alpha <= 255); 29 | return gTable[alpha]; 30 | } 31 | 32 | /** Usage: 33 | 34 | const Scale* table = SkUnPreMultiply::GetScaleTable(); 35 | 36 | for (...) { 37 | unsigned a = ... 38 | SkUnPreMultiply::Scale scale = table[a]; 39 | 40 | red = SkUnPreMultiply::ApplyScale(scale, red); 41 | ... 42 | // now red is unpremultiplied 43 | } 44 | */ 45 | static U8CPU ApplyScale(Scale scale, U8CPU component) { 46 | SkASSERT(component <= 255); 47 | return (scale * component + (1 << 23)) >> 24; 48 | } 49 | 50 | static SkColor PMColorToColor(SkPMColor c); 51 | 52 | static uint32_t UnPreMultiplyPreservingByteOrder(SkPMColor c); 53 | 54 | private: 55 | static const uint32_t gTable[256]; 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/device/xps/SkConstexprMath.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkConstexprMath_DEFINED 9 | #define SkConstexprMath_DEFINED 10 | 11 | #include "SkTypes.h" 12 | #include 13 | 14 | template 15 | struct SK_LOG { 16 | //! Compile-time constant ceiling(logB(N)). 17 | static const uintmax_t value = 1 + SK_LOG::value; 18 | }; 19 | template 20 | struct SK_LOG<1, B> { 21 | static const uintmax_t value = 0; 22 | }; 23 | template 24 | struct SK_LOG<0, B> { 25 | static const uintmax_t value = 0; 26 | }; 27 | 28 | template 29 | struct SK_2N1 { 30 | //! Compile-time constant (2^N)-1. 31 | static const uintmax_t value = (SK_2N1::value << 1) + 1; 32 | }; 33 | template<> 34 | struct SK_2N1<1> { 35 | static const uintmax_t value = 1; 36 | }; 37 | 38 | /** Compile-time constant number of base n digits in type t 39 | if the bits of type t are considered as unsigned base two. 40 | */ 41 | #define SK_BASE_N_DIGITS_IN(n, t) (\ 42 | SK_LOG::value, n>::value\ 43 | ) 44 | /** Compile-time constant number of base 10 digits in type t 45 | if the bits of type t are considered as unsigned base two. 46 | */ 47 | #define SK_DIGITS_IN(t) SK_BASE_N_DIGITS_IN(10, (t)) 48 | 49 | // Compile-time constant maximum value of two unsigned values. 50 | template struct SkTUMax { 51 | static const uintmax_t value = (b < a) ? a : b; 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkAlphaThresholdFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkAlphaThresholdFilter_DEFINED 9 | #define SkAlphaThresholdFilter_DEFINED 10 | 11 | #include "SkRegion.h" 12 | #include "SkImageFilter.h" 13 | 14 | class SK_API SkAlphaThresholdFilter { 15 | public: 16 | /** 17 | * Creates an image filter that samples a region. If the sample is inside the 18 | * region the alpha of the image is boosted up to a threshold value. If it is 19 | * outside the region then the alpha is decreased to the threshold value. 20 | * The 0,0 point of the region corresponds to the upper left corner of the 21 | * source image. 22 | */ 23 | static SkImageFilter* Create(const SkRegion& region, SkScalar innerThreshold, 24 | SkScalar outerThreshold, SkImageFilter* input = NULL); 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkArcToPathEffect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkArcToPathEffect_DEFINED 9 | #define SkArcToPathEffect_DEFINED 10 | 11 | #include "SkPathEffect.h" 12 | 13 | class SK_API SkArcToPathEffect : public SkPathEffect { 14 | public: 15 | /** radius must be > 0 to have an effect. It specifies the distance from each corner 16 | that should be "rounded". 17 | */ 18 | static SkPathEffect* Create(SkScalar radius) { 19 | if (radius <= 0) { 20 | return NULL; 21 | } 22 | return new SkArcToPathEffect(radius); 23 | } 24 | 25 | bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override; 26 | 27 | SK_TO_STRING_OVERRIDE() 28 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArcToPathEffect) 29 | 30 | protected: 31 | explicit SkArcToPathEffect(SkScalar radius); 32 | void flatten(SkWriteBuffer&) const override; 33 | 34 | private: 35 | SkScalar fRadius; 36 | 37 | typedef SkPathEffect INHERITED; 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkArithmeticMode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkArithmeticMode_DEFINED 9 | #define SkArithmeticMode_DEFINED 10 | 11 | #include "SkFlattenable.h" 12 | #include "SkScalar.h" 13 | 14 | class SkXfermode; 15 | 16 | class SK_API SkArithmeticMode { 17 | public: 18 | /** 19 | * result = clamp[k1 * src * dst + k2 * src + k3 * dst + k4] 20 | * 21 | * src and dst are treated as being [0.0 .. 1.0]. The polynomial is 22 | * evaluated on their unpremultiplied components. 23 | * 24 | * k1=k2=k3=0, k4=1.0 results in returning opaque white 25 | * k1=k3=k4=0, k2=1.0 results in returning the src 26 | * k1=k2=k4=0, k3=1.0 results in returning the dst 27 | */ 28 | static SkXfermode* Create(SkScalar k1, SkScalar k2, 29 | SkScalar k3, SkScalar k4, 30 | bool enforcePMColor = true); 31 | 32 | SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP(); 33 | 34 | private: 35 | SkArithmeticMode(); // can't be instantiated 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkBlurImageFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkBlurImageFilter_DEFINED 9 | #define SkBlurImageFilter_DEFINED 10 | 11 | #include "SkImageFilter.h" 12 | #include "SkSize.h" 13 | 14 | class SK_API SkBlurImageFilter : public SkImageFilter { 15 | public: 16 | static SkImageFilter* Create(SkScalar sigmaX, SkScalar sigmaY, SkImageFilter* input = NULL, 17 | const CropRect* cropRect = NULL) { 18 | return new SkBlurImageFilter(sigmaX, sigmaY, input, cropRect); 19 | } 20 | 21 | void computeFastBounds(const SkRect&, SkRect*) const override; 22 | 23 | SK_TO_STRING_OVERRIDE() 24 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurImageFilter) 25 | 26 | protected: 27 | void flatten(SkWriteBuffer&) const override; 28 | bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, 29 | SkIPoint* offset) const override; 30 | bool onFilterBounds(const SkIRect& src, const SkMatrix&, SkIRect* dst) const override; 31 | bool canFilterImageGPU() const override { return true; } 32 | bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx, SkBitmap* result, 33 | SkIPoint* offset) const override; 34 | 35 | private: 36 | SkBlurImageFilter(SkScalar sigmaX, 37 | SkScalar sigmaY, 38 | SkImageFilter* input, 39 | const CropRect* cropRect); 40 | 41 | SkSize fSigma; 42 | typedef SkImageFilter INHERITED; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkColorFilterImageFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkColorFilterImageFilter_DEFINED 9 | #define SkColorFilterImageFilter_DEFINED 10 | 11 | #include "SkImageFilter.h" 12 | 13 | class SkColorFilter; 14 | 15 | class SK_API SkColorFilterImageFilter : public SkImageFilter { 16 | public: 17 | static SkImageFilter* Create(SkColorFilter* cf, SkImageFilter* input = NULL, 18 | const CropRect* cropRect = NULL); 19 | 20 | SK_TO_STRING_OVERRIDE() 21 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorFilterImageFilter) 22 | 23 | protected: 24 | void flatten(SkWriteBuffer&) const override; 25 | bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, 26 | SkIPoint* loc) const override; 27 | bool onIsColorFilterNode(SkColorFilter**) const override; 28 | bool affectsTransparentBlack() const override; 29 | 30 | private: 31 | SkColorFilterImageFilter(SkColorFilter* cf, 32 | SkImageFilter* input, 33 | const CropRect* cropRect); 34 | virtual ~SkColorFilterImageFilter(); 35 | 36 | SkColorFilter* fColorFilter; 37 | 38 | typedef SkImageFilter INHERITED; 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkColorMatrix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkColorMatrix_DEFINED 9 | #define SkColorMatrix_DEFINED 10 | 11 | #include "SkScalar.h" 12 | 13 | class SK_API SkColorMatrix { 14 | public: 15 | enum { 16 | kCount = 20 17 | }; 18 | SkScalar fMat[kCount]; 19 | 20 | enum Elem { 21 | kR_Scale = 0, 22 | kG_Scale = 6, 23 | kB_Scale = 12, 24 | kA_Scale = 18, 25 | 26 | kR_Trans = 4, 27 | kG_Trans = 9, 28 | kB_Trans = 14, 29 | kA_Trans = 19, 30 | }; 31 | 32 | void setIdentity(); 33 | void setScale(SkScalar rScale, SkScalar gScale, SkScalar bScale, 34 | SkScalar aScale = SK_Scalar1); 35 | void preScale(SkScalar rScale, SkScalar gScale, SkScalar bScale, 36 | SkScalar aScale = SK_Scalar1); 37 | void postScale(SkScalar rScale, SkScalar gScale, SkScalar bScale, 38 | SkScalar aScale = SK_Scalar1); 39 | void postTranslate(SkScalar rTrans, SkScalar gTrans, SkScalar bTrans, 40 | SkScalar aTrans = 0); 41 | 42 | enum Axis { 43 | kR_Axis = 0, 44 | kG_Axis = 1, 45 | kB_Axis = 2 46 | }; 47 | void setRotate(Axis, SkScalar degrees); 48 | void setSinCos(Axis, SkScalar sine, SkScalar cosine); 49 | void preRotate(Axis, SkScalar degrees); 50 | void postRotate(Axis, SkScalar degrees); 51 | 52 | void setConcat(const SkColorMatrix& a, const SkColorMatrix& b); 53 | void preConcat(const SkColorMatrix& mat) { this->setConcat(*this, mat); } 54 | void postConcat(const SkColorMatrix& mat) { this->setConcat(mat, *this); } 55 | 56 | void setSaturation(SkScalar sat); 57 | void setRGB2YUV(); 58 | void setYUV2RGB(); 59 | 60 | bool operator==(const SkColorMatrix& other) const { 61 | return 0 == memcmp(fMat, other.fMat, sizeof(fMat)); 62 | } 63 | 64 | bool operator!=(const SkColorMatrix& other) const { return !((*this) == other); } 65 | 66 | static bool NeedsClamping(const SkScalar[20]); 67 | static void SetConcat(SkScalar result[20], const SkScalar outer[20], const SkScalar inner[20]); 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkColorMatrixFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkColorMatrixFilter_DEFINED 9 | #define SkColorMatrixFilter_DEFINED 10 | 11 | #include "SkColorFilter.h" 12 | #include "SkColorMatrix.h" 13 | 14 | class SK_API SkColorMatrixFilter : public SkColorFilter { 15 | public: 16 | static SkColorMatrixFilter* Create(const SkColorMatrix& cm) { 17 | return new SkColorMatrixFilter(cm); 18 | } 19 | static SkColorMatrixFilter* Create(const SkScalar array[20]) { 20 | return new SkColorMatrixFilter(array); 21 | } 22 | 23 | void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const override; 24 | uint32_t getFlags() const override; 25 | bool asColorMatrix(SkScalar matrix[20]) const override; 26 | SkColorFilter* newComposed(const SkColorFilter*) const override; 27 | 28 | #if SK_SUPPORT_GPU 29 | const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override; 30 | #endif 31 | 32 | struct State { 33 | int32_t fArray[20]; 34 | int fShift; 35 | }; 36 | 37 | SK_TO_STRING_OVERRIDE() 38 | 39 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorMatrixFilter) 40 | 41 | protected: 42 | explicit SkColorMatrixFilter(const SkColorMatrix&); 43 | explicit SkColorMatrixFilter(const SkScalar array[20]); 44 | void flatten(SkWriteBuffer&) const override; 45 | 46 | private: 47 | SkColorMatrix fMatrix; 48 | float fTranspose[SkColorMatrix::kCount]; // for Sk4s 49 | 50 | typedef void (*Proc)(const State&, unsigned r, unsigned g, unsigned b, 51 | unsigned a, int32_t result[4]); 52 | 53 | Proc fProc; 54 | State fState; 55 | uint32_t fFlags; 56 | 57 | void initState(const SkScalar array[20]); 58 | 59 | typedef SkColorFilter INHERITED; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkComposeImageFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkComposeImageFilter_DEFINED 9 | #define SkComposeImageFilter_DEFINED 10 | 11 | #include "SkImageFilter.h" 12 | 13 | class SK_API SkComposeImageFilter : public SkImageFilter { 14 | public: 15 | virtual ~SkComposeImageFilter(); 16 | 17 | static SkImageFilter* Create(SkImageFilter* outer, SkImageFilter* inner) { 18 | if (NULL == outer) { 19 | return SkSafeRef(inner); 20 | } 21 | if (NULL == inner) { 22 | return SkRef(outer); 23 | } 24 | SkImageFilter* inputs[2] = { outer, inner }; 25 | return new SkComposeImageFilter(inputs); 26 | } 27 | void computeFastBounds(const SkRect& src, SkRect* dst) const override; 28 | 29 | SK_TO_STRING_OVERRIDE() 30 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeImageFilter) 31 | 32 | protected: 33 | explicit SkComposeImageFilter(SkImageFilter* inputs[2]) : INHERITED(2, inputs) { 34 | SkASSERT(inputs[0]); 35 | SkASSERT(inputs[1]); 36 | } 37 | virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, 38 | SkBitmap* result, SkIPoint* loc) const override; 39 | bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const override; 40 | 41 | private: 42 | typedef SkImageFilter INHERITED; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkCornerPathEffect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkCornerPathEffect_DEFINED 9 | #define SkCornerPathEffect_DEFINED 10 | 11 | #include "SkPathEffect.h" 12 | 13 | /** \class SkCornerPathEffect 14 | 15 | SkCornerPathEffect is a subclass of SkPathEffect that can turn sharp corners 16 | into various treatments (e.g. rounded corners) 17 | */ 18 | class SK_API SkCornerPathEffect : public SkPathEffect { 19 | public: 20 | /** radius must be > 0 to have an effect. It specifies the distance from each corner 21 | that should be "rounded". 22 | */ 23 | static SkCornerPathEffect* Create(SkScalar radius) { return new SkCornerPathEffect(radius); } 24 | virtual ~SkCornerPathEffect(); 25 | 26 | virtual bool filterPath(SkPath* dst, const SkPath& src, 27 | SkStrokeRec*, const SkRect*) const override; 28 | 29 | SK_TO_STRING_OVERRIDE() 30 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCornerPathEffect) 31 | 32 | #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 33 | bool exposedInAndroidJavaAPI() const override { return true; } 34 | #endif 35 | 36 | protected: 37 | explicit SkCornerPathEffect(SkScalar radius); 38 | void flatten(SkWriteBuffer&) const override; 39 | 40 | private: 41 | SkScalar fRadius; 42 | 43 | typedef SkPathEffect INHERITED; 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkDrawExtraPathEffect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SK_DRAW_EXTRA_PATH_EFFECT_H 9 | #define SK_DRAW_EXTRA_PATH_EFFECT_H 10 | 11 | class SkAnimator; 12 | 13 | void InitializeSkExtraPathEffects(SkAnimator* animator); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkDropShadowImageFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #include "SkColor.h" 9 | #include "SkImageFilter.h" 10 | #include "SkScalar.h" 11 | 12 | class SK_API SkDropShadowImageFilter : public SkImageFilter { 13 | public: 14 | enum ShadowMode { 15 | kDrawShadowAndForeground_ShadowMode, 16 | kDrawShadowOnly_ShadowMode, 17 | 18 | kLast_ShadowMode = kDrawShadowOnly_ShadowMode 19 | }; 20 | 21 | static const int kShadowModeCount = kLast_ShadowMode+1; 22 | 23 | static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, 24 | SkColor color, ShadowMode shadowMode, SkImageFilter* input = NULL, 25 | const CropRect* cropRect = NULL) { 26 | return new SkDropShadowImageFilter(dx, dy, sigmaX, sigmaY, color, shadowMode, input, 27 | cropRect); 28 | } 29 | 30 | void computeFastBounds(const SkRect&, SkRect*) const override; 31 | SK_TO_STRING_OVERRIDE() 32 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter) 33 | 34 | protected: 35 | void flatten(SkWriteBuffer&) const override; 36 | bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, SkBitmap* result, 37 | SkIPoint* loc) const override; 38 | bool onFilterBounds(const SkIRect& src, const SkMatrix&, SkIRect* dst) const override; 39 | 40 | private: 41 | SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor, 42 | ShadowMode shadowMode, SkImageFilter* input, const CropRect* cropRect); 43 | 44 | SkScalar fDx, fDy, fSigmaX, fSigmaY; 45 | SkColor fColor; 46 | ShadowMode fShadowMode; 47 | 48 | typedef SkImageFilter INHERITED; 49 | }; 50 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkEmbossMaskFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkEmbossMaskFilter_DEFINED 9 | #define SkEmbossMaskFilter_DEFINED 10 | 11 | #include "SkMaskFilter.h" 12 | 13 | /** \class SkEmbossMaskFilter 14 | 15 | This mask filter creates a 3D emboss look, by specifying a light and blur amount. 16 | */ 17 | class SK_API SkEmbossMaskFilter : public SkMaskFilter { 18 | public: 19 | struct Light { 20 | SkScalar fDirection[3]; // x,y,z 21 | uint16_t fPad; 22 | uint8_t fAmbient; 23 | uint8_t fSpecular; // exponent, 4.4 right now 24 | }; 25 | 26 | static SkEmbossMaskFilter* Create(SkScalar blurSigma, const Light& light); 27 | 28 | // overrides from SkMaskFilter 29 | // This method is not exported to java. 30 | SkMask::Format getFormat() const override; 31 | // This method is not exported to java. 32 | virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, 33 | SkIPoint* margin) const override; 34 | 35 | SK_TO_STRING_OVERRIDE() 36 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmbossMaskFilter) 37 | 38 | protected: 39 | SkEmbossMaskFilter(SkScalar blurSigma, const Light& light); 40 | void flatten(SkWriteBuffer&) const override; 41 | 42 | private: 43 | Light fLight; 44 | SkScalar fBlurSigma; 45 | 46 | typedef SkMaskFilter INHERITED; 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkImageSource.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkImageSource_DEFINED 9 | #define SkImageSource_DEFINED 10 | 11 | #include "SkImageFilter.h" 12 | 13 | class SkImage; 14 | 15 | class SK_API SkImageSource : public SkImageFilter { 16 | public: 17 | static SkImageFilter* Create(const SkImage*); 18 | static SkImageFilter* Create(const SkImage*, 19 | const SkRect& srcRect, 20 | const SkRect& dstRect, 21 | SkFilterQuality); 22 | 23 | void computeFastBounds(const SkRect& src, SkRect* dst) const override; 24 | 25 | SK_TO_STRING_OVERRIDE() 26 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageSource) 27 | 28 | protected: 29 | void flatten(SkWriteBuffer&) const override; 30 | 31 | bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, 32 | SkBitmap* result, SkIPoint* offset) const override; 33 | 34 | private: 35 | explicit SkImageSource(const SkImage*); 36 | SkImageSource(const SkImage*, 37 | const SkRect& srcRect, 38 | const SkRect& dstRect, 39 | SkFilterQuality); 40 | 41 | SkAutoTUnref fImage; 42 | SkRect fSrcRect, fDstRect; 43 | SkFilterQuality fFilterQuality; 44 | 45 | typedef SkImageFilter INHERITED; 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkLerpXfermode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkLerpXfermode_DEFINED 9 | #define SkLerpXfermode_DEFINED 10 | 11 | #include "SkXfermode.h" 12 | 13 | class SK_API SkLerpXfermode : public SkXfermode { 14 | public: 15 | /** 16 | * result = scale * src + (1 - scale) * dst 17 | * 18 | * When scale == 1, this is the same as kSrc_Mode 19 | * When scale == 0, this is the same as kDst_Mode 20 | */ 21 | static SkXfermode* Create(SkScalar scale); 22 | 23 | // overrides from SkXfermode 24 | virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, 25 | const SkAlpha aa[]) const override; 26 | virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, 27 | const SkAlpha aa[]) const override; 28 | virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, 29 | const SkAlpha aa[]) const override; 30 | 31 | SK_TO_STRING_OVERRIDE() 32 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLerpXfermode) 33 | 34 | protected: 35 | void flatten(SkWriteBuffer&) const override; 36 | 37 | private: 38 | SkLerpXfermode(unsigned scale256); 39 | 40 | unsigned fScale256; // 0..256 41 | 42 | typedef SkXfermode INHERITED; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkLumaColorFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkLumaColorFilter_DEFINED 9 | #define SkLumaColorFilter_DEFINED 10 | 11 | #include "SkColorFilter.h" 12 | 13 | /** 14 | * Luminance-to-alpha color filter, as defined in 15 | * http://www.w3.org/TR/SVG/masking.html#Masking 16 | * http://www.w3.org/TR/css-masking/#MaskValues 17 | * 18 | * The resulting color is black with transparency equal to the 19 | * luminance value modulated by alpha: 20 | * 21 | * C' = [ Lum * a, 0, 0, 0 ] 22 | * 23 | */ 24 | class SK_API SkLumaColorFilter : public SkColorFilter { 25 | public: 26 | static SkColorFilter* Create(); 27 | 28 | void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const override; 29 | 30 | #if SK_SUPPORT_GPU 31 | const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override; 32 | #endif 33 | 34 | SK_TO_STRING_OVERRIDE() 35 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLumaColorFilter) 36 | 37 | protected: 38 | void flatten(SkWriteBuffer&) const override; 39 | 40 | private: 41 | SkLumaColorFilter(); 42 | 43 | typedef SkColorFilter INHERITED; 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkMagnifierImageFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | 9 | #ifndef SkMagnifierImageFilter_DEFINED 10 | #define SkMagnifierImageFilter_DEFINED 11 | 12 | #include "SkRect.h" 13 | #include "SkImageFilter.h" 14 | 15 | class SK_API SkMagnifierImageFilter : public SkImageFilter { 16 | public: 17 | static SkImageFilter* Create(const SkRect& src, SkScalar inset, SkImageFilter* input = NULL); 18 | 19 | SK_TO_STRING_OVERRIDE() 20 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMagnifierImageFilter) 21 | 22 | protected: 23 | SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset, SkImageFilter* input); 24 | void flatten(SkWriteBuffer&) const override; 25 | 26 | bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, 27 | SkBitmap* result, SkIPoint* offset) const override; 28 | #if SK_SUPPORT_GPU 29 | bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&, 30 | const SkIRect& bounds) const override; 31 | #endif 32 | 33 | private: 34 | SkRect fSrcRect; 35 | SkScalar fInset; 36 | typedef SkImageFilter INHERITED; 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkMergeImageFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkMergeImageFilter_DEFINED 9 | #define SkMergeImageFilter_DEFINED 10 | 11 | #include "SkImageFilter.h" 12 | 13 | #include "SkXfermode.h" 14 | 15 | class SK_API SkMergeImageFilter : public SkImageFilter { 16 | public: 17 | virtual ~SkMergeImageFilter(); 18 | 19 | static SkImageFilter* Create(SkImageFilter* first, SkImageFilter* second, 20 | SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode, 21 | const CropRect* cropRect = NULL) { 22 | SkImageFilter* inputs[2] = { first, second }; 23 | SkXfermode::Mode modes[2] = { mode, mode }; 24 | return new SkMergeImageFilter(inputs, 2, modes, cropRect); 25 | } 26 | 27 | static SkImageFilter* Create(SkImageFilter* filters[], int count, 28 | const SkXfermode::Mode modes[] = NULL, 29 | const CropRect* cropRect = NULL) { 30 | return new SkMergeImageFilter(filters, count, modes, cropRect); 31 | } 32 | 33 | SK_TO_STRING_OVERRIDE() 34 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter) 35 | 36 | protected: 37 | void flatten(SkWriteBuffer&) const override; 38 | bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, 39 | SkIPoint* loc) const override; 40 | 41 | private: 42 | SkMergeImageFilter(SkImageFilter* filters[], int count, const SkXfermode::Mode modes[], 43 | const CropRect* cropRect); 44 | 45 | uint8_t* fModes; // SkXfermode::Mode 46 | 47 | // private storage, to avoid dynamically allocating storage for our copy 48 | // of the modes (unless the count is so large we can't fit). 49 | intptr_t fStorage[16]; 50 | 51 | void initAllocModes(); 52 | void initModes(const SkXfermode::Mode []); 53 | 54 | typedef SkImageFilter INHERITED; 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkModeColorFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkModeColorFilter_DEFINED 9 | #define SkModeColorFilter_DEFINED 10 | 11 | #include "SkColorFilter.h" 12 | #include "SkColorPriv.h" 13 | #include "SkString.h" 14 | #include "SkXfermode.h" 15 | 16 | class SkModeColorFilter : public SkColorFilter { 17 | public: 18 | static SkColorFilter* Create(SkColor color, SkXfermode::Mode mode) { 19 | return new SkModeColorFilter(color, mode); 20 | } 21 | 22 | SkColor getColor() const { return fColor; } 23 | SkXfermode::Mode getMode() const { return fMode; } 24 | SkPMColor getPMColor() const { return fPMColor; } 25 | 26 | bool asColorMode(SkColor*, SkXfermode::Mode*) const override; 27 | uint32_t getFlags() const override; 28 | void filterSpan(const SkPMColor shader[], int count, SkPMColor result[]) const override; 29 | 30 | #ifndef SK_IGNORE_TO_STRING 31 | void toString(SkString* str) const override { 32 | str->append("SkModeColorFilter: color: 0x"); 33 | str->appendHex(fColor); 34 | str->append(" mode: "); 35 | str->append(SkXfermode::ModeName(fMode)); 36 | } 37 | #endif 38 | 39 | #if SK_SUPPORT_GPU 40 | const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override; 41 | #endif 42 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkModeColorFilter) 43 | 44 | protected: 45 | SkModeColorFilter(SkColor color, SkXfermode::Mode mode) { 46 | fColor = color; 47 | fMode = mode; 48 | this->updateCache(); 49 | }; 50 | 51 | void flatten(SkWriteBuffer&) const override; 52 | 53 | private: 54 | SkColor fColor; 55 | SkXfermode::Mode fMode; 56 | // cache 57 | SkPMColor fPMColor; 58 | SkXfermodeProc fProc; 59 | 60 | void updateCache(); 61 | 62 | typedef SkColorFilter INHERITED; 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkOffsetImageFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkOffsetImageFilter_DEFINED 9 | #define SkOffsetImageFilter_DEFINED 10 | 11 | #include "SkImageFilter.h" 12 | #include "SkPoint.h" 13 | 14 | class SK_API SkOffsetImageFilter : public SkImageFilter { 15 | public: 16 | static SkImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input = NULL, 17 | const CropRect* cropRect = NULL) { 18 | if (!SkScalarIsFinite(dx) || !SkScalarIsFinite(dy)) { 19 | return NULL; 20 | } 21 | return new SkOffsetImageFilter(dx, dy, input, cropRect); 22 | } 23 | 24 | void computeFastBounds(const SkRect& src, SkRect* dst) const override; 25 | 26 | SK_TO_STRING_OVERRIDE() 27 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOffsetImageFilter) 28 | 29 | protected: 30 | void flatten(SkWriteBuffer&) const override; 31 | bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, 32 | SkIPoint* loc) const override; 33 | bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const override; 34 | 35 | private: 36 | SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input, const CropRect*); 37 | 38 | SkVector fOffset; 39 | 40 | typedef SkImageFilter INHERITED; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkPaintFlagsDrawFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkPaintFlagsDrawFilter_DEFINED 9 | #define SkPaintFlagsDrawFilter_DEFINED 10 | 11 | #include "SkDrawFilter.h" 12 | 13 | class SK_API SkPaintFlagsDrawFilter : public SkDrawFilter { 14 | public: 15 | SkPaintFlagsDrawFilter(uint32_t clearFlags, uint32_t setFlags); 16 | 17 | bool filter(SkPaint*, Type) override; 18 | 19 | private: 20 | uint16_t fClearFlags; // user specified 21 | uint16_t fSetFlags; // user specified 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkPixelXorXfermode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkPixelXorXfermode_DEFINED 9 | #define SkPixelXorXfermode_DEFINED 10 | 11 | #include "SkXfermode.h" 12 | 13 | /** SkPixelXorXfermode implements a simple pixel xor (op ^ src ^ dst). 14 | This transformation does not follow premultiplied conventions, therefore 15 | this proc *always* returns an opaque color (alpha == 255). Thus it is 16 | not really usefull for operating on blended colors. 17 | */ 18 | class SK_API SkPixelXorXfermode : public SkXfermode { 19 | public: 20 | static SkXfermode* Create(SkColor opColor) { return new SkPixelXorXfermode(opColor); } 21 | 22 | SK_TO_STRING_OVERRIDE() 23 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPixelXorXfermode) 24 | 25 | protected: 26 | void flatten(SkWriteBuffer&) const override; 27 | SkPMColor xferColor(SkPMColor src, SkPMColor dst) const override; 28 | 29 | private: 30 | explicit SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {} 31 | 32 | SkColor fOpColor; 33 | 34 | typedef SkXfermode INHERITED; 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkRectShaderImageFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkRectShaderImageFilter_DEFINED 9 | #define SkRectShaderImageFilter_DEFINED 10 | 11 | #include "SkImageFilter.h" 12 | #include "SkRect.h" 13 | 14 | class SkShader; 15 | 16 | class SK_API SkRectShaderImageFilter : public SkImageFilter { 17 | public: 18 | /** Create a new image filter which fills the given rectangle with pixels 19 | * produced by the given SkShader. If no rectangle is specified, an output 20 | * is produced with the same bounds as the input primitive (even though 21 | * the input primitive's pixels are not used for processing). 22 | * @param s Shader to call for processing. Cannot be NULL. Will be 23 | * ref'ed by the new image filter. 24 | * @param rect Rectangle of output pixels in which to apply the shader. 25 | * If NULL or a given crop edge is not specified, the source 26 | * primitive's bounds are used instead. 27 | */ 28 | SK_ATTR_DEPRECATED("use Create(SkShader*, const CropRect*)") 29 | static SkImageFilter* Create(SkShader* s, const SkRect& rect); 30 | static SkImageFilter* Create(SkShader* s, const CropRect* rect = NULL); 31 | 32 | bool affectsTransparentBlack() const override; 33 | 34 | SK_TO_STRING_OVERRIDE() 35 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShaderImageFilter) 36 | 37 | protected: 38 | virtual ~SkRectShaderImageFilter(); 39 | 40 | void flatten(SkWriteBuffer&) const override; 41 | bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, 42 | SkIPoint* loc) const override; 43 | 44 | private: 45 | SkRectShaderImageFilter(SkShader* s, const CropRect* rect); 46 | 47 | SkShader* fShader; 48 | 49 | typedef SkImageFilter INHERITED; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkTableColorFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkTableColorFilter_DEFINED 9 | #define SkTableColorFilter_DEFINED 10 | 11 | #include "SkColorFilter.h" 12 | 13 | class SK_API SkTableColorFilter { 14 | public: 15 | /** 16 | * Create a table colorfilter, copying the table into the filter, and 17 | * applying it to all 4 components. 18 | * a' = table[a]; 19 | * r' = table[r]; 20 | * g' = table[g]; 21 | * b' = table[b]; 22 | * Compoents are operated on in unpremultiplied space. If the incomming 23 | * colors are premultiplied, they are temporarily unpremultiplied, then 24 | * the table is applied, and then the result is remultiplied. 25 | */ 26 | static SkColorFilter* Create(const uint8_t table[256]); 27 | 28 | /** 29 | * Create a table colorfilter, with a different table for each 30 | * component [A, R, G, B]. If a given table is NULL, then it is 31 | * treated as identity, with the component left unchanged. If a table 32 | * is not null, then its contents are copied into the filter. 33 | */ 34 | static SkColorFilter* CreateARGB(const uint8_t tableA[256], 35 | const uint8_t tableR[256], 36 | const uint8_t tableG[256], 37 | const uint8_t tableB[256]); 38 | 39 | SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP() 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkTableMaskFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkTableMaskFilter_DEFINED 9 | #define SkTableMaskFilter_DEFINED 10 | 11 | #include "SkMaskFilter.h" 12 | #include "SkScalar.h" 13 | 14 | /** \class SkTableMaskFilter 15 | 16 | Applies a table lookup on each of the alpha values in the mask. 17 | Helper methods create some common tables (e.g. gamma, clipping) 18 | */ 19 | class SK_API SkTableMaskFilter : public SkMaskFilter { 20 | public: 21 | /** Utility that sets the gamma table 22 | */ 23 | static void MakeGammaTable(uint8_t table[256], SkScalar gamma); 24 | 25 | /** Utility that creates a clipping table: clamps values below min to 0 26 | and above max to 255, and rescales the remaining into 0..255 27 | */ 28 | static void MakeClipTable(uint8_t table[256], uint8_t min, uint8_t max); 29 | 30 | static SkMaskFilter* Create(const uint8_t table[256]) { 31 | return new SkTableMaskFilter(table); 32 | } 33 | 34 | static SkMaskFilter* CreateGamma(SkScalar gamma) { 35 | uint8_t table[256]; 36 | MakeGammaTable(table, gamma); 37 | return new SkTableMaskFilter(table); 38 | } 39 | 40 | static SkMaskFilter* CreateClip(uint8_t min, uint8_t max) { 41 | uint8_t table[256]; 42 | MakeClipTable(table, min, max); 43 | return new SkTableMaskFilter(table); 44 | } 45 | 46 | SkMask::Format getFormat() const override; 47 | bool filterMask(SkMask*, const SkMask&, const SkMatrix&, SkIPoint*) const override; 48 | 49 | SK_TO_STRING_OVERRIDE() 50 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTableMaskFilter) 51 | 52 | protected: 53 | virtual ~SkTableMaskFilter(); 54 | 55 | void flatten(SkWriteBuffer&) const override; 56 | 57 | private: 58 | SkTableMaskFilter(); 59 | explicit SkTableMaskFilter(const uint8_t table[256]); 60 | 61 | uint8_t fTable[256]; 62 | 63 | typedef SkMaskFilter INHERITED; 64 | }; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkTestImageFilters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef _SkTestImageFilters_h 9 | #define _SkTestImageFilters_h 10 | 11 | #include "SkImageFilter.h" 12 | #include "SkPoint.h" 13 | 14 | // Fun mode that scales down (only) and then scales back up to look pixelated 15 | class SK_API SkDownSampleImageFilter : public SkImageFilter { 16 | public: 17 | static SkImageFilter* Create(SkScalar scale, SkImageFilter* input = NULL) { 18 | if (!SkScalarIsFinite(scale)) { 19 | return NULL; 20 | } 21 | // we don't support scale in this range 22 | if (scale > SK_Scalar1 || scale <= 0) { 23 | return NULL; 24 | } 25 | return new SkDownSampleImageFilter(scale, input); 26 | } 27 | 28 | SK_TO_STRING_OVERRIDE() 29 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDownSampleImageFilter) 30 | 31 | protected: 32 | void flatten(SkWriteBuffer&) const override; 33 | bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result, 34 | SkIPoint* loc) const override; 35 | 36 | private: 37 | SkDownSampleImageFilter(SkScalar scale, SkImageFilter* input) 38 | : INHERITED(1, &input), fScale(scale) {} 39 | 40 | SkScalar fScale; 41 | 42 | typedef SkImageFilter INHERITED; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkTileImageFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkTileImageFilter_DEFINED 9 | #define SkTileImageFilter_DEFINED 10 | 11 | #include "SkImageFilter.h" 12 | 13 | class SK_API SkTileImageFilter : public SkImageFilter { 14 | typedef SkImageFilter INHERITED; 15 | 16 | public: 17 | /** Create a tile image filter 18 | @param src Defines the pixels to tile 19 | @param dst Defines the pixels where tiles are drawn 20 | @param input Input from which the subregion defined by srcRect will be tiled 21 | */ 22 | static SkImageFilter* Create(const SkRect& src, const SkRect& dst, SkImageFilter* input); 23 | 24 | bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context& ctx, 25 | SkBitmap* dst, SkIPoint* offset) const override; 26 | bool onFilterBounds(const SkIRect& src, const SkMatrix&, 27 | SkIRect* dst) const override; 28 | void computeFastBounds(const SkRect& src, SkRect* dst) const override; 29 | 30 | SK_TO_STRING_OVERRIDE() 31 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter) 32 | 33 | protected: 34 | void flatten(SkWriteBuffer& buffer) const override; 35 | 36 | private: 37 | SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input) 38 | : INHERITED(1, &input, NULL), fSrcRect(srcRect), fDstRect(dstRect) {} 39 | 40 | SkRect fSrcRect; 41 | SkRect fDstRect; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/effects/SkXfermodeImageFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkXfermodeImageFilter_DEFINED 9 | #define SkXfermodeImageFilter_DEFINED 10 | 11 | #include "SkImageFilter.h" 12 | 13 | class SkBitmap; 14 | class SkXfermode; 15 | 16 | class SK_API SkXfermodeImageFilter : public SkImageFilter { 17 | /** 18 | * This filter takes an xfermode, and uses it to composite the foreground 19 | * over the background. If foreground or background is NULL, the input 20 | * bitmap (src) is used instead. 21 | */ 22 | 23 | public: 24 | virtual ~SkXfermodeImageFilter(); 25 | 26 | static SkXfermodeImageFilter* Create(SkXfermode* mode, SkImageFilter* background, 27 | SkImageFilter* foreground = NULL, 28 | const CropRect* cropRect = NULL) { 29 | SkImageFilter* inputs[2] = { background, foreground }; 30 | return new SkXfermodeImageFilter(mode, inputs, cropRect); 31 | } 32 | 33 | SK_TO_STRING_OVERRIDE() 34 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter) 35 | 36 | bool onFilterImage(Proxy* proxy, 37 | const SkBitmap& src, 38 | const Context& ctx, 39 | SkBitmap* dst, 40 | SkIPoint* offset) const override; 41 | #if SK_SUPPORT_GPU 42 | bool canFilterImageGPU() const override; 43 | bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx, 44 | SkBitmap* result, SkIPoint* offset) const override; 45 | #endif 46 | 47 | protected: 48 | SkXfermodeImageFilter(SkXfermode* mode, SkImageFilter* inputs[2], 49 | const CropRect* cropRect); 50 | void flatten(SkWriteBuffer&) const override; 51 | 52 | private: 53 | SkXfermode* fMode; 54 | typedef SkImageFilter INHERITED; 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/GrContextOptions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef GrContextOptions_DEFINED 9 | #define GrContextOptions_DEFINED 10 | 11 | #include "SkTypes.h" 12 | 13 | struct GrContextOptions { 14 | GrContextOptions() 15 | : fDrawPathToCompressedTexture(false) 16 | , fSuppressPrints(false) 17 | , fMaxTextureSizeOverride(SK_MaxS32) 18 | , fMaxTileSizeOverride(0) 19 | , fSuppressDualSourceBlending(false) 20 | , fGeometryBufferMapThreshold(-1) 21 | , fUseDrawInsteadOfPartialRenderTargetWrite(false) 22 | , fImmediateMode(false) 23 | , fUseShaderSwizzling(false) {} 24 | 25 | // EXPERIMENTAL 26 | // May be removed in the future, or may become standard depending 27 | // on the outcomes of a variety of internal tests. 28 | bool fDrawPathToCompressedTexture; 29 | 30 | // Suppress prints for the GrContext. 31 | bool fSuppressPrints; 32 | 33 | /** Overrides: These options override feature detection using backend API queries. These 34 | overrides can only reduce the feature set or limits, never increase them beyond the 35 | detected values. */ 36 | 37 | int fMaxTextureSizeOverride; 38 | /** If non-zero, overrides the maximum size of a tile for sw-backed images and bitmaps rendered 39 | by SkGpuDevice. */ 40 | int fMaxTileSizeOverride; 41 | bool fSuppressDualSourceBlending; 42 | 43 | /** the threshold in bytes above which we will use a buffer mapping API to map vertex and index 44 | buffers to CPU memory in order to update them. A value of -1 means the GrContext should 45 | deduce the optimal value for this platform. */ 46 | int fGeometryBufferMapThreshold; 47 | 48 | /** some gpus have problems with partial writes of the rendertarget */ 49 | bool fUseDrawInsteadOfPartialRenderTargetWrite; 50 | 51 | /** The GrContext operates in immedidate mode. It will issue all draws to the backend API 52 | immediately. Intended to ease debugging. */ 53 | bool fImmediateMode; 54 | 55 | /** Force us to do all swizzling manually in the shader and don't rely on extensions to do 56 | swizzling. */ 57 | bool fUseShaderSwizzling; 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/GrRect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef GrRect_DEFINED 9 | #define GrRect_DEFINED 10 | 11 | #include "SkTypes.h" 12 | #include "SkRect.h" 13 | 14 | struct GrIRect16 { 15 | int16_t fLeft, fTop, fRight, fBottom; 16 | 17 | static GrIRect16 SK_WARN_UNUSED_RESULT MakeEmpty() { 18 | GrIRect16 r; 19 | r.setEmpty(); 20 | return r; 21 | } 22 | 23 | static GrIRect16 SK_WARN_UNUSED_RESULT MakeWH(int16_t w, int16_t h) { 24 | GrIRect16 r; 25 | r.set(0, 0, w, h); 26 | return r; 27 | } 28 | 29 | static GrIRect16 SK_WARN_UNUSED_RESULT MakeXYWH(int16_t x, int16_t y, int16_t w, int16_t h) { 30 | GrIRect16 r; 31 | r.set(x, y, x + w, y + h); 32 | return r; 33 | } 34 | 35 | int width() const { return fRight - fLeft; } 36 | int height() const { return fBottom - fTop; } 37 | int area() const { return this->width() * this->height(); } 38 | bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; } 39 | 40 | void setEmpty() { memset(this, 0, sizeof(*this)); } 41 | 42 | void set(int16_t left, int16_t top, int16_t right, int16_t bottom) { 43 | fLeft = left; 44 | fTop = top; 45 | fRight = right; 46 | fBottom = bottom; 47 | } 48 | 49 | void set(const SkIRect& r) { 50 | fLeft = SkToS16(r.fLeft); 51 | fTop = SkToS16(r.fTop); 52 | fRight = SkToS16(r.fRight); 53 | fBottom = SkToS16(r.fBottom); 54 | } 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/GrTexture.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2011 Google Inc. 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | #ifndef GrTexture_DEFINED 10 | #define GrTexture_DEFINED 11 | 12 | #include "GrSurface.h" 13 | #include "SkPoint.h" 14 | #include "SkRefCnt.h" 15 | 16 | class GrTextureParams; 17 | class GrTexturePriv; 18 | 19 | class GrTexture : virtual public GrSurface { 20 | public: 21 | GrTexture* asTexture() override { return this; } 22 | const GrTexture* asTexture() const override { return this; } 23 | 24 | /** 25 | * Return the native ID or handle to the texture, depending on the 26 | * platform. e.g. on OpenGL, return the texture ID. 27 | */ 28 | virtual GrBackendObject getTextureHandle() const = 0; 29 | 30 | /** 31 | * This function indicates that the texture parameters (wrap mode, filtering, ...) have been 32 | * changed externally to Skia. 33 | */ 34 | virtual void textureParamsModified() = 0; 35 | 36 | #ifdef SK_DEBUG 37 | void validate() const { 38 | this->INHERITED::validate(); 39 | this->validateDesc(); 40 | } 41 | #endif 42 | 43 | /** Access methods that are only to be used within Skia code. */ 44 | inline GrTexturePriv texturePriv(); 45 | inline const GrTexturePriv texturePriv() const; 46 | 47 | protected: 48 | GrTexture(GrGpu*, LifeCycle, const GrSurfaceDesc&); 49 | 50 | void validateDesc() const; 51 | 52 | private: 53 | size_t onGpuMemorySize() const override; 54 | void dirtyMipMaps(bool mipMapsDirty); 55 | 56 | enum MipMapsStatus { 57 | kNotAllocated_MipMapsStatus, 58 | kAllocated_MipMapsStatus, 59 | kValid_MipMapsStatus 60 | }; 61 | 62 | MipMapsStatus fMipMapsStatus; 63 | // These two shift a fixed-point value into normalized coordinates 64 | // for this texture if the texture is power of two sized. 65 | int fShiftFixedX; 66 | int fShiftFixedY; 67 | 68 | friend class GrTexturePriv; 69 | 70 | typedef GrSurface INHERITED; 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/SkGrPixelRef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkGrPixelRef_DEFINED 9 | #define SkGrPixelRef_DEFINED 10 | 11 | #include "SkBitmap.h" 12 | #include "SkPixelRef.h" 13 | #include "GrTexture.h" 14 | #include "GrRenderTarget.h" 15 | 16 | 17 | /** 18 | * Common baseclass that implements onLockPixels() by calling onReadPixels(). 19 | * Since it has a copy, it always returns false for onLockPixelsAreWritable(). 20 | */ 21 | class SK_API SkROLockPixelsPixelRef : public SkPixelRef { 22 | public: 23 | SkROLockPixelsPixelRef(const SkImageInfo&); 24 | virtual ~SkROLockPixelsPixelRef(); 25 | 26 | protected: 27 | bool onNewLockPixels(LockRec*) override; 28 | void onUnlockPixels() override; 29 | bool onLockPixelsAreWritable() const override; // return false; 30 | 31 | private: 32 | SkBitmap fBitmap; 33 | typedef SkPixelRef INHERITED; 34 | }; 35 | 36 | /** 37 | * PixelRef that wraps a GrSurface 38 | */ 39 | class SK_API SkGrPixelRef : public SkROLockPixelsPixelRef { 40 | public: 41 | /** 42 | * Constructs a pixel ref around a GrSurface. 43 | */ 44 | SkGrPixelRef(const SkImageInfo&, GrSurface*); 45 | virtual ~SkGrPixelRef(); 46 | 47 | // override from SkPixelRef 48 | GrTexture* getTexture() override; 49 | 50 | protected: 51 | // overrides from SkPixelRef 52 | bool onReadPixels(SkBitmap* dst, const SkIRect* subset) override; 53 | SkPixelRef* deepCopy(SkColorType, SkColorProfileType, 54 | const SkIRect* subset) override; 55 | void onNotifyPixelsChanged() override; 56 | 57 | private: 58 | GrSurface* fSurface; 59 | typedef SkROLockPixelsPixelRef INHERITED; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/SkGrTexturePixelRef.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2010 Google Inc. 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | 11 | #ifndef SkGrTexturePixelRef_DEFINED 12 | #define SkGrTexturePixelRef_DEFINED 13 | 14 | #include "SkGrPixelRef.h" 15 | 16 | typedef SkGrPixelRef SkGrTexturePixelRef; 17 | typedef SkGrPixelRef SkGrRenderTargetPixelRef; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/effects/GrConstColorProcessor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef GrColorProcessor_DEFINED 9 | #define GrColorProcessor_DEFINED 10 | 11 | #include "GrFragmentProcessor.h" 12 | 13 | /** 14 | * This is a simple GrFragmentProcessor that outputs a constant color. It may do one of the 15 | * following with its input color: ignore it, or multiply it by the constant color, multiply its 16 | * alpha by the constant color and ignore the input color's r, g, and b. 17 | */ 18 | class GrConstColorProcessor : public GrFragmentProcessor { 19 | public: 20 | enum InputMode { 21 | kIgnore_InputMode, 22 | kModulateRGBA_InputMode, 23 | kModulateA_InputMode, 24 | 25 | kLastInputMode = kModulateA_InputMode 26 | }; 27 | static const int kInputModeCnt = kLastInputMode + 1; 28 | 29 | static GrFragmentProcessor* Create(GrColor color, InputMode mode) { 30 | return new GrConstColorProcessor(color, mode); 31 | } 32 | 33 | const char* name() const override { return "Color"; } 34 | 35 | GrColor color() const { return fColor; } 36 | 37 | InputMode inputMode() const { return fMode; } 38 | 39 | private: 40 | GrConstColorProcessor(GrColor color, InputMode mode) : fColor(color), fMode(mode) { 41 | this->initClassID(); 42 | } 43 | 44 | GrGLFragmentProcessor* onCreateGLInstance() const override; 45 | 46 | void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override; 47 | 48 | bool onIsEqual(const GrFragmentProcessor&) const override; 49 | 50 | void onComputeInvariantOutput(GrInvariantOutput* inout) const override; 51 | 52 | GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 53 | 54 | GrColor fColor; 55 | InputMode fMode; 56 | 57 | typedef GrFragmentProcessor INHERITED; 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/effects/GrCoverageSetOpXP.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef GrCoverageSetOpXP_DEFINED 9 | #define GrCoverageSetOpXP_DEFINED 10 | 11 | #include "GrTypes.h" 12 | #include "GrXferProcessor.h" 13 | #include "SkRegion.h" 14 | 15 | class GrProcOptInfo; 16 | 17 | /** 18 | * This xfer processor directly blends the the src coverage with the dst using a set operator. It is 19 | * useful for rendering coverage masks using CSG. It can optionally invert the src coverage before 20 | * applying the set operator. 21 | */ 22 | class GrCoverageSetOpXPFactory : public GrXPFactory { 23 | public: 24 | static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = false); 25 | 26 | bool supportsRGBCoverage(GrColor /*knownColor*/, 27 | uint32_t /*knownColorFlags*/) const override { 28 | return true; 29 | } 30 | 31 | void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, 32 | GrXPFactory::InvariantBlendedColor*) const override; 33 | 34 | private: 35 | GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage); 36 | 37 | GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, 38 | const GrProcOptInfo& colorPOI, 39 | const GrProcOptInfo& coveragePOI, 40 | bool hasMixedSamples, 41 | const DstTexture*) const override; 42 | 43 | bool willReadDstColor(const GrCaps& /*caps*/, 44 | const GrProcOptInfo& /*colorPOI*/, 45 | const GrProcOptInfo& /*coveragePOI*/, 46 | bool /*hasMixedSamples*/) const override { 47 | return false; 48 | } 49 | 50 | bool onIsEqual(const GrXPFactory& xpfBase) const override { 51 | const GrCoverageSetOpXPFactory& xpf = xpfBase.cast(); 52 | return fRegionOp == xpf.fRegionOp; 53 | } 54 | 55 | GR_DECLARE_XP_FACTORY_TEST; 56 | 57 | SkRegion::Op fRegionOp; 58 | bool fInvertCoverage; 59 | 60 | typedef GrXPFactory INHERITED; 61 | }; 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/effects/GrCustomXfermode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef GrCustomXfermode_DEFINED 9 | #define GrCustomXfermode_DEFINED 10 | 11 | #include "SkXfermode.h" 12 | 13 | class GrTexture; 14 | 15 | /** 16 | * Custom Xfer modes are used for blending when the blend mode cannot be represented using blend 17 | * coefficients. 18 | */ 19 | namespace GrCustomXfermode { 20 | bool IsSupportedMode(SkXfermode::Mode mode); 21 | GrXPFactory* CreateXPFactory(SkXfermode::Mode mode); 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/effects/GrPorterDuffXferProcessor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef GrPorterDuffXferProcessor_DEFINED 9 | #define GrPorterDuffXferProcessor_DEFINED 10 | 11 | #include "GrTypes.h" 12 | #include "GrXferProcessor.h" 13 | #include "SkXfermode.h" 14 | 15 | class GrProcOptInfo; 16 | 17 | class GrPorterDuffXPFactory : public GrXPFactory { 18 | public: 19 | static GrXPFactory* Create(SkXfermode::Mode mode); 20 | 21 | bool supportsRGBCoverage(GrColor /*knownColor*/, uint32_t /*knownColorFlags*/) const override { 22 | return true; 23 | } 24 | 25 | void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, 26 | GrXPFactory::InvariantBlendedColor*) const override; 27 | 28 | private: 29 | GrPorterDuffXPFactory(SkXfermode::Mode); 30 | 31 | GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, 32 | const GrProcOptInfo& colorPOI, 33 | const GrProcOptInfo& coveragePOI, 34 | bool hasMixedSamples, 35 | const DstTexture*) const override; 36 | 37 | bool willReadDstColor(const GrCaps& caps, 38 | const GrProcOptInfo& colorPOI, 39 | const GrProcOptInfo& coveragePOI, 40 | bool hasMixedSamples) const override; 41 | 42 | bool onIsEqual(const GrXPFactory& xpfBase) const override { 43 | const GrPorterDuffXPFactory& xpf = xpfBase.cast(); 44 | return fXfermode == xpf.fXfermode; 45 | } 46 | 47 | GR_DECLARE_XP_FACTORY_TEST; 48 | static void TestGetXPOutputTypes(const GrXferProcessor*, int* outPrimary, int* outSecondary); 49 | 50 | SkXfermode::Mode fXfermode; 51 | 52 | friend class GrPorterDuffTest; // for TestGetXPOutputTypes() 53 | typedef GrXPFactory INHERITED; 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/effects/GrXfermodeFragmentProcessor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef GrXfermodeFragmentProcessor_DEFINED 9 | #define GrXfermodeFragmentProcessor_DEFINED 10 | 11 | #include "SkXfermode.h" 12 | 13 | class GrFragmentProcessor; 14 | 15 | namespace GrXfermodeFragmentProcessor { 16 | /** The color input to the returned processor is treated as the src and the passed in processor 17 | is the dst. */ 18 | const GrFragmentProcessor* CreateFromDstProcessor(const GrFragmentProcessor* dst, 19 | SkXfermode::Mode mode); 20 | 21 | /** The color input to the returned processor is treated as the dst and the passed in processor 22 | is the src. */ 23 | const GrFragmentProcessor* CreateFromSrcProcessor(const GrFragmentProcessor* src, 24 | SkXfermode::Mode mode); 25 | 26 | /** Takes the input color, which is assumed to be unpremultiplied, passes it as an opaque color 27 | to both src and dst. The outputs of a src and dst are blended using mode and the original 28 | input's alpha is applied to the blended color to produce a premul output. */ 29 | const GrFragmentProcessor* CreateFromTwoProcessors(const GrFragmentProcessor* src, 30 | const GrFragmentProcessor* dst, 31 | SkXfermode::Mode mode); 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/gl/GrGLConfig_chrome.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2011 Google Inc. 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | #ifndef GrGLConfig_chrome_DEFINED 9 | #define GrGLConfig_chrome_DEFINED 10 | 11 | // glGetError() forces a sync with gpu process on chrome 12 | #define GR_GL_CHECK_ERROR_START 0 13 | 14 | // cmd buffer allocates memory and memsets it to zero when it sees glBufferData 15 | // with NULL. 16 | #define GR_GL_USE_BUFFER_DATA_NULL_HINT 0 17 | 18 | // chrome uses this to set the context on each GL call. 19 | #define GR_GL_PER_GL_FUNC_CALLBACK 1 20 | 21 | // Check error is even more expensive in chrome (cmd buffer flush). The 22 | // compositor also doesn't check its allocations. 23 | #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0 24 | 25 | // CheckFramebufferStatus in chrome synchronizes the gpu and renderer processes. 26 | #define GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT 1 27 | 28 | // Non-VBO vertices and indices are not allowed in Chromium. 29 | #define GR_GL_MUST_USE_VBO 1 30 | 31 | // Use updated Khronos signature for glShaderSource 32 | // (const char* const instead of char**). 33 | #define GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE 1 34 | 35 | #if !defined(GR_GL_IGNORE_ES3_MSAA) 36 | #define GR_GL_IGNORE_ES3_MSAA 1 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/gl/GrGLExtensions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef GrGLExtensions_DEFINED 9 | #define GrGLExtensions_DEFINED 10 | 11 | #include "GrGLFunctions.h" 12 | #include "SkString.h" 13 | #include "SkTArray.h" 14 | 15 | struct GrGLInterface; 16 | 17 | /** 18 | * This helper queries the current GL context for its extensions, remembers them, and can be 19 | * queried. It supports both glGetString- and glGetStringi-style extension string APIs and will 20 | * use the latter if it is available. 21 | */ 22 | class SK_API GrGLExtensions { 23 | public: 24 | GrGLExtensions() : fInitialized(false), fStrings(new SkTArray) {} 25 | 26 | GrGLExtensions(const GrGLExtensions&); 27 | 28 | GrGLExtensions& operator=(const GrGLExtensions&); 29 | 30 | void swap(GrGLExtensions* that) { 31 | fStrings.swap(that->fStrings); 32 | SkTSwap(fInitialized, that->fInitialized); 33 | } 34 | 35 | /** 36 | * We sometimes need to use this class without having yet created a GrGLInterface. This version 37 | * of init expects that getString is always non-NULL while getIntegerv and getStringi are non- 38 | * NULL if on desktop GL with version 3.0 or higher. Otherwise it will fail. 39 | */ 40 | bool init(GrGLStandard standard, 41 | GrGLGetStringProc getString, 42 | GrGLGetStringiProc getStringi, 43 | GrGLGetIntegervProc getIntegerv); 44 | 45 | bool isInitialized() const { return fInitialized; } 46 | 47 | /** 48 | * Queries whether an extension is present. This will fail if init() has not been called. 49 | */ 50 | bool has(const char[]) const; 51 | 52 | /** 53 | * Removes an extension if present. Returns true if the extension was present before the call. 54 | */ 55 | bool remove(const char[]); 56 | 57 | /** 58 | * Adds an extension to list 59 | */ 60 | void add(const char[]); 61 | 62 | void reset() { fStrings->reset(); } 63 | 64 | void print(const char* sep = "\n") const; 65 | 66 | private: 67 | bool fInitialized; 68 | SkAutoTDelete > fStrings; 69 | }; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/gl/GrGLSLPrettyPrint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | #ifndef GrGLSLPrettyPrint_DEFINED 8 | #define GrGLSLPrettyPrint_DEFINED 9 | 10 | #include "SkString.h" 11 | 12 | namespace GrGLSLPrettyPrint { 13 | SkString PrettyPrintGLSL(const char** strings, 14 | int* lengths, 15 | int count, 16 | bool countlines); 17 | }; 18 | 19 | #endif /* GRGLPRETTYPRINTSL_H_ */ 20 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/gl/GrGLTypes.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2015 Google Inc. 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | #ifndef GrGLTypes_DEFINED 10 | #define GrGLTypes_DEFINED 11 | 12 | #include "GrGLConfig.h" 13 | 14 | /** 15 | * Classifies GL contexts by which standard they implement (currently as OpenGL vs. OpenGL ES). 16 | */ 17 | enum GrGLStandard { 18 | kNone_GrGLStandard, 19 | kGL_GrGLStandard, 20 | kGLES_GrGLStandard, 21 | }; 22 | static const int kGrGLStandardCnt = 3; 23 | 24 | /////////////////////////////////////////////////////////////////////////////// 25 | 26 | /** 27 | * Declares typedefs for all the GL functions used in GrGLInterface 28 | */ 29 | 30 | typedef unsigned int GrGLenum; 31 | typedef unsigned char GrGLboolean; 32 | typedef unsigned int GrGLbitfield; 33 | typedef signed char GrGLbyte; 34 | typedef char GrGLchar; 35 | typedef short GrGLshort; 36 | typedef int GrGLint; 37 | typedef int GrGLsizei; 38 | typedef int64_t GrGLint64; 39 | typedef unsigned char GrGLubyte; 40 | typedef unsigned short GrGLushort; 41 | typedef unsigned int GrGLuint; 42 | typedef uint64_t GrGLuint64; 43 | typedef float GrGLfloat; 44 | typedef float GrGLclampf; 45 | typedef double GrGLdouble; 46 | typedef double GrGLclampd; 47 | typedef void GrGLvoid; 48 | #ifndef SK_IGNORE_64BIT_OPENGL_CHANGES 49 | #ifdef _WIN64 50 | typedef signed long long int GrGLintptr; 51 | typedef signed long long int GrGLsizeiptr; 52 | #else 53 | typedef signed long int GrGLintptr; 54 | typedef signed long int GrGLsizeiptr; 55 | #endif 56 | #else 57 | typedef signed long int GrGLintptr; 58 | typedef signed long int GrGLsizeiptr; 59 | #endif 60 | 61 | /////////////////////////////////////////////////////////////////////////////// 62 | /** 63 | * Types for interacting with GL resources created externally to Skia. GrBackendObjects for GL 64 | * textures are really const GrGLTexture* 65 | */ 66 | 67 | struct GrGLTextureInfo { 68 | GrGLenum fTarget; 69 | GrGLuint fID; 70 | }; 71 | 72 | GR_STATIC_ASSERT(sizeof(GrBackendObject) >= sizeof(const GrGLTextureInfo*)); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/gl/SkNullGLContext.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2011 Google Inc. 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | #ifndef SkNullGLContext_DEFINED 9 | #define SkNullGLContext_DEFINED 10 | 11 | #include "gl/SkGLContext.h" 12 | 13 | class SK_API SkNullGLContext : public SkGLContext { 14 | public: 15 | ~SkNullGLContext() override; 16 | 17 | static SkNullGLContext* Create(GrGLStandard); 18 | 19 | class ContextState; 20 | 21 | private: 22 | SkNullGLContext(); 23 | 24 | void onPlatformMakeCurrent() const override; 25 | void onPlatformSwapBuffers() const override {} 26 | GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return NULL; } 27 | 28 | ContextState* fState; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/gl/angle/SkANGLEGLContext.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2012 Google Inc. 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | #ifndef SkANGLEGLContext_DEFINED 9 | #define SkANGLEGLContext_DEFINED 10 | 11 | #if SK_ANGLE 12 | 13 | #include "gl/SkGLContext.h" 14 | 15 | class SkANGLEGLContext : public SkGLContext { 16 | public: 17 | ~SkANGLEGLContext() override; 18 | 19 | static SkANGLEGLContext* Create(GrGLStandard forcedGpuAPI, bool useGLBackend) { 20 | if (kGL_GrGLStandard == forcedGpuAPI) { 21 | return NULL; 22 | } 23 | SkANGLEGLContext* ctx = new SkANGLEGLContext(useGLBackend); 24 | if (!ctx->isValid()) { 25 | delete ctx; 26 | return NULL; 27 | } 28 | return ctx; 29 | } 30 | 31 | // The param is an EGLNativeDisplayType and the return is an EGLDispay. 32 | static void* GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend); 33 | 34 | private: 35 | SkANGLEGLContext(bool preferGLBackend); 36 | void destroyGLContext(); 37 | 38 | void onPlatformMakeCurrent() const override; 39 | void onPlatformSwapBuffers() const override; 40 | GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override; 41 | 42 | void* fContext; 43 | void* fDisplay; 44 | void* fSurface; 45 | }; 46 | 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/gpu/gl/command_buffer/SkCommandBufferGLContext.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2015 Google Inc. 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | #ifndef SKCOMMANDBUFFERGLCONTEXT_DEFINED 9 | #define SKCOMMANDBUFFERGLCONTEXT_DEFINED 10 | 11 | #if SK_COMMAND_BUFFER 12 | 13 | #include "gl/SkGLContext.h" 14 | 15 | class SkCommandBufferGLContext : public SkGLContext { 16 | public: 17 | ~SkCommandBufferGLContext() override; 18 | 19 | static SkCommandBufferGLContext* Create(GrGLStandard forcedGpuAPI) { 20 | if (kGL_GrGLStandard == forcedGpuAPI) { 21 | return nullptr; 22 | } 23 | SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext; 24 | if (!ctx->isValid()) { 25 | delete ctx; 26 | return nullptr; 27 | } 28 | return ctx; 29 | } 30 | 31 | static SkCommandBufferGLContext* Create(void* nativeWindow, int msaaSampleCount) { 32 | SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext(nativeWindow, 33 | msaaSampleCount); 34 | if (!ctx->isValid()) { 35 | delete ctx; 36 | return nullptr; 37 | } 38 | return ctx; 39 | } 40 | 41 | void presentCommandBuffer(); 42 | 43 | bool makeCurrent(); 44 | int getStencilBits(); 45 | int getSampleCount(); 46 | 47 | private: 48 | SkCommandBufferGLContext(); 49 | SkCommandBufferGLContext(void* nativeWindow, int msaaSampleCount); 50 | void initializeGLContext(void* nativeWindow, const int* configAttribs, 51 | const int* surfaceAttribs); 52 | void destroyGLContext(); 53 | 54 | void onPlatformMakeCurrent() const override; 55 | void onPlatformSwapBuffers() const override; 56 | GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override; 57 | 58 | void* fContext; 59 | void* fDisplay; 60 | void* fSurface; 61 | void* fConfig; 62 | }; 63 | 64 | #endif // SK_COMMAND_BUFFER 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/images/SkForceLinking.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | /** 9 | * This function's sole purpose is to trick the linker into not discarding 10 | * SkImageDecoder subclasses just because we do not directly call them. 11 | * This is necessary in applications that will create image decoders from 12 | * a stream. 13 | * Call this function with an expression that evaluates to false to ensure 14 | * that the linker includes the subclasses. 15 | * Passing true will result in leaked objects. 16 | */ 17 | int SkForceLinking(bool doNotPassTrue); 18 | 19 | #define __SK_FORCE_IMAGE_DECODER_LINKING \ 20 | SK_UNUSED static int linking_forced = SkForceLinking(false) 21 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/images/SkPageFlipper.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2008 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkPageFlipper_DEFINED 11 | #define SkPageFlipper_DEFINED 12 | 13 | #include "SkRegion.h" 14 | 15 | /** SkPageFlipper manages alternating inval/dirty regions for a rectangular area 16 | (like a bitmap). You call inval() to accumulate inval areas, and then when 17 | you're ready to "flip" pages (i.e. draw into the one you've been 18 | invalidating) you call update, which swaps the inval regions, and returns 19 | two things to you: 1) the final inval region to be drawn into, and 2) the 20 | region of pixels that should be copied from the "front" page onto the one 21 | you're about to draw into. This copyBits region will be disjoint from the 22 | inval region, so both need to be handled. 23 | */ 24 | class SkPageFlipper { 25 | public: 26 | SkPageFlipper(); 27 | SkPageFlipper(int width, int height); 28 | 29 | int width() const { return fWidth; } 30 | int height() const { return fHeight; } 31 | 32 | void resize(int width, int height); 33 | 34 | bool isDirty() const { return !fDirty1->isEmpty(); } 35 | const SkRegion& dirtyRgn() const { return *fDirty1; } 36 | 37 | void inval(); 38 | void inval(const SkIRect&); 39 | void inval(const SkRegion&); 40 | void inval(const SkRect&, bool antialias); 41 | 42 | /** When you're ready to write to the back page, call update. The returned 43 | region is the invalidate are that needs to be drawn to. The copyBits 44 | region (provided by the caller) is the area that should be copied from 45 | the front page to the back page (will not intersect with the returned 46 | inval region. 47 | 48 | Once this is called, the two internal regions are swapped, so the *new* 49 | back inval region is ready to receive new inval calls. 50 | */ 51 | const SkRegion& update(SkRegion* copyBits); 52 | 53 | private: 54 | SkRegion* fDirty0; 55 | SkRegion* fDirty1; 56 | SkRegion fDirty0Storage; 57 | SkRegion fDirty1Storage; 58 | int fWidth; 59 | int fHeight; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/ports/SkAtomics_atomic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkAtomics_atomic_DEFINED 9 | #define SkAtomics_atomic_DEFINED 10 | 11 | template 12 | T sk_atomic_load(const T* ptr, sk_memory_order mo) { 13 | SkASSERT(mo == sk_memory_order_relaxed || 14 | mo == sk_memory_order_seq_cst || 15 | mo == sk_memory_order_acquire || 16 | mo == sk_memory_order_consume); 17 | return __atomic_load_n(ptr, mo); 18 | } 19 | 20 | template 21 | void sk_atomic_store(T* ptr, T val, sk_memory_order mo) { 22 | SkASSERT(mo == sk_memory_order_relaxed || 23 | mo == sk_memory_order_seq_cst || 24 | mo == sk_memory_order_release); 25 | __atomic_store_n(ptr, val, mo); 26 | } 27 | 28 | template 29 | T sk_atomic_fetch_add(T* ptr, T val, sk_memory_order mo) { 30 | // All values of mo are valid. 31 | return __atomic_fetch_add(ptr, val, mo); 32 | } 33 | 34 | template 35 | T sk_atomic_fetch_sub(T* ptr, T val, sk_memory_order mo) { 36 | // All values of mo are valid. 37 | return __atomic_fetch_sub(ptr, val, mo); 38 | } 39 | 40 | template 41 | bool sk_atomic_compare_exchange(T* ptr, T* expected, T desired, 42 | sk_memory_order success, 43 | sk_memory_order failure) { 44 | // All values of success are valid. 45 | SkASSERT(failure == sk_memory_order_relaxed || 46 | failure == sk_memory_order_seq_cst || 47 | failure == sk_memory_order_acquire || 48 | failure == sk_memory_order_consume); 49 | SkASSERT(failure <= success); 50 | return __atomic_compare_exchange_n(ptr, expected, desired, false/*weak?*/, success, failure); 51 | } 52 | 53 | template 54 | T sk_atomic_exchange(T* ptr, T val, sk_memory_order mo) { 55 | // All values of mo are valid. 56 | return __atomic_exchange_n(ptr, val, mo); 57 | } 58 | 59 | #endif//SkAtomics_atomic_DEFINED 60 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/ports/SkFontMgr_android.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkFontMgr_android_DEFINED 9 | #define SkFontMgr_android_DEFINED 10 | 11 | #include "SkTypes.h" 12 | 13 | class SkFontMgr; 14 | 15 | /** 16 | * For test only -- this only affects the default factory. 17 | * Load font config from given xml files, instead of those from Android system. 18 | */ 19 | SK_API void SkUseTestFontConfigFile(const char* mainconf, const char* fallbackconf, 20 | const char* fontsdir); 21 | 22 | struct SkFontMgr_Android_CustomFonts { 23 | /** When specifying custom fonts, indicates how to use system fonts. */ 24 | enum SystemFontUse { 25 | kOnlyCustom, /** Use only custom fonts. NDK compliant. */ 26 | kPreferCustom, /** Use custom fonts before system fonts. */ 27 | kPreferSystem /** Use system fonts before custom fonts. */ 28 | }; 29 | /** Whether or not to use system fonts. */ 30 | SystemFontUse fSystemFontUse; 31 | 32 | /** Base path to resolve relative font file names. If a directory, should end with '/'. */ 33 | const char* fBasePath; 34 | 35 | /** Optional custom configuration file to use. */ 36 | const char* fFontsXml; 37 | 38 | /** Optional custom configuration file for fonts which provide fallback. 39 | * In the new style (version > 21) fontsXml format is used, this should be NULL. 40 | */ 41 | const char* fFallbackFontsXml; 42 | }; 43 | 44 | /** Create a font manager for Android. If 'custom' is NULL, use only system fonts. */ 45 | SK_API SkFontMgr* SkFontMgr_New_Android(const SkFontMgr_Android_CustomFonts* custom); 46 | 47 | #endif // SkFontMgr_android_DEFINED 48 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/ports/SkFontMgr_custom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkFontMgr_custom_DEFINED 9 | #define SkFontMgr_custom_DEFINED 10 | 11 | #include "SkTypes.h" 12 | 13 | class SkFontMgr; 14 | 15 | /** Create a custom font manager which scans a given directory for font files. */ 16 | SK_API SkFontMgr* SkFontMgr_New_Custom_Directory(const char* dir); 17 | 18 | #endif // SkFontMgr_custom_DEFINED 19 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/ports/SkFontMgr_fontconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkFontMgr_fontconfig_DEFINED 9 | #define SkFontMgr_fontconfig_DEFINED 10 | 11 | #include "SkTypes.h" 12 | #include 13 | 14 | class SkFontMgr; 15 | 16 | /** Create a font manager around a FontConfig instance. 17 | * If 'fc' is NULL, will use a new default config. 18 | * Takes ownership of 'fc' and will call FcConfigDestroy on it. 19 | */ 20 | SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc); 21 | 22 | #endif // #ifndef SkFontMgr_fontconfig_DEFINED 23 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/ports/SkTypeface_mac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkTypeface_mac_DEFINED 9 | #define SkTypeface_mac_DEFINED 10 | 11 | #include "SkTypeface.h" 12 | 13 | #include 14 | 15 | #ifdef SK_BUILD_FOR_MAC 16 | #import 17 | #endif 18 | 19 | #ifdef SK_BUILD_FOR_IOS 20 | #include 21 | #endif 22 | 23 | /** 24 | * Like the other Typeface create methods, this returns a new reference to the 25 | * corresponding typeface for the specified CTFontRef. The caller must call 26 | * unref() when it is finished. 27 | * 28 | * The CFTypeRef parameter, if provided, will be kept referenced for the 29 | * lifetime of the SkTypeface. This was introduced as a means to work around 30 | * https://crbug.com/413332 . 31 | */ 32 | SK_API extern SkTypeface* SkCreateTypefaceFromCTFont(CTFontRef, CFTypeRef = NULL); 33 | 34 | /** 35 | * Returns the platform-specific CTFontRef handle for a 36 | * given SkTypeface. Note that the returned CTFontRef gets 37 | * released when the source SkTypeface is destroyed. 38 | * 39 | * This method is deprecated. It may only be used by Blink Mac 40 | * legacy code in special cases related to text-shaping 41 | * with AAT fonts, clipboard handling and font fallback. 42 | * See https://code.google.com/p/skia/issues/detail?id=3408 43 | */ 44 | SK_API extern CTFontRef SkTypeface_GetCTFontRef(const SkTypeface* face); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/ports/SkTypeface_win.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkTypeface_win_DEFINED 9 | #define SkTypeface_win_DEFINED 10 | 11 | #include "SkTypeface.h" 12 | 13 | /** 14 | * Like the other Typeface create methods, this returns a new reference to the 15 | * corresponding typeface for the specified logfont. The caller is responsible 16 | * for calling unref() when it is finished. 17 | */ 18 | SK_API SkTypeface* SkCreateTypefaceFromLOGFONT(const LOGFONT&); 19 | 20 | /** 21 | * Copy the LOGFONT associated with this typeface into the lf parameter. Note 22 | * that the lfHeight will need to be set afterwards, since the typeface does 23 | * not track this (the paint does). 24 | * typeface may be NULL, in which case we return the logfont for the default font. 25 | */ 26 | SK_API void SkLOGFONTFromTypeface(const SkTypeface* typeface, LOGFONT* lf); 27 | 28 | /** 29 | * Set an optional callback to ensure that the data behind a LOGFONT is loaded. 30 | * This will get called if Skia tries to access the data but hits a failure. 31 | * Normally this is null, and is only required if the font data needs to be 32 | * remotely (re)loaded. 33 | */ 34 | SK_API void SkTypeface_SetEnsureLOGFONTAccessibleProc(void (*)(const LOGFONT&)); 35 | 36 | // Experimental! 37 | // 38 | class SkFontMgr; 39 | class SkRemotableFontMgr; 40 | struct IDWriteFactory; 41 | 42 | SK_API SkFontMgr* SkFontMgr_New_GDI(); 43 | SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory = NULL); 44 | 45 | /** 46 | * Creates an SkFontMgr which renders using DirectWrite and obtains its data 47 | * from the SkRemotableFontMgr. 48 | * 49 | * If DirectWrite could not be initialized, will return NULL. 50 | */ 51 | SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr*); 52 | 53 | /** 54 | * Creates an SkRemotableFontMgr backed by DirectWrite using the default 55 | * system font collection in the current locale. 56 | * 57 | * If DirectWrite could not be initialized, will return NULL. 58 | */ 59 | SK_API SkRemotableFontMgr* SkRemotableFontMgr_New_DirectWrite(); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/private/SkFunction.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkFunction_DEFINED 9 | #define SkFunction_DEFINED 10 | 11 | // TODO: document, more pervasive move support in constructors, small-Fn optimization 12 | 13 | #include "SkUtility.h" 14 | #include "SkUniquePtr.h" 15 | #include "SkTypes.h" 16 | 17 | template class SkFunction; 18 | 19 | template 20 | class SkFunction { 21 | public: 22 | SkFunction() {} 23 | 24 | template 25 | SkFunction(const Fn& fn) 26 | : fFunction(new LambdaImpl(fn)) {} 27 | 28 | SkFunction(R (*fn)(Args...)) : fFunction(new FnPtrImpl(fn)) {} 29 | 30 | SkFunction(const SkFunction& other) { *this = other; } 31 | SkFunction& operator=(const SkFunction& other) { 32 | if (this != &other) { 33 | fFunction.reset(other.fFunction.get() ? other.fFunction->clone() : nullptr); 34 | } 35 | return *this; 36 | } 37 | 38 | R operator()(Args... args) const { 39 | SkASSERT(fFunction.get()); 40 | return fFunction->call(skstd::forward(args)...); 41 | } 42 | 43 | private: 44 | struct Interface { 45 | virtual ~Interface() {} 46 | virtual R call(Args...) const = 0; 47 | virtual Interface* clone() const = 0; 48 | }; 49 | 50 | template 51 | class LambdaImpl final : public Interface { 52 | public: 53 | LambdaImpl(const Fn& fn) : fFn(fn) {} 54 | 55 | R call(Args... args) const override { return fFn(skstd::forward(args)...); } 56 | Interface* clone() const override { return new LambdaImpl(fFn); } 57 | 58 | private: 59 | Fn fFn; 60 | }; 61 | 62 | class FnPtrImpl final : public Interface { 63 | public: 64 | FnPtrImpl(R (*fn)(Args...)) : fFn(fn) {} 65 | 66 | R call(Args... args) const override { return fFn(skstd::forward(args)...); } 67 | Interface* clone() const override { return new FnPtrImpl(fFn); } 68 | 69 | private: 70 | R (*fFn)(Args...); 71 | }; 72 | 73 | skstd::unique_ptr fFunction; 74 | }; 75 | 76 | #endif//SkFunction_DEFINED 77 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/private/SkGpuFenceSync.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2015 Google Inc. 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | #ifndef SkGpuFenceSync_DEFINED 9 | #define SkGpuFenceSync_DEFINED 10 | 11 | #include "SkTypes.h" 12 | 13 | typedef void* SkPlatformGpuFence; 14 | 15 | /* 16 | * This class provides an interface to interact with fence syncs. A fence sync is an object that the 17 | * client can insert into the GPU command stream, and then at any future time, wait until all 18 | * commands that were issued before the fence have completed. 19 | */ 20 | class SkGpuFenceSync { 21 | public: 22 | virtual SkPlatformGpuFence SK_WARN_UNUSED_RESULT insertFence() const = 0; 23 | virtual bool flushAndWaitFence(SkPlatformGpuFence) const = 0; 24 | virtual void deleteFence(SkPlatformGpuFence) const = 0; 25 | 26 | virtual ~SkGpuFenceSync() {} 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/private/SkMiniRecorder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkMiniRecorder_DEFINED 9 | #define SkMiniRecorder_DEFINED 10 | 11 | #include "SkRecords.h" 12 | #include "SkScalar.h" 13 | #include "SkTypes.h" 14 | class SkCanvas; 15 | 16 | // Records small pictures, but only a limited subset of the canvas API, and may fail. 17 | class SkMiniRecorder : SkNoncopyable { 18 | public: 19 | SkMiniRecorder(); 20 | ~SkMiniRecorder(); 21 | 22 | // Try to record an op. Returns false on failure. 23 | bool drawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, 24 | const SkPaint*, SkCanvas::SrcRectConstraint); 25 | bool drawPath(const SkPath&, const SkPaint&); 26 | bool drawRect(const SkRect&, const SkPaint&); 27 | bool drawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y, const SkPaint&); 28 | 29 | // Detach anything we've recorded as a picture, resetting this SkMiniRecorder. 30 | SkPicture* detachAsPicture(const SkRect& cull); 31 | 32 | // Flush anything we've recorded to the canvas, resetting this SkMiniRecorder. 33 | // This is logically the same as but rather more efficient than: 34 | // SkAutoTUnref pic(this->detachAsPicture(SkRect::MakeEmpty())); 35 | // pic->playback(canvas); 36 | void flushAndReset(SkCanvas*); 37 | 38 | private: 39 | enum class State { 40 | kEmpty, 41 | kDrawBitmapRectFixedSize, 42 | kDrawPath, 43 | kDrawRect, 44 | kDrawTextBlob, 45 | }; 46 | 47 | State fState; 48 | 49 | template 50 | struct Max { static const size_t val = A > B ? A : B; }; 51 | 52 | static const size_t kInlineStorage = 53 | Max::val>::val>::val; 57 | SkAlignedSStorage fBuffer; 58 | }; 59 | 60 | #endif//SkMiniRecorder_DEFINED 61 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/private/SkSpinlock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | // This file is not part of the public Skia API. 9 | 10 | #ifndef SkSpinlock_DEFINED 11 | #define SkSpinlock_DEFINED 12 | 13 | #include "../private/SkAtomics.h" 14 | 15 | #define SK_DECLARE_STATIC_SPINLOCK(name) namespace {} static SkPODSpinlock name 16 | 17 | // This class has no constructor and must be zero-initialized (the macro above does this). 18 | class SK_API SkPODSpinlock { 19 | public: 20 | void acquire() { 21 | // To act as a mutex, we need an acquire barrier if we take the lock. 22 | if (sk_atomic_exchange(&fLocked, true, sk_memory_order_acquire)) { 23 | // Lock was contended. Fall back to an out-of-line spin loop. 24 | this->contendedAcquire(); 25 | } 26 | } 27 | 28 | void release() { 29 | // To act as a mutex, we need a release barrier. 30 | sk_atomic_store(&fLocked, false, sk_memory_order_release); 31 | } 32 | 33 | private: 34 | void contendedAcquire(); 35 | bool fLocked; 36 | }; 37 | 38 | // For non-global-static use cases, this is normally what you want. 39 | class SkSpinlock : public SkPODSpinlock { 40 | public: 41 | SkSpinlock() { this->release(); } 42 | }; 43 | 44 | #endif//SkSpinlock_DEFINED 45 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/private/SkThreadID.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkThreadID_DEFINED 9 | #define SkThreadID_DEFINED 10 | 11 | #include "SkTypes.h" 12 | 13 | typedef int64_t SkThreadID; 14 | 15 | SkThreadID SkGetThreadID(); 16 | 17 | const SkThreadID kIllegalThreadID = 0; 18 | 19 | #endif // SkThreadID_DEFINED 20 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/private/SkUtility.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkUtility_DEFINED 9 | #define SkUtility_DEFINED 10 | 11 | #include "SkTLogic.h" 12 | 13 | namespace skstd { 14 | 15 | template inline remove_reference_t&& move(T&& t) { 16 | return static_cast&&>(t); 17 | } 18 | 19 | template inline T&& forward(remove_reference_t& t) /*noexcept*/ { 20 | return static_cast(t); 21 | } 22 | template inline T&& forward(remove_reference_t&& t) /*noexcept*/ { 23 | static_assert(!is_lvalue_reference::value, 24 | "Forwarding an rvalue reference as an lvalue reference is not allowed."); 25 | return static_cast(t); 26 | } 27 | 28 | template add_rvalue_reference_t declval(); 29 | 30 | } // namespace skstd 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/svg/SkSVGCanvas.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkSVGCanvas_DEFINED 9 | #define SkSVGCanvas_DEFINED 10 | 11 | #include "SkCanvas.h" 12 | 13 | class SkXMLWriter; 14 | 15 | class SK_API SkSVGCanvas { 16 | public: 17 | /** 18 | * Returns a new canvas that will generate SVG commands from its draw calls, and send 19 | * them to the provided xmlwriter. Ownership of the xmlwriter is not transfered to the canvas, 20 | * but it must stay valid during the lifetime of the returned canvas. 21 | * 22 | * The canvas may buffer some drawing calls, so the output is not guaranteed to be valid 23 | * or complete until the canvas instance is deleted. 24 | * 25 | * The 'bounds' parameter defines an initial SVG viewport (viewBox attribute on the root 26 | * SVG element). 27 | */ 28 | static SkCanvas* Create(const SkRect& bounds, SkXMLWriter*); 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/svg/parser/SkSVGAttribute.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkSVGAttribute_DEFINED 11 | #define SkSVGAttribute_DEFINED 12 | 13 | #include "SkTypes.h" 14 | 15 | struct SkSVGAttribute { 16 | const char* fName; 17 | #ifdef SK_DEBUG 18 | size_t fOffset; 19 | #endif 20 | }; 21 | 22 | #ifndef SK_OFFSETOF 23 | // This is offsetof for types which are not standard layout. 24 | #define SK_OFFSETOF(type, field) (size_t)((char*)&(((type*)1024)->field) - (char*)1024) 25 | #endif 26 | 27 | #ifdef SK_DEBUG 28 | #define SVG_ATTRIBUTE(attr) { #attr, SK_OFFSETOF(BASE_CLASS, f_##attr) } 29 | #define SVG_LITERAL_ATTRIBUTE(svgAttr, cAttr) { #svgAttr, SK_OFFSETOF(BASE_CLASS, cAttr) } 30 | #else 31 | #define SVG_ATTRIBUTE(attr) { #attr } 32 | #define SVG_LITERAL_ATTRIBUTE(svgAttr, cAttr) { #svgAttr } 33 | #endif 34 | 35 | #define SVG_ADD_ATTRIBUTE(attr) \ 36 | if (f_##attr.size() > 0) \ 37 | parser._addAttributeLen(#attr, f_##attr.c_str(), f_##attr.size()) 38 | 39 | #define SVG_ADD_ATTRIBUTE_ALIAS(attr, alias) \ 40 | if (f_##alias.size() > 0) \ 41 | parser._addAttributeLen(#attr, f_##alias.c_str(), f_##alias.size()) 42 | 43 | #endif // SkSVGAttribute_DEFINED 44 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/svg/parser/SkSVGBase.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkSVGBase_DEFINED 11 | #define SkSVGBase_DEFINED 12 | 13 | #include "SkSVGAttribute.h" 14 | 15 | class SkSVGParser; 16 | 17 | class SkSVGBase { 18 | public: 19 | virtual ~SkSVGBase(); 20 | virtual void addAttribute(SkSVGParser& parser, int attrIndex, 21 | const char* attrValue, size_t attrLength); 22 | virtual int getAttributes(const SkSVGAttribute** attrPtr) = 0; 23 | }; 24 | 25 | #endif // SkSVGBase_DEFINEDes(const SkSVGAttribute** attrPtr) = 0; 26 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/svg/parser/SkSVGTypes.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkSVGTypes_DEFINED 11 | #define SkSVGTypes_DEFINED 12 | 13 | enum SkSVGTypes { 14 | SkSVGType_Circle, 15 | SkSVGType_ClipPath, 16 | SkSVGType_Defs, 17 | SkSVGType_Ellipse, 18 | SkSVGType_FeColorMatrix, 19 | SkSVGType_Filter, 20 | SkSVGType_G, 21 | SkSVGType_Image, 22 | SkSVGType_Line, 23 | SkSVGType_LinearGradient, 24 | SkSVGType_Mask, 25 | SkSVGType_Metadata, 26 | SkSVGType_Path, 27 | SkSVGType_Polygon, 28 | SkSVGType_Polyline, 29 | SkSVGType_RadialGradient, 30 | SkSVGType_Rect, 31 | SkSVGType_SVG, 32 | SkSVGType_Stop, 33 | SkSVGType_Symbol, 34 | SkSVGType_Text, 35 | SkSVGType_Tspan, 36 | SkSVGType_Unknown, 37 | SkSVGType_Use 38 | }; 39 | 40 | #endif // SkSVGTypes_DEFINED 41 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/SkBoundaryPatch.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2011 Google Inc. 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | #ifndef SkBoundaryPatch_DEFINED 9 | #define SkBoundaryPatch_DEFINED 10 | 11 | #include "SkPoint.h" 12 | #include "SkRefCnt.h" 13 | 14 | class SkBoundary : public SkRefCnt { 15 | public: 16 | 17 | 18 | // These must be 0, 1, 2, 3 for efficiency in the subclass implementations 19 | enum Edge { 20 | kTop = 0, 21 | kRight = 1, 22 | kBottom = 2, 23 | kLeft = 3 24 | }; 25 | // Edge index goes clockwise around the boundary, beginning at the "top" 26 | virtual SkPoint eval(Edge, SkScalar unitInterval) = 0; 27 | 28 | private: 29 | typedef SkRefCnt INHERITED; 30 | }; 31 | 32 | class SkBoundaryPatch { 33 | public: 34 | SkBoundaryPatch(); 35 | ~SkBoundaryPatch(); 36 | 37 | SkBoundary* getBoundary() const { return fBoundary; } 38 | SkBoundary* setBoundary(SkBoundary*); 39 | 40 | SkPoint eval(SkScalar unitU, SkScalar unitV); 41 | bool evalPatch(SkPoint verts[], int rows, int cols); 42 | 43 | private: 44 | SkBoundary* fBoundary; 45 | }; 46 | 47 | //////////////////////////////////////////////////////////////////////// 48 | 49 | class SkLineBoundary : public SkBoundary { 50 | public: 51 | SkPoint fPts[4]; 52 | 53 | // override 54 | virtual SkPoint eval(Edge, SkScalar); 55 | }; 56 | 57 | class SkCubicBoundary : public SkBoundary { 58 | public: 59 | // the caller sets the first 12 entries. The 13th is used by the impl. 60 | SkPoint fPts[13]; 61 | 62 | // override 63 | virtual SkPoint eval(Edge, SkScalar); 64 | }; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/SkCubicInterval.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2011 Google Inc. 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | #ifndef SkCubicInterval_DEFINED 9 | #define SkCubicInterval_DEFINED 10 | 11 | #include "SkPoint.h" 12 | 13 | SkScalar SkEvalCubicInterval(SkScalar x1, SkScalar y1, 14 | SkScalar x2, SkScalar y2, 15 | SkScalar unitX); 16 | 17 | static inline SkScalar SkEvalCubicInterval(const SkPoint pts[2], SkScalar x) { 18 | return SkEvalCubicInterval(pts[0].fX, pts[0].fY, 19 | pts[1].fX, pts[1].fY, x); 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/SkCullPoints.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkCullPoints_DEFINED 11 | #define SkCullPoints_DEFINED 12 | 13 | #include "SkRect.h" 14 | 15 | class SkCullPoints { 16 | public: 17 | SkCullPoints(); 18 | SkCullPoints(const SkIRect& r); 19 | 20 | void reset(const SkIRect& r); 21 | 22 | /** Start a contour at (x,y). Follow this with call(s) to lineTo(...) 23 | */ 24 | void moveTo(int x, int y); 25 | 26 | enum LineToResult { 27 | kNo_Result, //!< line segment was completely clipped out 28 | kLineTo_Result, //!< path.lineTo(pts[1]); 29 | kMoveToLineTo_Result //!< path.moveTo(pts[0]); path.lineTo(pts[1]); 30 | }; 31 | /** Connect a line to the previous call to lineTo (or moveTo). 32 | */ 33 | LineToResult lineTo(int x, int y, SkIPoint pts[2]); 34 | 35 | private: 36 | SkIRect fR; // the caller's rectangle 37 | SkIPoint fAsQuad[4]; // cache of fR as 4 points 38 | SkIPoint fPrevPt; // private state 39 | LineToResult fPrevResult; // private state 40 | 41 | bool sect_test(int x0, int y0, int x1, int y1) const; 42 | }; 43 | 44 | ///////////////////////////////////////////////////////////////////////////////// 45 | 46 | class SkPath; 47 | 48 | /** \class SkCullPointsPath 49 | 50 | Similar to SkCullPoints, but this class handles the return values 51 | from lineTo, and automatically builds a SkPath with the result(s). 52 | */ 53 | class SkCullPointsPath { 54 | public: 55 | SkCullPointsPath(); 56 | SkCullPointsPath(const SkIRect& r, SkPath* dst); 57 | 58 | void reset(const SkIRect& r, SkPath* dst); 59 | 60 | void moveTo(int x, int y); 61 | void lineTo(int x, int y); 62 | 63 | private: 64 | SkCullPoints fCP; 65 | SkPath* fPath; 66 | }; 67 | 68 | bool SkHitTestPath(const SkPath&, SkRect& target, bool hires); 69 | bool SkHitTestPath(const SkPath&, SkScalar x, SkScalar y, bool hires); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/SkFrontBufferedStream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #include "SkTypes.h" 9 | 10 | class SkStream; 11 | class SkStreamRewindable; 12 | 13 | /** 14 | * Specialized stream that buffers the first X bytes of a stream, 15 | * where X is passed in by the user. Note that unlike some buffered 16 | * stream APIs, once more bytes than can fit in the buffer are read, 17 | * no more buffering is done. This stream is designed for a use case 18 | * where the caller knows that rewind will only be called from within 19 | * X bytes (inclusive), and the wrapped stream is not necessarily 20 | * able to rewind at all. 21 | */ 22 | class SkFrontBufferedStream { 23 | public: 24 | /** 25 | * Creates a new stream that wraps and buffers an SkStream. 26 | * @param stream SkStream to buffer. If stream is NULL, NULL is 27 | * returned. When this call succeeds (i.e. returns non NULL), 28 | * SkFrontBufferedStream is expected to be the only owner of 29 | * stream, so it should no be longer used directly. 30 | * SkFrontBufferedStream will delete stream upon deletion. 31 | * @param minBufferSize Minimum size of buffer required. 32 | * @return An SkStream that can buffer at least minBufferSize, or 33 | * NULL on failure. The caller is required to delete when finished with 34 | * this object. 35 | */ 36 | static SkStreamRewindable* Create(SkStream* stream, size_t minBufferSize); 37 | }; 38 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/SkJSONCPP.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | * 7 | * A common place to put the jsoncpp library includes, as opposed to littering 8 | * the pragmas repeatedly through our code. 9 | */ 10 | #ifndef SkJSONCPP_DEFINED 11 | #define SkJSONCPP_DEFINED 12 | 13 | #ifdef GOOGLE3 14 | #include "third_party/jsoncpp/reader.h" 15 | #include "third_party/jsoncpp/value.h" 16 | #include "third_party/jsoncpp/writer.h" 17 | #else 18 | #ifdef SK_BUILD_FOR_WIN 19 | // json includes xlocale which generates warning 4530 because we're 20 | // compiling without exceptions; 21 | // see https://code.google.com/p/skia/issues/detail?id=1067 22 | #pragma warning(push) 23 | #pragma warning(disable : 4530) 24 | #endif 25 | #include "json/reader.h" 26 | #include "json/value.h" 27 | #include "json/writer.h" 28 | #ifdef SK_BUILD_FOR_WIN 29 | #pragma warning(pop) 30 | #endif 31 | #endif 32 | 33 | #endif // SkJSONCPP_DEFINED 34 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/SkMeshUtils.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2011 Google Inc. 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | #ifndef SkMeshUtils_DEFINED 9 | #define SkMeshUtils_DEFINED 10 | 11 | #include "SkPoint.h" 12 | #include "SkColor.h" 13 | 14 | class SkBitmap; 15 | class SkCanvas; 16 | class SkPaint; 17 | 18 | class SkMeshIndices { 19 | public: 20 | SkMeshIndices(); 21 | ~SkMeshIndices(); 22 | 23 | bool init(int texW, int texH, int rows, int cols) { 24 | return this->init(NULL, NULL, texW, texH, rows, cols); 25 | } 26 | 27 | bool init(SkPoint tex[], uint16_t indices[], 28 | int texW, int texH, int rows, int cols); 29 | 30 | int indexCount() const { return fIndexCount; } 31 | const uint16_t* indices() const { return fIndices; } 32 | 33 | size_t texCount() const { return fTexCount; } 34 | const SkPoint* tex() const { return fTex; } 35 | 36 | private: 37 | int fIndexCount, fTexCount; 38 | SkPoint* fTex; 39 | uint16_t* fIndices; 40 | void* fStorage; // may be null 41 | }; 42 | 43 | class SkMeshUtils { 44 | public: 45 | static void Draw(SkCanvas*, const SkBitmap&, int rows, int cols, 46 | const SkPoint verts[], const SkColor colors[], 47 | const SkPaint& paint); 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/SkNinePatch.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkNinePatch_DEFINED 11 | #define SkNinePatch_DEFINED 12 | 13 | #include "SkRect.h" 14 | #include "SkRegion.h" 15 | 16 | class SkBitmap; 17 | class SkCanvas; 18 | class SkPaint; 19 | 20 | class SkNinePatch { 21 | public: 22 | static void DrawNine(SkCanvas* canvas, const SkRect& dst, 23 | const SkBitmap& bitmap, const SkIRect& margins, 24 | const SkPaint* paint = NULL); 25 | 26 | static void DrawMesh(SkCanvas* canvas, const SkRect& dst, 27 | const SkBitmap& bitmap, 28 | const int32_t xDivs[], int numXDivs, 29 | const int32_t yDivs[], int numYDivs, 30 | const SkPaint* paint = NULL); 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/SkNoSaveLayerCanvas.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkNoSaveLayerCanvas_DEFINED 9 | #define SkNoSaveLayerCanvas_DEFINED 10 | 11 | #include "SkCanvas.h" 12 | #include "SkRRect.h" 13 | 14 | // The NoSaveLayerCanvas is used to play back SkPictures when the saveLayer 15 | // functionality isn't required (e.g., during analysis of the draw calls). 16 | // It also simplifies the clipping calls to only use rectangles. 17 | class SK_API SkNoSaveLayerCanvas : public SkCanvas { 18 | public: 19 | SkNoSaveLayerCanvas(SkBaseDevice* device) 20 | : INHERITED(device, kConservativeRasterClip_InitFlag) 21 | {} 22 | 23 | protected: 24 | virtual SaveLayerStrategy willSaveLayer(const SkRect* bounds, const SkPaint* paint, 25 | SaveFlags flags) override { 26 | this->INHERITED::willSaveLayer(bounds, paint, flags); 27 | return kNoLayer_SaveLayerStrategy; 28 | } 29 | 30 | private: 31 | typedef SkCanvas INHERITED; 32 | }; 33 | 34 | #endif // SkNoSaveLayerCanvas_DEFINED 35 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/SkNullCanvas.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkNullCanvas_DEFINED 9 | #define SkNullCanvas_DEFINED 10 | 11 | #include "SkBitmap.h" 12 | 13 | class SkCanvas; 14 | 15 | /** 16 | * Creates a canvas that draws nothing. This is useful for performance testing. 17 | */ 18 | SK_API SkCanvas* SkCreateNullCanvas(); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/SkParse.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkParse_DEFINED 11 | #define SkParse_DEFINED 12 | 13 | #include "SkColor.h" 14 | 15 | class SK_API SkParse { 16 | public: 17 | static int Count(const char str[]); // number of scalars or int values 18 | static int Count(const char str[], char separator); 19 | static const char* FindColor(const char str[], SkColor* value); 20 | static const char* FindHex(const char str[], uint32_t* value); 21 | static const char* FindMSec(const char str[], SkMSec* value); 22 | static const char* FindNamedColor(const char str[], size_t len, SkColor* color); 23 | static const char* FindS32(const char str[], int32_t* value); 24 | static const char* FindScalar(const char str[], SkScalar* value); 25 | static const char* FindScalars(const char str[], SkScalar value[], int count); 26 | 27 | static bool FindBool(const char str[], bool* value); 28 | // return the index of str in list[], or -1 if not found 29 | static int FindList(const char str[], const char list[]); 30 | #ifdef SK_SUPPORT_UNITTEST 31 | static void TestColor(); 32 | static void UnitTest(); 33 | #endif 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/SkParsePaint.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkParsePaint_DEFINED 11 | #define SkParsePaint_DEFINED 12 | 13 | #include "SkPaint.h" 14 | #include "SkDOM.h" 15 | 16 | /** "color" color 17 | "opacity" scalar [0..1] 18 | "stroke-width" scalar (0...inf) 19 | "text-size" scalar (0..inf) 20 | "is-stroke" bool 21 | "is-antialias" bool 22 | "is-lineartext" bool 23 | */ 24 | void SkPaint_Inflate(SkPaint*, const SkDOM&, const SkDOM::Node*); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/SkParsePath.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkParsePath_DEFINED 11 | #define SkParsePath_DEFINED 12 | 13 | #include "SkPath.h" 14 | 15 | class SkString; 16 | 17 | class SkParsePath { 18 | public: 19 | static bool FromSVGString(const char str[], SkPath*); 20 | static void ToSVGString(const SkPath&, SkString*); 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/SkPictureUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkPictureUtils_DEFINED 9 | #define SkPictureUtils_DEFINED 10 | 11 | #include "SkPicture.h" 12 | 13 | // TODO: remove this file? 14 | 15 | class SK_API SkPictureUtils { 16 | public: 17 | /** 18 | * How many bytes are allocated to hold the SkPicture. 19 | * Includes operations, parameters, bounding data, deletion listeners; 20 | * includes nested SkPictures, but does not include large objects that 21 | * SkRecord holds a reference to (e.g. paths, or pixels backing bitmaps). 22 | */ 23 | static size_t ApproximateBytesUsed(const SkPicture* pict) { 24 | return pict->approximateBytesUsed(); 25 | } 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/win/SkAutoCoInitialize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkAutoCo_DEFINED 9 | #define SkAutoCo_DEFINED 10 | 11 | #include "SkTypes.h" 12 | 13 | /** 14 | * An instance of this class initializes COM on creation 15 | * and closes the COM library on destruction. 16 | */ 17 | class SkAutoCoInitialize : SkNoncopyable { 18 | private: 19 | HRESULT fHR; 20 | public: 21 | SkAutoCoInitialize(); 22 | ~SkAutoCoInitialize(); 23 | bool succeeded(); 24 | }; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/win/SkHRESULT.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkHRESULT_DEFINED 9 | #define SkHRESULT_DEFINED 10 | 11 | #include "SkTypes.h" 12 | 13 | void SkTraceHR(const char* file, unsigned long line, 14 | HRESULT hr, const char* msg); 15 | 16 | #ifdef SK_DEBUG 17 | #define SK_TRACEHR(_hr, _msg) SkTraceHR(__FILE__, __LINE__, _hr, _msg) 18 | #else 19 | #define SK_TRACEHR(_hr, _msg) _hr 20 | #endif 21 | 22 | #define HR_GENERAL(_ex, _msg, _ret) {\ 23 | HRESULT _hr = _ex;\ 24 | if (FAILED(_hr)) {\ 25 | SK_TRACEHR(_hr, _msg);\ 26 | return _ret;\ 27 | }\ 28 | } 29 | 30 | //@{ 31 | /** 32 | These macros are for reporting HRESULT errors. 33 | The expression will be evaluated. 34 | If the resulting HRESULT SUCCEEDED then execution will continue normally. 35 | If the HRESULT FAILED then the macro will return from the current function. 36 | In variants ending with 'M' the given message will be traced when FAILED. 37 | The HR variants will return the HRESULT when FAILED. 38 | The HRB variants will return false when FAILED. 39 | The HRN variants will return NULL when FAILED. 40 | The HRV variants will simply return when FAILED. 41 | The HRZ variants will return 0 when FAILED. 42 | */ 43 | #define HR(ex) HR_GENERAL(ex, NULL, _hr) 44 | #define HRM(ex, msg) HR_GENERAL(ex, msg, _hr) 45 | 46 | #define HRB(ex) HR_GENERAL(ex, NULL, false) 47 | #define HRBM(ex, msg) HR_GENERAL(ex, msg, false) 48 | 49 | #define HRN(ex) HR_GENERAL(ex, NULL, NULL) 50 | #define HRNM(ex, msg) HR_GENERAL(ex, msg, NULL) 51 | 52 | #define HRV(ex) HR_GENERAL(ex, NULL, ) 53 | #define HRVM(ex, msg) HR_GENERAL(ex, msg, ) 54 | 55 | #define HRZ(ex) HR_GENERAL(ex, NULL, 0) 56 | #define HRZM(ex, msg) HR_GENERAL(ex, msg, 0) 57 | //@} 58 | #endif 59 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/utils/win/SkTScopedComPtr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkTScopedComPtr_DEFINED 9 | #define SkTScopedComPtr_DEFINED 10 | 11 | #include "SkTypes.h" 12 | 13 | template 14 | class SkBlockComRef : public T { 15 | private: 16 | virtual ULONG STDMETHODCALLTYPE AddRef(void) = 0; 17 | virtual ULONG STDMETHODCALLTYPE Release(void) = 0; 18 | }; 19 | 20 | template T* SkRefComPtr(T* ptr) { 21 | ptr->AddRef(); 22 | return ptr; 23 | } 24 | 25 | template T* SkSafeRefComPtr(T* ptr) { 26 | if (ptr) { 27 | ptr->AddRef(); 28 | } 29 | return ptr; 30 | } 31 | 32 | template 33 | class SkTScopedComPtr : SkNoncopyable { 34 | private: 35 | T *fPtr; 36 | 37 | public: 38 | explicit SkTScopedComPtr(T *ptr = NULL) : fPtr(ptr) { } 39 | ~SkTScopedComPtr() { 40 | this->reset(); 41 | } 42 | T &operator*() const { SkASSERT(fPtr != NULL); return *fPtr; } 43 | SkBlockComRef *operator->() const { 44 | return static_cast*>(fPtr); 45 | } 46 | /** 47 | * Returns the address of the underlying pointer. 48 | * This is dangerous -- it breaks encapsulation and the reference escapes. 49 | * Must only be used on instances currently pointing to NULL, 50 | * and only to initialize the instance. 51 | */ 52 | T **operator&() { SkASSERT(fPtr == NULL); return &fPtr; } 53 | T *get() const { return fPtr; } 54 | void reset() { 55 | if (this->fPtr) { 56 | this->fPtr->Release(); 57 | this->fPtr = NULL; 58 | } 59 | } 60 | 61 | void swap(SkTScopedComPtr& that) { 62 | T* temp = this->fPtr; 63 | this->fPtr = that.fPtr; 64 | that.fPtr = temp; 65 | } 66 | 67 | T* release() { 68 | T* temp = this->fPtr; 69 | this->fPtr = NULL; 70 | return temp; 71 | } 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/SkApplication.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkApplication_DEFINED 11 | #define SkApplication_DEFINED 12 | 13 | class SkOSWindow; 14 | 15 | extern SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv); 16 | extern void application_init(); 17 | extern void application_term(); 18 | 19 | #ifdef SK_BUILD_FOR_IOS 20 | enum IOS_launch_type { 21 | kError_iOSLaunchType = -1, 22 | kTool_iOSLaunchType = 0, 23 | kApplication__iOSLaunchType = 1 24 | }; 25 | 26 | extern IOS_launch_type set_cmd_line_args(int argc, char *argv[], 27 | const char* resourceDir); 28 | #endif 29 | 30 | #endif // SkApplication_DEFINED 31 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/SkBGViewArtist.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkBGViewArtist_DEFINED 11 | #define SkBGViewArtist_DEFINED 12 | 13 | #include "SkView.h" 14 | #include "SkPaint.h" 15 | 16 | class SkBGViewArtist : public SkView::Artist { 17 | public: 18 | SkBGViewArtist(SkColor c = SK_ColorWHITE); 19 | virtual ~SkBGViewArtist(); 20 | 21 | const SkPaint& paint() const { return fPaint; } 22 | SkPaint& paint() { return fPaint; } 23 | 24 | protected: 25 | // overrides 26 | virtual void onDraw(SkView*, SkCanvas*); 27 | virtual void onInflate(const SkDOM&, const SkDOM::Node*); 28 | 29 | private: 30 | SkPaint fPaint; 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/SkKey.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkKey_DEFINED 11 | #define SkKey_DEFINED 12 | 13 | #include "SkTypes.h" 14 | 15 | enum SkKey { 16 | //reordering these to match android.app.KeyEvent 17 | kNONE_SkKey, //corresponds to android's UNKNOWN 18 | 19 | kLeftSoftKey_SkKey, 20 | kRightSoftKey_SkKey, 21 | 22 | kHome_SkKey, //!< the home key - added to match android 23 | kBack_SkKey, //!< (CLR) 24 | kSend_SkKey, //!< the green (talk) key 25 | kEnd_SkKey, //!< the red key 26 | 27 | k0_SkKey, 28 | k1_SkKey, 29 | k2_SkKey, 30 | k3_SkKey, 31 | k4_SkKey, 32 | k5_SkKey, 33 | k6_SkKey, 34 | k7_SkKey, 35 | k8_SkKey, 36 | k9_SkKey, 37 | kStar_SkKey, //!< the * key 38 | kHash_SkKey, //!< the # key 39 | 40 | kUp_SkKey, 41 | kDown_SkKey, 42 | kLeft_SkKey, 43 | kRight_SkKey, 44 | 45 | kOK_SkKey, //!< the center key 46 | 47 | kVolUp_SkKey, //!< volume up - match android 48 | kVolDown_SkKey, //!< volume down - same 49 | kPower_SkKey, //!< power button - same 50 | kCamera_SkKey, //!< camera - same 51 | 52 | kSkKeyCount 53 | }; 54 | 55 | enum SkModifierKeys { 56 | kShift_SkModifierKey = 1 << 0, 57 | kControl_SkModifierKey = 1 << 1, 58 | kOption_SkModifierKey = 1 << 2, // same as ALT 59 | kCommand_SkModifierKey = 1 << 3, 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/SkOSWindow_Android.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Skia 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkOSWindow_Android_DEFINED 9 | #define SkOSWindow_Android_DEFINED 10 | 11 | #include "SkWindow.h" 12 | 13 | #include 14 | 15 | struct SkAndroidWindow { 16 | EGLDisplay fDisplay; 17 | EGLSurface fSurface; 18 | EGLContext fContext; 19 | }; 20 | 21 | class SkOSWindow : public SkWindow { 22 | public: 23 | SkOSWindow(void*); 24 | ~SkOSWindow(); 25 | 26 | enum SkBackEndTypes { 27 | kNone_BackEndType, 28 | kNativeGL_BackEndType, 29 | }; 30 | 31 | bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo* info); 32 | void detach(); 33 | void present(); 34 | bool makeFullscreen() { return true; } 35 | void closeWindow(); 36 | void setVsync(bool); 37 | bool destroyRequested() { return fDestroyRequested; } 38 | 39 | virtual void onPDFSaved(const char title[], const char desc[], const char path[]); 40 | 41 | protected: 42 | // overrides from SkWindow 43 | virtual void onHandleInval(const SkIRect&); 44 | virtual void onSetTitle(const char title[]); 45 | 46 | private: 47 | SkAndroidWindow fWindow; 48 | ANativeWindow* fNativeWindow; 49 | bool fDestroyRequested; 50 | 51 | typedef SkWindow INHERITED; 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/SkOSWindow_Mac.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | #ifndef SkOSWindow_MacCocoa_DEFINED 10 | #define SkOSWindow_MacCocoa_DEFINED 11 | 12 | #include "SkWindow.h" 13 | 14 | class SkOSWindow : public SkWindow { 15 | public: 16 | SkOSWindow(void* hwnd); 17 | ~SkOSWindow(); 18 | void* getHWND() const { return fHWND; } 19 | 20 | virtual bool onDispatchClick(int x, int y, Click::State state, 21 | void* owner, unsigned modi); 22 | enum SkBackEndTypes { 23 | kNone_BackEndType, 24 | #if SK_SUPPORT_GPU 25 | kNativeGL_BackEndType, 26 | #endif 27 | #if SK_ANGLE 28 | kANGLE_BackEndType, 29 | #endif // SK_ANGLE 30 | #if SK_COMMAND_BUFFER 31 | kCommandBuffer_BackEndType, 32 | #endif // SK_COMMAND_BUFFER 33 | }; 34 | 35 | void detach(); 36 | bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); 37 | void present(); 38 | 39 | bool makeFullscreen(); 40 | void closeWindow(); 41 | void setVsync(bool); 42 | protected: 43 | // overrides from SkEventSink 44 | virtual bool onEvent(const SkEvent& evt); 45 | // overrides from SkWindow 46 | virtual void onHandleInval(const SkIRect&); 47 | // overrides from SkView 48 | virtual void onAddMenu(const SkOSMenu*); 49 | virtual void onUpdateMenu(const SkOSMenu*); 50 | virtual void onSetTitle(const char[]); 51 | 52 | private: 53 | void* fHWND; 54 | bool fInvalEventIsPending; 55 | void* fNotifier; 56 | #if SK_SUPPORT_GPU 57 | void* fGLContext; 58 | #endif 59 | typedef SkWindow INHERITED; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/SkOSWindow_SDL.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 The Android Open Source Project 3 | * 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the LICENSE file. 6 | */ 7 | 8 | #ifndef SkOSWindow_SDL_DEFINED 9 | #define SkOSWindow_SDL_DEFINED 10 | 11 | #include "SDL.h" 12 | #include "SDL_opengl.h" 13 | #include "SkWindow.h" 14 | 15 | class SkOSWindow : public SkWindow { 16 | public: 17 | SkOSWindow(void* screen); 18 | virtual ~SkOSWindow(); 19 | 20 | static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay) { 21 | SkFAIL("not implemented\n"); 22 | return false; 23 | } 24 | 25 | enum SkBackEndTypes { 26 | kNone_BackEndType, 27 | kNativeGL_BackEndType, 28 | #if SK_ANGLE 29 | kANGLE_BackEndType, 30 | #endif // SK_ANGLE 31 | #if SK_COMMAND_BUFFER 32 | kCommandBuffer_BackEndType, 33 | #endif // SK_COMMAND_BUFFER 34 | }; 35 | 36 | void detach(); 37 | bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); 38 | void present(); 39 | bool makeFullscreen(); 40 | void setVsync(bool); 41 | void closeWindow(); 42 | void loop() { 43 | while (!fQuit) { 44 | this->handleEvents(); 45 | this->update(nullptr); 46 | } 47 | } 48 | 49 | protected: 50 | void onSetTitle(const char title[]) override; 51 | void onHandleInval(const SkIRect&) override; 52 | void onPDFSaved(const char title[], const char desc[], const char path[]) override; 53 | 54 | private: 55 | void handleEvents(); 56 | bool fQuit; 57 | uint32_t fWindowFlags; 58 | SDL_Window* fWindow; 59 | SDL_GLContext fGLContext; 60 | 61 | typedef SkWindow INHERITED; 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/SkOSWindow_iOS.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2011 Google Inc. 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | #ifndef SkOSWindow_iOS_DEFINED 9 | #define SkOSWindow_iOS_DEFINED 10 | 11 | #include "SkWindow.h" 12 | 13 | class SkOSWindow : public SkWindow { 14 | public: 15 | SkOSWindow(void* hwnd); 16 | ~SkOSWindow(); 17 | void* getHWND() const { return fHWND; } 18 | 19 | enum SkBackEndTypes { 20 | kNone_BackEndType, 21 | kNativeGL_BackEndType, 22 | }; 23 | 24 | void detach(); 25 | bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); 26 | void present(); 27 | 28 | bool makeFullscreen() { return true; } 29 | void closeWindow() { /* Not impl yet */ } 30 | void setVsync(bool) { /* Can't turn off vsync? */ } 31 | 32 | protected: 33 | // overrides from SkEventSink 34 | virtual bool onEvent(const SkEvent& evt); 35 | // overrides from SkWindow 36 | virtual void onHandleInval(const SkIRect&); 37 | // overrides from SkView 38 | virtual void onAddMenu(const SkOSMenu*); 39 | virtual void onUpdateMenu(SkOSMenu*); 40 | virtual void onSetTitle(const char[]); 41 | 42 | private: 43 | void* fHWND; 44 | bool fInvalEventIsPending; 45 | void* fNotifier; 46 | typedef SkWindow INHERITED; 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/SkStackViewLayout.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkStackViewLayout_DEFINED 11 | #define SkStackViewLayout_DEFINED 12 | 13 | #include "SkView.h" 14 | 15 | class SkStackViewLayout : public SkView::Layout { 16 | public: 17 | SkStackViewLayout(); 18 | 19 | enum Orient { 20 | kHorizontal_Orient, 21 | kVertical_Orient, 22 | 23 | kOrientCount 24 | }; 25 | Orient getOrient() const { return (Orient)fOrient; } 26 | void setOrient(Orient); 27 | 28 | void getMargin(SkRect*) const; 29 | void setMargin(const SkRect&); 30 | 31 | SkScalar getSpacer() const { return fSpacer; } 32 | void setSpacer(SkScalar); 33 | 34 | /** Controls the posititioning in the same direction as the orientation 35 | */ 36 | enum Pack { 37 | kStart_Pack, 38 | kCenter_Pack, 39 | kEnd_Pack, 40 | 41 | kPackCount 42 | }; 43 | Pack getPack() const { return (Pack)fPack; } 44 | void setPack(Pack); 45 | 46 | /** Controls the posititioning at right angles to the orientation 47 | */ 48 | enum Align { 49 | kStart_Align, 50 | kCenter_Align, 51 | kEnd_Align, 52 | kStretch_Align, 53 | 54 | kAlignCount 55 | }; 56 | Align getAlign() const { return (Align)fAlign; } 57 | void setAlign(Align); 58 | 59 | bool getRound() const { return SkToBool(fRound); } 60 | void setRound(bool); 61 | 62 | protected: 63 | virtual void onLayoutChildren(SkView* parent); 64 | virtual void onInflate(const SkDOM&, const SkDOM::Node*); 65 | 66 | private: 67 | SkRect fMargin; 68 | SkScalar fSpacer; 69 | uint8_t fOrient, fPack, fAlign, fRound; 70 | }; 71 | 72 | class SkFillViewLayout : public SkView::Layout { 73 | public: 74 | SkFillViewLayout(); 75 | void getMargin(SkRect*) const; 76 | void setMargin(const SkRect&); 77 | 78 | protected: 79 | // overrides; 80 | virtual void onLayoutChildren(SkView* parent); 81 | virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node); 82 | 83 | private: 84 | SkRect fMargin; 85 | typedef SkView::Layout INHERITED; 86 | }; 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/SkSystemEventTypes.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkSystemEventTypes_DEFINED 11 | #define SkSystemEventTypes_DEFINED 12 | 13 | /* 14 | The goal of these strings is two-fold: 15 | 1) make funny strings (containing at least one char < 32) to avoid colliding with "user" strings 16 | 2) keep them <= 4 bytes, so we can avoid an allocation in SkEvent::setType() 17 | */ 18 | #define SK_EventType_Delay "\xd" "lay" 19 | #define SK_EventType_Inval "nv" "\xa" "l" 20 | #define SK_EventType_Key "key" "\x1" 21 | #define SK_EventType_OnEnd "on" "\xe" "n" 22 | #define SK_EventType_Unichar "\xc" "har" 23 | #define SK_EventType_KeyUp "key" "\xf" 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/SkTouchGesture.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2011 Google Inc. 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | #ifndef SkTouchGesture_DEFINED 9 | #define SkTouchGesture_DEFINED 10 | 11 | #include "SkTDArray.h" 12 | #include "SkMatrix.h" 13 | 14 | struct SkFlingState { 15 | SkFlingState() : fActive(false) {} 16 | 17 | bool isActive() const { return fActive; } 18 | void stop() { fActive = false; } 19 | 20 | void reset(float sx, float sy); 21 | bool evaluateMatrix(SkMatrix* matrix); 22 | 23 | private: 24 | SkPoint fDirection; 25 | SkScalar fSpeed0; 26 | double fTime0; 27 | bool fActive; 28 | }; 29 | 30 | class SkTouchGesture { 31 | public: 32 | SkTouchGesture(); 33 | ~SkTouchGesture(); 34 | 35 | void touchBegin(void* owner, float x, float y); 36 | void touchMoved(void* owner, float x, float y); 37 | void touchEnd(void* owner); 38 | void reset(); 39 | 40 | bool isActive() { return fFlinger.isActive(); } 41 | void stop() { fFlinger.stop(); } 42 | 43 | const SkMatrix& localM(); 44 | const SkMatrix& globalM() const { return fGlobalM; } 45 | 46 | private: 47 | enum State { 48 | kEmpty_State, 49 | kTranslate_State, 50 | kZoom_State, 51 | }; 52 | 53 | struct Rec { 54 | void* fOwner; 55 | float fStartX, fStartY; 56 | float fPrevX, fPrevY; 57 | float fLastX, fLastY; 58 | SkMSec fPrevT, fLastT; 59 | }; 60 | SkTDArray fTouches; 61 | 62 | State fState; 63 | SkMatrix fLocalM, fGlobalM; 64 | SkFlingState fFlinger; 65 | SkMSec fLastUpT; 66 | SkPoint fLastUpP; 67 | 68 | 69 | void flushLocalM(); 70 | int findRec(void* owner) const; 71 | void appendNewRec(void* owner, float x, float y); 72 | float computePinch(const Rec&, const Rec&); 73 | float limitTotalZoom(float scale) const; 74 | bool handleDblTap(float, float); 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/SkViewInflate.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkViewInflate_DEFINED 11 | #define SkViewInflate_DEFINED 12 | 13 | #include "SkDOM.h" 14 | #include "SkTDict.h" 15 | #include "SkEvent.h" 16 | 17 | class SkView; 18 | 19 | class SkViewInflate { 20 | public: 21 | SkViewInflate(); 22 | virtual ~SkViewInflate(); 23 | 24 | /** Return the tree of inflated views. If root is null, create the root element 25 | as a view, otherwise assume root is that view, and just "inflate" it. 26 | 27 | Returns null if the tree cannot be built. 28 | */ 29 | SkView* inflate(const SkDOM& dom, const SkDOM::Node* node, SkView* root = NULL); 30 | SkView* inflate(const char xml[], size_t len, SkView* root = NULL); 31 | 32 | /** Given an id attribute value, return the corresponding view, or null 33 | if no match is found. 34 | */ 35 | SkView* findViewByID(const char id[]) const; 36 | 37 | SkDEBUGCODE(void dump() const;) 38 | 39 | protected: 40 | /* Override this in your subclass to handle instantiating views 41 | Call the inherited version for nodes you don't recognize. 42 | 43 | Do not call "inflate" on the view, just return it. This will 44 | get called automatically after createView returns. 45 | */ 46 | virtual SkView* createView(const SkDOM& dom, const SkDOM::Node* node); 47 | /** Base implementation calls view->inflate(dom, node). Subclasses may override this 48 | to perform additional initializations to view, either before or after calling 49 | the inherited version. 50 | */ 51 | virtual void inflateView(SkView* view, const SkDOM& dom, const SkDOM::Node* node); 52 | 53 | private: 54 | enum { 55 | kMinIDStrAlloc = 64 56 | }; 57 | SkTDict fIDs; 58 | 59 | struct IDStr { 60 | SkView* fView; 61 | char* fStr; 62 | }; 63 | SkTDArray fListenTo, fBroadcastTo; 64 | SkChunkAlloc fStrings; 65 | 66 | void addIDStr(SkTDArray* list, SkView*, const char* str); 67 | 68 | void rInflate(const SkDOM& dom, const SkDOM::Node* node, SkView* parent); 69 | }; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/animated/SkBorderView.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkBorderView_DEFINED 11 | #define SkBorderView_DEFINED 12 | 13 | #include "SkView.h" 14 | #include "SkWidgetViews.h" 15 | #include "SkAnimator.h" 16 | 17 | class SkBorderView : public SkWidgetView { 18 | public: 19 | SkBorderView(); 20 | ~SkBorderView(); 21 | void setSkin(const char skin[]); 22 | SkScalar getLeft() const { return fLeft; } 23 | SkScalar getRight() const { return fRight; } 24 | SkScalar getTop() const { return fTop; } 25 | SkScalar getBottom() const { return fBottom; } 26 | protected: 27 | //overrides 28 | virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node); 29 | virtual void onSizeChange(); 30 | virtual void onDraw(SkCanvas* canvas); 31 | virtual bool onEvent(const SkEvent& evt); 32 | private: 33 | SkAnimator fAnim; 34 | SkScalar fLeft, fRight, fTop, fBottom; //margin on each side 35 | SkRect fMargin; 36 | 37 | typedef SkWidgetView INHERITED; 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/animated/SkImageView.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkImageView_DEFINED 11 | #define SkImageView_DEFINED 12 | 13 | #include "SkView.h" 14 | #include "SkString.h" 15 | 16 | class SkAnimator; 17 | class SkBitmap; 18 | class SkMatrix; 19 | 20 | class SkImageView : public SkView { 21 | public: 22 | SkImageView(); 23 | virtual ~SkImageView(); 24 | 25 | void getUri(SkString*) const; 26 | void setUri(const char []); 27 | void setUri(const SkString&); 28 | 29 | 30 | enum ScaleType { 31 | kMatrix_ScaleType, 32 | kFitXY_ScaleType, 33 | kFitStart_ScaleType, 34 | kFitCenter_ScaleType, 35 | kFitEnd_ScaleType 36 | }; 37 | ScaleType getScaleType() const { return (ScaleType)fScaleType; } 38 | void setScaleType(ScaleType); 39 | 40 | bool getImageMatrix(SkMatrix*) const; 41 | void setImageMatrix(const SkMatrix*); 42 | 43 | protected: 44 | // overrides 45 | virtual bool onEvent(const SkEvent&); 46 | virtual void onDraw(SkCanvas*); 47 | virtual void onInflate(const SkDOM&, const SkDOMNode*); 48 | 49 | private: 50 | SkString fUri; 51 | SkMatrix* fMatrix; // null or copy of caller's matrix ,,,,, 52 | union { 53 | SkAnimator* fAnim; 54 | SkBitmap* fBitmap; 55 | } fData; 56 | uint8_t fScaleType; 57 | SkBool8 fDataIsAnim; // as opposed to bitmap 58 | SkBool8 fUriIsValid; 59 | 60 | void onUriChange(); 61 | bool getDataBounds(SkRect* bounds); 62 | bool freeData(); 63 | bool ensureUriIsLoaded(); 64 | 65 | typedef SkView INHERITED; 66 | }; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/animated/SkProgressBarView.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkProgressBarView_DEFINED 11 | #define SkProgressBarView_DEFINED 12 | 13 | #include "SkView.h" 14 | #include "SkWidgetViews.h" 15 | #include "SkAnimator.h" 16 | 17 | class SkProgressBarView : public SkWidgetView { 18 | public: 19 | SkProgressBarView(); 20 | //SkProgressBarView(int max); 21 | 22 | //inflate: "sk-progress" 23 | 24 | void reset(); //reset progress to zero 25 | void setProgress(int progress); 26 | void changeProgress(int diff); 27 | void setMax(int max); 28 | 29 | int getProgress() const { return fProgress; } 30 | int getMax() const { return fMax; } 31 | 32 | protected: 33 | //overrides 34 | virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node); 35 | virtual void onSizeChange(); 36 | virtual void onDraw(SkCanvas* canvas); 37 | virtual bool onEvent(const SkEvent& evt); 38 | 39 | private: 40 | SkAnimator fAnim; 41 | int fProgress; 42 | int fMax; 43 | 44 | typedef SkWidgetView INHERITED; 45 | }; 46 | 47 | 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/views/animated/SkScrollBarView.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkScrollBarView_DEFINED 11 | #define SkScrollBarView_DEFINED 12 | 13 | #include "SkView.h" 14 | #include "SkWidgetViews.h" 15 | #include "SkAnimator.h" 16 | 17 | class SkScrollBarView : public SkWidgetView { 18 | public: 19 | SkScrollBarView(); 20 | 21 | unsigned getStart() const { return fStartPoint; } 22 | unsigned getShown() const { return fShownLength; } 23 | unsigned getTotal() const { return fTotalLength; } 24 | 25 | void setStart(unsigned start); 26 | void setShown(unsigned shown); 27 | void setTotal(unsigned total); 28 | 29 | protected: 30 | //overrides 31 | virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node); 32 | virtual void onSizeChange(); 33 | virtual void onDraw(SkCanvas* canvas); 34 | virtual bool onEvent(const SkEvent& evt); 35 | 36 | private: 37 | SkAnimator fAnim; 38 | unsigned fTotalLength, fStartPoint, fShownLength; 39 | 40 | void adjust(); 41 | 42 | typedef SkWidgetView INHERITED; 43 | }; 44 | #endif 45 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/xml/SkBML_WXMLParser.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkBML_WXMLParser_DEFINED 11 | #define SkBML_WXMLParser_DEFINED 12 | 13 | #include "SkString.h" 14 | #include "SkXMLParser.h" 15 | 16 | class SkStream; 17 | class SkWStream; 18 | 19 | class BML_WXMLParser : public SkXMLParser { 20 | public: 21 | BML_WXMLParser(SkWStream& writer); 22 | virtual ~BML_WXMLParser(); 23 | static void Write(SkStream& s, const char filename[]); 24 | 25 | /** @cond UNIT_TEST */ 26 | SkDEBUGCODE(static void UnitTest();) 27 | /** @endcond */ 28 | private: 29 | virtual bool onAddAttribute(const char name[], const char value[]); 30 | virtual bool onEndElement(const char name[]); 31 | virtual bool onStartElement(const char name[]); 32 | BML_WXMLParser& operator=(const BML_WXMLParser& src); 33 | #ifdef SK_DEBUG 34 | int fElemsCount, fElemsReused; 35 | int fAttrsCount, fNamesReused, fValuesReused; 36 | #endif 37 | SkWStream& fWriter; 38 | char* fElems[256]; 39 | char* fAttrNames[256]; 40 | char* fAttrValues[256]; 41 | 42 | // important that these are U8, so we get automatic wrap-around 43 | uint8_t fNextElem, fNextAttrName, fNextAttrValue; 44 | }; 45 | 46 | #endif // SkBML_WXMLParser_DEFINED 47 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/skia/xml/SkBML_XMLParser.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2006 The Android Open Source Project 4 | * 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the LICENSE file. 7 | */ 8 | 9 | 10 | #ifndef SkBML_XMLParser_DEFINED 11 | #define SkBML_XMLParser_DEFINED 12 | 13 | class SkStream; 14 | class SkWStream; 15 | class SkXMLParser; 16 | class SkXMLWriter; 17 | 18 | class BML_XMLParser { 19 | public: 20 | /** Read the byte XML stream and write the decompressed XML. 21 | */ 22 | static void Read(SkStream& s, SkXMLWriter& writer); 23 | /** Read the byte XML stream and write the decompressed XML into a writable stream. 24 | */ 25 | static void Read(SkStream& s, SkWStream& output); 26 | /** Read the byte XML stream and write the decompressed XML into an XML parser. 27 | */ 28 | static void Read(SkStream& s, SkXMLParser& output); 29 | }; 30 | 31 | #endif // SkBML_XMLParser_DEFINED 32 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/v8-testing.h: -------------------------------------------------------------------------------- 1 | // Copyright 2010 the V8 project authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef V8_V8_TEST_H_ 6 | #define V8_V8_TEST_H_ 7 | 8 | #include "v8.h" 9 | 10 | /** 11 | * Testing support for the V8 JavaScript engine. 12 | */ 13 | namespace v8 { 14 | 15 | class V8_EXPORT Testing { 16 | public: 17 | enum StressType { 18 | kStressTypeOpt, 19 | kStressTypeDeopt 20 | }; 21 | 22 | /** 23 | * Set the type of stressing to do. The default if not set is kStressTypeOpt. 24 | */ 25 | static void SetStressRunType(StressType type); 26 | 27 | /** 28 | * Get the number of runs of a given test that is required to get the full 29 | * stress coverage. 30 | */ 31 | static int GetStressRuns(); 32 | 33 | /** 34 | * Indicate the number of the run which is about to start. The value of run 35 | * should be between 0 and one less than the result from GetStressRuns() 36 | */ 37 | static void PrepareStressRun(int run); 38 | 39 | /** 40 | * Force deoptimization of all functions. 41 | */ 42 | static void DeoptimizeAll(); 43 | }; 44 | 45 | 46 | } // namespace v8 47 | 48 | #endif // V8_V8_TEST_H_ 49 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/include/v8-version.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 the V8 project authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef V8_INCLUDE_VERSION_H_ // V8_VERSION_H_ conflicts with src/version.h 6 | #define V8_INCLUDE_VERSION_H_ 7 | 8 | // These macros define the version number for the current version. 9 | // NOTE these macros are used by some of the tool scripts and the build 10 | // system so their names cannot be changed without changing the scripts. 11 | #define V8_MAJOR_VERSION 4 12 | #define V8_MINOR_VERSION 5 13 | #define V8_BUILD_NUMBER 103 14 | #define V8_PATCH_LEVEL 30 15 | 16 | // Use 1 for candidates and 0 otherwise. 17 | // (Boolean macro values are not supported by all preprocessors.) 18 | #define V8_IS_CANDIDATE_VERSION 0 19 | 20 | #endif // V8_INCLUDE_VERSION_H_ 21 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/libs/arm/libNativeScript.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/platforms/android/src/canvas/jni/libs/arm/libNativeScript.so -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/libs/arm/libskia_android.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/platforms/android/src/canvas/jni/libs/arm/libskia_android.zip -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/libs/x86/libNativeScript.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/platforms/android/src/canvas/jni/libs/x86/libNativeScript.so -------------------------------------------------------------------------------- /platforms/android/src/canvas/jni/libs/x86/libskia_android.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/platforms/android/src/canvas/jni/libs/x86/libskia_android.zip -------------------------------------------------------------------------------- /platforms/android/src/canvas/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-canvas-android", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "grunt": "^0.4.5", 13 | "grunt-zip": "^0.17.1" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-15 15 | android.library=true 16 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/platforms/android/src/canvas/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /platforms/android/src/canvas/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/platforms/android/src/canvas/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /platforms/android/src/canvas/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/platforms/android/src/canvas/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /platforms/android/src/canvas/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | canvas 4 | 5 | 6 | -------------------------------------------------------------------------------- /platforms/android/src/canvas/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /platforms/ios/.gitignore: -------------------------------------------------------------------------------- 1 | canvas.framework/ 2 | src/build/ 3 | xcuserdata/ -------------------------------------------------------------------------------- /platforms/ios/.npmignore: -------------------------------------------------------------------------------- 1 | src/ -------------------------------------------------------------------------------- /platforms/ios/src/canvas.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /platforms/ios/src/canvas/CanvasRenderingContext2d.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface __CanvasRenderingContext2D : NSObject 4 | @property NSString* fillStyle; 5 | 6 | -(void)setWidth:(int)width height:(int)height; 7 | -(void)__draw; 8 | 9 | -(void)fillRect:(float)x :(float)y :(float)width :(float)height; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /platforms/ios/src/canvas/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/platforms/ios/src/canvas/Info.plist -------------------------------------------------------------------------------- /platforms/ios/src/canvas/canvas.h: -------------------------------------------------------------------------------- 1 | #include "CanvasRenderingContext2d.h" -------------------------------------------------------------------------------- /platforms/ios/src/canvas/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module canvas { 2 | umbrella header "canvas.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /prepackage.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var path = require('path'); 3 | var cp = require('child_process'); 4 | var mkdirp = require('mkdirp'); 5 | var Q = require('q'); 6 | 7 | function findTool(envVar, localPath, name, suffix) { 8 | var toolingPath = process.env[envVar]; 9 | return toolingPath 10 | ? '"' + path.join(toolingPath, localPath, name + (process.platform === 'win32' ? suffix : '')) + '"' 11 | : name; 12 | } 13 | 14 | function Qexec(command) { 15 | var future = Q.defer(); 16 | 17 | console.log('Executing ' + command); 18 | cp.exec(command, function (err, stdout, stderr) { 19 | if (err) { 20 | future.reject(err); 21 | } 22 | if (stdout) { 23 | process.stdout.write(stdout); 24 | } 25 | if (stderr) { 26 | process.stderr.write(stderr); 27 | } 28 | future.resolve(); 29 | }); 30 | return future.promise; 31 | } 32 | 33 | 34 | var projectDir = process.cwd(); 35 | process.chdir(path.join(projectDir, 'platforms/android/src/canvas')); 36 | 37 | Qexec('npm install') 38 | .then(function () { return Qexec('grunt'); }) 39 | .then(function () { return Qexec(findTool('ANDROID_NDK_PATH', '', 'ndk-build', '.cmd') + ' all'); }) 40 | .then(function () { return Qexec(findTool('ANT_HOME', 'bin', 'ant', '.bat') + ' release'); }) 41 | .then(function() { 42 | if (process.platform !== 'darwin') { 43 | return; 44 | } 45 | process.chdir(path.join(projectDir, 'platforms/ios/src')); 46 | return Qexec('xcodebuild -target universal -configuration Release'); 47 | }) 48 | .then(function () { 49 | process.chdir(projectDir); 50 | var filesToCopy = [ 51 | ['platforms/android/jniLibs/x86/libcanvas.so', 'platforms/android/src/canvas/libs/x86/libcanvas.so'], 52 | ['platforms/android/jniLibs/armeabi-v7a/libcanvas.so', 'platforms/android/src/canvas/libs/armeabi-v7a/libcanvas.so'], 53 | ['platforms/android/canvas.jar', 'platforms/android/src/canvas/bin/classes.jar'], 54 | ]; 55 | 56 | filesToCopy.forEach(function (pair) { 57 | mkdirp.sync(path.dirname(pair[0])); 58 | fs.writeFileSync(pair[0], fs.readFileSync(pair[1])); 59 | }); 60 | }) 61 | .done(); 62 | -------------------------------------------------------------------------------- /test/app/App_Resources/Android/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/Android/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /test/app/App_Resources/Android/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/Android/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /test/app/App_Resources/Android/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/Android/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /test/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Default-568h@2x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Default-667h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Default-667h@2x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Default-736h@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Default-736h@3x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Default-Landscape-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Default-Landscape-568h@2x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Default-Landscape-667h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Default-Landscape-667h@2x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Default-Landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Default-Landscape.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Default-Landscape@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Default-Landscape@2x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Default-Landscape@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Default-Landscape@3x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Default-Portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Default-Portrait.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Default-Portrait@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Default-Portrait@2x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Default.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Default@2x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Icon-Small-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Icon-Small-50.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Icon-Small-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Icon-Small-50@2x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Icon-Small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Icon-Small.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/Icon-Small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/Icon-Small@2x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/icon-40.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/icon-40@2x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/icon-60.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/icon-60@2x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/icon-72.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/icon-72@2x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/icon-76.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/icon-76@2x.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/icon.png -------------------------------------------------------------------------------- /test/app/App_Resources/iOS/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NativeScript/nativescript-canvas/1fe4ed7e146aee655f6340dea8b5b36549bdcb67/test/app/App_Resources/iOS/icon@2x.png -------------------------------------------------------------------------------- /test/app/app.css: -------------------------------------------------------------------------------- 1 | .title { 2 | font-size: 30; 3 | horizontal-align: center; 4 | margin: 20; 5 | } 6 | 7 | button { 8 | font-size: 42; 9 | horizontal-align: center; 10 | } 11 | 12 | .message { 13 | font-size: 20; 14 | color: #284848; 15 | horizontal-align: center; 16 | } 17 | -------------------------------------------------------------------------------- /test/app/app.js: -------------------------------------------------------------------------------- 1 | var application = require("application"); 2 | application.mainModule = "main-page"; 3 | application.cssFile = "./app.css"; 4 | application.start(); 5 | -------------------------------------------------------------------------------- /test/app/main-page.js: -------------------------------------------------------------------------------- 1 | function getRandomHex() { 2 | return [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F'][0|(Math.random() * 15)].toString(); 3 | } 4 | 5 | 6 | var vmModule = require("./main-view-model"); 7 | function pageLoaded(args) { 8 | var page = args.object; 9 | page.bindingContext = vmModule.mainViewModel; 10 | 11 | var canvas = page.content.getViewById('canvas'); 12 | var context = canvas.getContext('2d'); 13 | setInterval(function () { 14 | var fillStyle = '#' + getRandomHex() + getRandomHex() + getRandomHex(); 15 | console.log('Fillstyle is ' + fillStyle); 16 | context.fillStyle = fillStyle; 17 | for (var i = 0; i < 10000; ++i) { 18 | context.fillRect(0|(Math.random() * 200), Math.random() * 200, 5, 5); 19 | } 20 | if (canvas.ios) { 21 | canvas.ios.setNeedsDisplay(); 22 | } 23 | }, 0); 24 | } 25 | exports.pageLoaded = pageLoaded; 26 | -------------------------------------------------------------------------------- /test/app/main-page.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /test/app/main-view-model.js: -------------------------------------------------------------------------------- 1 | var observable = require("data/observable"); 2 | var HelloWorldModel = (function (_super) { 3 | __extends(HelloWorldModel, _super); 4 | function HelloWorldModel() { 5 | _super.call(this); 6 | this.counter = 10000; 7 | this.set("message", this.counter + " taps left"); 8 | var self = this; 9 | setInterval(function() { 10 | self.tapAction(); 11 | }, 0); 12 | } 13 | HelloWorldModel.prototype.tapAction = function () { 14 | this.counter--; 15 | if (this.counter <= 0) { 16 | this.set("message", "Hoorraaay! You unlocked the NativeScript clicker achievement!"); 17 | } 18 | else { 19 | this.set("message", this.counter + " taps left"); 20 | } 21 | }; 22 | return HelloWorldModel; 23 | })(observable.Observable); 24 | exports.HelloWorldModel = HelloWorldModel; 25 | exports.mainViewModel = new HelloWorldModel(); 26 | -------------------------------------------------------------------------------- /test/app/package.json: -------------------------------------------------------------------------------- 1 | {"name":"tns-template-hello-world","main":"app.js","version":"1.5.1","author":{"name":"Telerik","email":"support@telerik.com"},"description":"Nativescript hello-world project template","license":"Apache-2.0","keywords":["telerik","mobile","nativescript","{N}","tns","appbuilder","template"],"repository":{"type":"git","url":"git://github.com/NativeScript/template-hello-world.git"},"bugs":{"url":"https://github.com/NativeScript/template-hello-world/issues"},"homepage":"https://github.com/NativeScript/template-hello-world","android":{"v8Flags":"--expose_gc"},"readme":"ERROR: No README data found!","_id":"tns-template-hello-world@1.5.1","_from":"tns-template-hello-world@1.5.1"} -------------------------------------------------------------------------------- /test/app/references.d.ts: -------------------------------------------------------------------------------- 1 | /// Enable smart suggestions and completions in Visual Studio Code JavaScript projects. 2 | -------------------------------------------------------------------------------- /test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "nativescript": { 3 | "id": "com.telerik.canvastest", 4 | "tns-android": { 5 | "version": "1.5.1" 6 | }, 7 | "tns-ios": { 8 | "version": "1.4.1" 9 | } 10 | }, 11 | "dependencies": { 12 | "nativescript-canvas": "file:..", 13 | "tns-core-modules": "1.5.0" 14 | } 15 | } --------------------------------------------------------------------------------