Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: runtime/embedders/openglui/common/extension.cc

Issue 12212074: Support for non-DOM canvases/contexts (backed by bitaps). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "embedders/openglui/common/extension.h" 5 #include "embedders/openglui/common/extension.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 LOGI("PlaySample"); 916 LOGI("PlaySample");
917 Dart_EnterScope(); 917 Dart_EnterScope();
918 const char* what = GetArgAsString(arguments, 0); 918 const char* what = GetArgAsString(arguments, 0);
919 int rtn = PlaySoundSample(what); 919 int rtn = PlaySoundSample(what);
920 SetIntReturnValue(arguments, rtn); 920 SetIntReturnValue(arguments, rtn);
921 Dart_ExitScope(); 921 Dart_ExitScope();
922 } 922 }
923 923
924 // 2D Canvas. 924 // 2D Canvas.
925 925
926 // TODO(gram): this should be dynamic.
927 #define MAX_CONTEXTS 16
928 CanvasContext* contexts[MAX_CONTEXTS] = { 0 };
929
930 CanvasContext* display_context; 926 CanvasContext* display_context;
931 927
932 CanvasContext* Context2D(int handle) {
933 if (handle < 0 || handle >= MAX_CONTEXTS) {
934 return NULL;
935 }
936 return contexts[handle];
937 }
938
939 void C2DCreateNativeContext(Dart_NativeArguments arguments) { 928 void C2DCreateNativeContext(Dart_NativeArguments arguments) {
940 LOGI("In C2DCreateNativeContext"); 929 LOGI("In C2DCreateNativeContext");
941 Dart_EnterScope(); 930 Dart_EnterScope();
942 931
943 int handle = GetArgAsInt(arguments, 0); 932 int handle = GetArgAsInt(arguments, 0);
944 int width = GetArgAsInt(arguments, 1); 933 int width = GetArgAsInt(arguments, 1);
945 int height = GetArgAsInt(arguments, 2); 934 int height = GetArgAsInt(arguments, 2);
946 935
947 // ASSERT(handle >= 0 && handle < MAX_CONTEXTS && 936 CanvasContext* rtn = new CanvasContext(handle, width, height);
948 // contexts[handle] == NULL)
949 CanvasContext* rtn = new CanvasContext(width, height);
950 rtn->Create();
951 if (display_context == NULL) { 937 if (display_context == NULL) {
952 display_context = rtn; 938 display_context = rtn;
953 } 939 }
954 contexts[handle] = rtn;
955 Dart_ExitScope(); 940 Dart_ExitScope();
956 LOGI("Out C2DCreateNativeContext"); 941 LOGI("Out C2DCreateNativeContext");
957 } 942 }
958 943
959 void C2DSetWidth(Dart_NativeArguments arguments) { 944 void C2DSetWidth(Dart_NativeArguments arguments) {
960 LOGI("In C2DSetWidth"); 945 LOGI("In C2DSetWidth");
961 Dart_EnterScope(); 946 Dart_EnterScope();
962 int handle = GetArgAsInt(arguments, 0); 947 int handle = GetArgAsInt(arguments, 0);
963 int width = GetArgAsInt(arguments, 1); 948 int width = GetArgAsInt(arguments, 1);
964 SetIntReturnValue(arguments, Context2D(handle)->setWidth(width)); 949 SetIntReturnValue(arguments, Context2D(handle)->setWidth(width));
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 HandleError(Dart_StringToCString(name, &cname)); 1647 HandleError(Dart_StringToCString(name, &cname));
1663 for (int i = 0; function_list[i].name != NULL; ++i) { 1648 for (int i = 0; function_list[i].name != NULL; ++i) {
1664 if (strcmp(function_list[i].name, cname) == 0) { 1649 if (strcmp(function_list[i].name, cname) == 0) {
1665 result = function_list[i].function; 1650 result = function_list[i].function;
1666 break; 1651 break;
1667 } 1652 }
1668 } 1653 }
1669 Dart_ExitScope(); 1654 Dart_ExitScope();
1670 return result; 1655 return result;
1671 } 1656 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698