| Index: runtime/embedders/openglui/common/extension.cc
|
| ===================================================================
|
| --- runtime/embedders/openglui/common/extension.cc (revision 17737)
|
| +++ runtime/embedders/openglui/common/extension.cc (working copy)
|
| @@ -8,6 +8,8 @@
|
| #include <stdlib.h>
|
| #include <string.h>
|
|
|
| +#include "embedders/openglui/common/canvas_context.h"
|
| +#include "embedders/openglui/common/graphics_handler.h"
|
| #include "embedders/openglui/common/log.h"
|
| #include "embedders/openglui/common/opengl.h"
|
| #include "include/dart_api.h"
|
| @@ -153,6 +155,11 @@
|
| Dart_SetReturnValue(arguments, result);
|
| }
|
|
|
| +void SetDoubleReturnValue(Dart_NativeArguments arguments, double v) {
|
| + Dart_Handle result = HandleError(Dart_NewDouble(v));
|
| + Dart_SetReturnValue(arguments, result);
|
| +}
|
| +
|
| void SetStringReturnValue(Dart_NativeArguments arguments, const char* s) {
|
| Dart_Handle result = HandleError(Dart_NewStringFromCString(s));
|
| Dart_SetReturnValue(arguments, result);
|
| @@ -194,6 +201,20 @@
|
| Dart_ExitScope();
|
| }
|
|
|
| +void GetDeviceScreenWidth(Dart_NativeArguments arguments) {
|
| + LOGI("GetDeviceScreenWidth");
|
| + Dart_EnterScope();
|
| + SetIntReturnValue(arguments, graphics->width());
|
| + Dart_ExitScope();
|
| +}
|
| +
|
| +void GetDeviceScreenHeight(Dart_NativeArguments arguments) {
|
| + LOGI("GetDeviceScreenHeight");
|
| + Dart_EnterScope();
|
| + SetIntReturnValue(arguments, graphics->height());
|
| + Dart_ExitScope();
|
| +}
|
| +
|
| void SwapBuffers(Dart_NativeArguments arguments) {
|
| LOGI("SwapBuffers");
|
| Dart_EnterScope();
|
| @@ -900,6 +921,605 @@
|
| Dart_ExitScope();
|
| }
|
|
|
| +// 2D Canvas.
|
| +
|
| +// TODO(gram): this should be dynamic.
|
| +#define MAX_CONTEXTS 16
|
| +CanvasContext* contexts[MAX_CONTEXTS] = { 0 };
|
| +
|
| +CanvasContext* display_context;
|
| +
|
| +CanvasContext* Context2D(int handle) {
|
| + if (handle < 0 || handle >= MAX_CONTEXTS) {
|
| + return NULL;
|
| + }
|
| + return contexts[handle];
|
| +}
|
| +
|
| +void C2DCreateNativeContext(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DCreateNativeContext");
|
| + Dart_EnterScope();
|
| +
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + int width = GetArgAsInt(arguments, 1);
|
| + int height = GetArgAsInt(arguments, 2);
|
| +
|
| + // ASSERT(handle >= 0 && handle < MAX_CONTEXTS &&
|
| + // contexts[handle] == NULL)
|
| + CanvasContext* rtn = new CanvasContext(width, height);
|
| + rtn->Create();
|
| + if (display_context == NULL) {
|
| + display_context = rtn;
|
| + }
|
| + contexts[handle] = rtn;
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DCreateNativeContext");
|
| +}
|
| +
|
| +void C2DSetWidth(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetWidth");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + int width = GetArgAsInt(arguments, 1);
|
| + SetIntReturnValue(arguments, Context2D(handle)->setWidth(width));
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetWidth");
|
| +}
|
| +
|
| +void C2DSetHeight(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetHeight");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + int height = GetArgAsInt(arguments, 1);
|
| + SetIntReturnValue(arguments, Context2D(handle)->setHeight(height));
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetHeight");
|
| +}
|
| +
|
| +void C2DSetGlobalAlpha(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetGlobalAlpha");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double alpha = GetArgAsDouble(arguments, 1);
|
| + alpha = MIN(1.0, MAX(alpha, 0.0));
|
| + Context2D(handle)->setGlobalAlpha(alpha);
|
| + SetDoubleReturnValue(arguments, alpha);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetGlobalAlpha");
|
| +}
|
| +
|
| +void C2DSetFillStyle(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetFillStyle");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + Dart_Handle whatHandle = HandleError(Dart_GetNativeArgument(arguments, 1));
|
| + if (Dart_IsString(whatHandle)) {
|
| + const char* color = GetArgAsString(arguments, 1);
|
| + Context2D(handle)->setFillColor(color);
|
| + } else { // Texture from gradient or image.
|
| + }
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetFillStyle");
|
| +}
|
| +
|
| +void C2DSetFont(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetFont");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + const char* font = GetArgAsString(arguments, 1);
|
| + SetStringReturnValue(arguments, Context2D(handle)->setFont(font));
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetFont");
|
| +}
|
| +
|
| +void C2DSetGlobalCompositeOperation(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetGlobalCompositeOperation");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + const char* op = GetArgAsString(arguments, 1);
|
| + Context2D(handle)->setGlobalCompositeOperation(op);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetGlobalCompositeOperation");
|
| +}
|
| +
|
| +void C2DSetLineCap(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetLineCap");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + const char* lc = GetArgAsString(arguments, 1);
|
| + Context2D(handle)->setLineCap(lc);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetLineCap");
|
| +}
|
| +
|
| +void C2DSetLineJoin(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetLineJoin");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + const char* lj = GetArgAsString(arguments, 1);
|
| + Context2D(handle)->setLineJoin(lj);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetLineJoin");
|
| +}
|
| +
|
| +void C2DSetLineWidth(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetLineWidth");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double w = GetArgAsDouble(arguments, 1);
|
| + Context2D(handle)->setLineWidth(w);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetLineWidth");
|
| +}
|
| +
|
| +void C2DSetMiterLimit(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetMiterLimit");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double w = GetArgAsDouble(arguments, 1);
|
| + Context2D(handle)->setMiterLimit(w);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetMiterLimit");
|
| +}
|
| +
|
| +void C2DSetShadowBlur(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetShadowBlur");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double blur = GetArgAsDouble(arguments, 1);
|
| + Context2D(handle)->setShadowBlur(blur);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetShadowBlur");
|
| +}
|
| +
|
| +void C2DSetShadowColor(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetShadowColor");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + const char* color = GetArgAsString(arguments, 1);
|
| + Context2D(handle)->setShadowColor(color);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetShadowColor");
|
| +}
|
| +
|
| +void C2DSetShadowOffsetX(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetShadowOffsetX");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double offset = GetArgAsDouble(arguments, 1);
|
| + Context2D(handle)->setShadowOffsetX(offset);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetShadowOffsetX");
|
| +}
|
| +
|
| +void C2DSetShadowOffsetY(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetShadowOffsetY");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double offset = GetArgAsDouble(arguments, 1);
|
| + Context2D(handle)->setShadowOffsetY(offset);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetShadowOffsetY");
|
| +}
|
| +
|
| +void C2DSetStrokeStyle(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetStrokeStyle");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + const char* color = GetArgAsString(arguments, 1);
|
| + Context2D(handle)->setStrokeColor(color);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetStrokeStyle");
|
| +}
|
| +
|
| +void C2DSetTextAlign(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetTextAlign");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + const char* align = GetArgAsString(arguments, 1);
|
| + SetStringReturnValue(arguments, Context2D(handle)->setTextAlign(align));
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetTextAlign");
|
| +}
|
| +
|
| +void C2DSetTextBaseline(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetTextBaseline");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + const char* baseline = GetArgAsString(arguments, 1);
|
| + SetStringReturnValue(arguments, Context2D(handle)->setTextBaseline(baseline));
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetTextBaseline");
|
| +}
|
| +
|
| +void C2DGetImageSmoothingEnabled(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DGetImageSmoothingEnabled");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + SetDoubleReturnValue(arguments, Context2D(handle)->imageSmoothingEnabled());
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DGetImageSmoothingEnabled");
|
| +}
|
| +
|
| +void C2DArc(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DArc");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double x = GetArgAsDouble(arguments, 1);
|
| + double y = GetArgAsDouble(arguments, 2);
|
| + double r = GetArgAsDouble(arguments, 3);
|
| + double a1 = GetArgAsDouble(arguments, 4);
|
| + double a2 = GetArgAsDouble(arguments, 5);
|
| + bool anticlockwise = GetArgAsBool(arguments, 6);
|
| + Context2D(handle)->Arc(x, y, r, a1, a2, anticlockwise);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DArc");
|
| +}
|
| +
|
| +void C2DArcTo(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DArcTo");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double x1 = GetArgAsDouble(arguments, 1);
|
| + double y1 = GetArgAsDouble(arguments, 2);
|
| + double x2 = GetArgAsDouble(arguments, 3);
|
| + double y2 = GetArgAsDouble(arguments, 4);
|
| + double radius = GetArgAsDouble(arguments, 5);
|
| + Context2D(handle)->ArcTo(x1, y1, x2, y2, radius);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DArcTo");
|
| +}
|
| +
|
| +void C2DBeginPath(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DBeginPath");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + Context2D(handle)->BeginPath();
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DBeginPath");
|
| +}
|
| +
|
| +void C2DBezierCurveTo(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DBezierCurveTo");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double cp1x = GetArgAsDouble(arguments, 1);
|
| + double cp1y = GetArgAsDouble(arguments, 2);
|
| + double cp2x = GetArgAsDouble(arguments, 3);
|
| + double cp2y = GetArgAsDouble(arguments, 4);
|
| + double x = GetArgAsDouble(arguments, 5);
|
| + double y = GetArgAsDouble(arguments, 6);
|
| + Context2D(handle)->BezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DBezierCurveTo");
|
| +}
|
| +
|
| +void C2DClearRect(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DClearRect");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double left = GetArgAsDouble(arguments, 1);
|
| + double top = GetArgAsDouble(arguments, 2);
|
| + double width = GetArgAsDouble(arguments, 3);
|
| + double height = GetArgAsDouble(arguments, 4);
|
| + Context2D(handle)->ClearRect(left, top, width, height);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DClearRect");
|
| +}
|
| +
|
| +void C2DClip(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DClip");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + Context2D(handle)->Clip();
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DClip");
|
| +}
|
| +
|
| +void C2DClosePath(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DClosePath");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + Context2D(handle)->ClosePath();
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DClosePath");
|
| +}
|
| +
|
| +void C2DCreateImageDataFromDimensions(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DCreateImageDataFromDimensions");
|
| + Dart_EnterScope();
|
| + // int handle = GetArgAsInt(arguments, 0);
|
| + // double sw = GetArgAsDouble(arguments, 1);
|
| + // double sh = GetArgAsDouble(arguments, 2);
|
| + // GLubyte* pixels = (GLubyte*)calloc(sw * sh * 4, sizeof(GLubyte));
|
| + // ImageData* imageData = new ImageData(sw, sh, pixels);
|
| + // TODO(gram): How do we create a Dart ImageData object from this?
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DCreateImageDataFromDimensions");
|
| +}
|
| +
|
| +void C2DDrawImage(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DDrawImage");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + const char* src_url = GetArgAsString(arguments, 1);
|
| + int sx = GetArgAsInt(arguments, 2);
|
| + int sy = GetArgAsInt(arguments, 3);
|
| + bool has_src_dimensions = GetArgAsBool(arguments, 4);
|
| + int sw = GetArgAsInt(arguments, 5);
|
| + int sh = GetArgAsInt(arguments, 6);
|
| + int dx = GetArgAsInt(arguments, 7);
|
| + int dy = GetArgAsInt(arguments, 8);
|
| + bool has_dst_dimensions = GetArgAsBool(arguments, 9);
|
| + int dw = GetArgAsInt(arguments, 10);
|
| + int dh = GetArgAsInt(arguments, 11);
|
| + Context2D(handle)->DrawImage(src_url,
|
| + sx, sy, has_src_dimensions, sw, sh,
|
| + dx, dy, has_dst_dimensions, dw, dh);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DDrawImage");
|
| +}
|
| +
|
| +void C2DFill(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DFill");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + Context2D(handle)->Fill();
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DFill");
|
| +}
|
| +
|
| +void C2DFillRect(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DFillRect");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double left = GetArgAsDouble(arguments, 1);
|
| + double top = GetArgAsDouble(arguments, 2);
|
| + double width = GetArgAsDouble(arguments, 3);
|
| + double height = GetArgAsDouble(arguments, 4);
|
| + Context2D(handle)->FillRect(left, top, width, height);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DFillRect");
|
| +}
|
| +
|
| +void C2DFillText(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DFillText");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + const char* text = GetArgAsString(arguments, 1);
|
| + double x = GetArgAsDouble(arguments, 2);
|
| + double y = GetArgAsDouble(arguments, 3);
|
| + double maxWidth = GetArgAsDouble(arguments, 4);
|
| + Context2D(handle)->FillText(text, x, y, maxWidth);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DFillText");
|
| +}
|
| +
|
| +void C2DGetImageData(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DGetImageData");
|
| + Dart_EnterScope();
|
| + // TODO(gram): Complete this.
|
| + // int handle = GetArgAsInt(arguments, 0);
|
| + // double sx = GetArgAsDouble(arguments, 1);
|
| + // double sy = GetArgAsDouble(arguments, 2);
|
| + // double sw = GetArgAsDouble(arguments, 3);
|
| + // double sh = GetArgAsDouble(arguments, 4);
|
| + // ... = Context2D(handle)->GetImageData(text, x, y, maxWidth);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DGetImageData");
|
| +}
|
| +
|
| +void C2DLineTo(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DLineTo");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double x = GetArgAsDouble(arguments, 1);
|
| + double y = GetArgAsDouble(arguments, 2);
|
| + Context2D(handle)->LineTo(x, y);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DLineTo");
|
| +}
|
| +
|
| +void C2DMeasureText(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DMeasureText");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + const char* text = GetArgAsString(arguments, 1);
|
| + float width = Context2D(handle)->MeasureText(text);
|
| + SetDoubleReturnValue(arguments, width);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DMeasureText");
|
| +}
|
| +
|
| +void C2DMoveTo(Dart_NativeArguments arguments) {
|
| + LOGI("IN C2DMoveTo");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double x = GetArgAsDouble(arguments, 1);
|
| + double y = GetArgAsDouble(arguments, 2);
|
| + Context2D(handle)->MoveTo(x, y);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DMoveTo");
|
| +}
|
| +
|
| +void C2DPutImageData(Dart_NativeArguments arguments) {
|
| + LOGI("IN C2DPutImageData");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + // Get object arguments 2
|
| + // BindingImageData* imageData = GetArgAsObject(arguments, 1);
|
| + double dx = GetArgAsDouble(arguments, 2);
|
| + double dy = GetArgAsDouble(arguments, 3);
|
| + Context2D(handle)->PutImageData(NULL, dx, dy);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DPutImageData");
|
| +}
|
| +
|
| +void C2DQuadraticCurveTo(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DQuadraticCurveTo");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double cpx = GetArgAsDouble(arguments, 1);
|
| + double cpy = GetArgAsDouble(arguments, 2);
|
| + double x = GetArgAsDouble(arguments, 3);
|
| + double y = GetArgAsDouble(arguments, 4);
|
| + Context2D(handle)->QuadraticCurveTo(cpx, cpy, x, y);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DQuadraticCurveTo");
|
| +}
|
| +
|
| +void C2DRect(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DRect");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double x = GetArgAsDouble(arguments, 1);
|
| + double y = GetArgAsDouble(arguments, 2);
|
| + double w = GetArgAsDouble(arguments, 3);
|
| + double h = GetArgAsDouble(arguments, 4);
|
| + Context2D(handle)->Rect(x, y, w, h);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DRect");
|
| +}
|
| +
|
| +void C2DRestore(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DRestore");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + Context2D(handle)->Restore();
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DRestore");
|
| +}
|
| +
|
| +void C2DRotate(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DRotate");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double a = GetArgAsDouble(arguments, 1);
|
| + Context2D(handle)->Rotate(a);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DRotate");
|
| +}
|
| +
|
| +void C2DSave(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSave");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + Context2D(handle)->Save();
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSave");
|
| +}
|
| +
|
| +void C2DScale(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DScale");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double sx = GetArgAsDouble(arguments, 1);
|
| + double sy = GetArgAsDouble(arguments, 2);
|
| + Context2D(handle)->Scale(sx, sy);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DScale");
|
| +}
|
| +
|
| +void C2DSetLineDash(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetLineDash");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + int len;
|
| + float* dash = static_cast<float*>(GetArgsAsFloatList(arguments, 1, &len));
|
| + if (dash != NULL) {
|
| + Context2D(handle)->setLineDash(dash, len);
|
| + delete[] dash;
|
| + }
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetLineDash");
|
| +}
|
| +
|
| +void C2DSetLineDashOffset(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetLineDashOffset");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double offset = GetArgAsDouble(arguments, 1);
|
| + Context2D(handle)->setLineDashOffset(offset);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetLineDashOffset");
|
| +}
|
| +
|
| +void C2DSetTransform(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DSetTransform");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double m11 = GetArgAsDouble(arguments, 1);
|
| + double m12 = GetArgAsDouble(arguments, 2);
|
| + double m21 = GetArgAsDouble(arguments, 3);
|
| + double m22 = GetArgAsDouble(arguments, 4);
|
| + double dx = GetArgAsDouble(arguments, 5);
|
| + double dy = GetArgAsDouble(arguments, 6);
|
| + Context2D(handle)->setTransform(m11, m12, m21, m22, dx, dy);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DSetTransform");
|
| +}
|
| +
|
| +void C2DStroke(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DStroke");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + Context2D(handle)->Stroke();
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DStroke");
|
| +}
|
| +
|
| +void C2DStrokeRect(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DStrokeRect");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double left = GetArgAsDouble(arguments, 1);
|
| + double top = GetArgAsDouble(arguments, 2);
|
| + double width = GetArgAsDouble(arguments, 3);
|
| + double height = GetArgAsDouble(arguments, 4);
|
| + Context2D(handle)->StrokeRect(left, top, width, height);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DStrokeRect");
|
| +}
|
| +
|
| +void C2DStrokeText(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DStrokeText");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + const char* text = GetArgAsString(arguments, 1);
|
| + double x = GetArgAsDouble(arguments, 2);
|
| + double y = GetArgAsDouble(arguments, 3);
|
| + double maxWidth = GetArgAsDouble(arguments, 4);
|
| + Context2D(handle)->StrokeText(text, x, y, maxWidth);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DStrokeText");
|
| +}
|
| +
|
| +void C2DTransform(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DTransform");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double m11 = GetArgAsDouble(arguments, 1);
|
| + double m12 = GetArgAsDouble(arguments, 2);
|
| + double m21 = GetArgAsDouble(arguments, 3);
|
| + double m22 = GetArgAsDouble(arguments, 4);
|
| + double dx = GetArgAsDouble(arguments, 5);
|
| + double dy = GetArgAsDouble(arguments, 6);
|
| + Context2D(handle)->Transform(m11, m12, m21, m22, dx, dy);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DTransform");
|
| +}
|
| +
|
| +void C2DTranslate(Dart_NativeArguments arguments) {
|
| + LOGI("In C2DTranslate");
|
| + Dart_EnterScope();
|
| + int handle = GetArgAsInt(arguments, 0);
|
| + double x = GetArgAsDouble(arguments, 1);
|
| + double y = GetArgAsDouble(arguments, 2);
|
| + Context2D(handle)->Translate(x, y);
|
| + Dart_ExitScope();
|
| + LOGI("Out C2DTranslate");
|
| +}
|
| +
|
| struct FunctionLookup {
|
| const char* name;
|
| Dart_NativeFunction function;
|
| @@ -911,6 +1531,8 @@
|
| {"SystemRand", SystemRand},
|
| {"SystemSrand", SystemSrand},
|
| {"SwapBuffers", SwapBuffers},
|
| + {"GetDeviceScreenWidth", GetDeviceScreenWidth},
|
| + {"GetDeviceScreenHeight", GetDeviceScreenHeight},
|
| {"GLAttachShader", GLAttachShader},
|
| {"GLBindBuffer", GLBindBuffer},
|
| {"GLBufferData", GLBufferData},
|
| @@ -973,6 +1595,63 @@
|
| {"LoadSample", LoadSample},
|
| {"PlaySample", PlaySample},
|
|
|
| + // 2D Support
|
| +
|
| + { "C2DCreateNativeContext", C2DCreateNativeContext},
|
| +
|
| + // Property getters/setters.
|
| +
|
| + { "C2DSetWidth", C2DSetWidth},
|
| + { "C2DSetHeight", C2DSetHeight},
|
| + { "C2DSetGlobalAlpha", C2DSetGlobalAlpha},
|
| + { "C2DSetFillStyle", C2DSetFillStyle},
|
| + { "C2DSetFont", C2DSetFont},
|
| + { "C2DSetGlobalCompositeOperation", C2DSetGlobalCompositeOperation},
|
| + { "C2DSetLineCap", C2DSetLineCap},
|
| + { "C2DSetLineJoin", C2DSetLineJoin},
|
| + { "C2DSetLineWidth", C2DSetLineWidth},
|
| + { "C2DSetMiterLimit", C2DSetMiterLimit},
|
| + { "C2DSetShadowBlur", C2DSetShadowBlur},
|
| + { "C2DSetShadowColor", C2DSetShadowColor},
|
| + { "C2DSetShadowOffsetX", C2DSetShadowOffsetX},
|
| + { "C2DSetShadowOffsetY", C2DSetShadowOffsetY},
|
| + { "C2DSetStrokeStyle", C2DSetStrokeStyle},
|
| + { "C2DSetTextAlign", C2DSetTextAlign},
|
| + { "C2DSetTextBaseline", C2DSetTextBaseline},
|
| + { "C2DGetImageSmoothingEnabled", C2DGetImageSmoothingEnabled},
|
| +
|
| + // Methods.
|
| + { "C2DArc", C2DArc},
|
| + { "C2DArcTo", C2DArcTo},
|
| + { "C2DBeginPath", C2DBeginPath},
|
| + { "C2DBezierCurveTo", C2DBezierCurveTo},
|
| + { "C2DClearRect", C2DClearRect},
|
| + { "C2DClip", C2DClip},
|
| + { "C2DClosePath", C2DClosePath},
|
| + { "C2DCreateImageDataFromDimensions", C2DCreateImageDataFromDimensions},
|
| + { "C2DDrawImage", C2DDrawImage},
|
| + { "C2DFill", C2DFill},
|
| + { "C2DFillRect", C2DFillRect},
|
| + { "C2DFillText", C2DFillText},
|
| + { "C2DGetImageData", C2DGetImageData},
|
| + { "C2DLineTo", C2DLineTo},
|
| + { "C2DMeasureText", C2DMeasureText},
|
| + { "C2DMoveTo", C2DMoveTo},
|
| + { "C2DPutImageData", C2DPutImageData},
|
| + { "C2DQuadraticCurveTo", C2DQuadraticCurveTo},
|
| + { "C2DRect", C2DRect},
|
| + { "C2DRestore", C2DRestore},
|
| + { "C2DRotate", C2DRotate},
|
| + { "C2DSave", C2DSave},
|
| + { "C2DScale", C2DScale},
|
| + { "C2DSetLineDash", C2DSetLineDash},
|
| + { "C2DSetLineDashOffset", C2DSetLineDashOffset},
|
| + { "C2DSetTransform", C2DSetTransform},
|
| + { "C2DStroke", C2DStroke},
|
| + { "C2DStrokeRect", C2DStrokeRect},
|
| + { "C2DStrokeText", C2DStrokeText},
|
| + { "C2DTransform", C2DTransform},
|
| + { "C2DTranslate", C2DTranslate},
|
| {NULL, NULL}};
|
|
|
| Dart_NativeFunction ResolveName(Dart_Handle name, int argc) {
|
| @@ -990,4 +1669,3 @@
|
| Dart_ExitScope();
|
| return result;
|
| }
|
| -
|
|
|