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

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

Issue 17860002: Fix runtime build for Android (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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
« no previous file with comments | « runtime/bin/socket_android.cc ('k') | runtime/embedders/openglui/openglui_embedder.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "embedders/openglui/common/canvas_context.h" 11 #include "embedders/openglui/common/canvas_context.h"
12 #include "embedders/openglui/common/image_cache.h" 12 #include "embedders/openglui/common/image_cache.h"
13 #include "embedders/openglui/common/graphics_handler.h" 13 #include "embedders/openglui/common/graphics_handler.h"
14 #include "embedders/openglui/common/log.h" 14 #include "embedders/openglui/common/log.h"
15 #include "embedders/openglui/common/opengl.h" 15 #include "embedders/openglui/common/opengl.h"
16 #include "include/dart_api.h" 16 #include "include/dart_api.h"
17 #include "include/dart_native_api.h"
17 18
18 Dart_Handle HandleError(Dart_Handle handle) { 19 Dart_Handle HandleError(Dart_Handle handle) {
19 if (Dart_IsError(handle)) Dart_PropagateError(handle); 20 if (Dart_IsError(handle)) Dart_PropagateError(handle);
20 return handle; 21 return handle;
21 } 22 }
22 23
23 void CheckGLError(const char *function) { 24 void CheckGLError(const char *function) {
24 int error = glGetError(); 25 int error = glGetError();
25 if (error != GL_NO_ERROR) { 26 if (error != GL_NO_ERROR) {
26 if (error == GL_INVALID_ENUM) { 27 if (error == GL_INVALID_ENUM) {
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 srand(seed); 855 srand(seed);
855 for (int i = 0; i < length; ++i) { 856 for (int i = 0; i < length; ++i) {
856 values[i] = rand() % 256; 857 values[i] = rand() % 256;
857 } 858 }
858 return values; 859 return values;
859 } 860 }
860 861
861 void WrappedRandomArray(Dart_Port dest_port_id, 862 void WrappedRandomArray(Dart_Port dest_port_id,
862 Dart_Port reply_port_id, 863 Dart_Port reply_port_id,
863 Dart_CObject* message) { 864 Dart_CObject* message) {
864 if (message->type == Dart_CObject::kArray && 865 if (message->type == Dart_CObject_kArray &&
865 2 == message->value.as_array.length) { 866 2 == message->value.as_array.length) {
866 // Use .as_array and .as_int32 to access the data in the Dart_CObject. 867 // Use .as_array and .as_int32 to access the data in the Dart_CObject.
867 Dart_CObject* param0 = message->value.as_array.values[0]; 868 Dart_CObject* param0 = message->value.as_array.values[0];
868 Dart_CObject* param1 = message->value.as_array.values[1]; 869 Dart_CObject* param1 = message->value.as_array.values[1];
869 if (param0->type == Dart_CObject::kInt32 && 870 if (param0->type == Dart_CObject_kInt32 &&
870 param1->type == Dart_CObject::kInt32) { 871 param1->type == Dart_CObject_kInt32) {
871 int length = param0->value.as_int32; 872 int length = param0->value.as_int32;
872 int seed = param1->value.as_int32; 873 int seed = param1->value.as_int32;
873 874
874 uint8_t* values = RandomArray(seed, length); 875 uint8_t* values = RandomArray(seed, length);
875 876
876 if (values != NULL) { 877 if (values != NULL) {
877 Dart_CObject result; 878 Dart_CObject result;
878 result.type = Dart_CObject::kTypedData; 879 result.type = Dart_CObject_kTypedData;
879 result.value.as_typed_data.type = Dart_CObject::kUint8Array; 880 result.value.as_typed_data.type = Dart_TypedData_kUint8;
880 result.value.as_typed_data.values = values; 881 result.value.as_typed_data.values = values;
881 result.value.as_typed_data.length = length; 882 result.value.as_typed_data.length = length;
882 Dart_PostCObject(reply_port_id, &result); 883 Dart_PostCObject(reply_port_id, &result);
883 free(values); 884 free(values);
884 // It is OK that result is destroyed when function exits. 885 // It is OK that result is destroyed when function exits.
885 // Dart_PostCObject has copied its data. 886 // Dart_PostCObject has copied its data.
886 return; 887 return;
887 } 888 }
888 } 889 }
889 } 890 }
890 Dart_CObject result; 891 Dart_CObject result;
891 result.type = Dart_CObject::kNull; 892 result.type = Dart_CObject_kNull;
892 Dart_PostCObject(reply_port_id, &result); 893 Dart_PostCObject(reply_port_id, &result);
893 } 894 }
894 895
895 void RandomArrayServicePort(Dart_NativeArguments arguments) { 896 void RandomArrayServicePort(Dart_NativeArguments arguments) {
896 Dart_EnterScope(); 897 Dart_EnterScope();
897 Dart_SetReturnValue(arguments, Dart_Null()); 898 Dart_SetReturnValue(arguments, Dart_Null());
898 Dart_Port service_port = 899 Dart_Port service_port =
899 Dart_NewNativePort("RandomArrayService", WrappedRandomArray, true); 900 Dart_NewNativePort("RandomArrayService", WrappedRandomArray, true);
900 if (service_port != ((Dart_Port)0)) { 901 if (service_port != ((Dart_Port)0)) {
901 Dart_Handle send_port = HandleError(Dart_NewSendPort(service_port)); 902 Dart_Handle send_port = HandleError(Dart_NewSendPort(service_port));
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 HandleError(Dart_StringToCString(name, &cname)); 1728 HandleError(Dart_StringToCString(name, &cname));
1728 for (int i = 0; function_list[i].name != NULL; ++i) { 1729 for (int i = 0; function_list[i].name != NULL; ++i) {
1729 if (strcmp(function_list[i].name, cname) == 0) { 1730 if (strcmp(function_list[i].name, cname) == 0) {
1730 result = function_list[i].function; 1731 result = function_list[i].function;
1731 break; 1732 break;
1732 } 1733 }
1733 } 1734 }
1734 Dart_ExitScope(); 1735 Dart_ExitScope();
1735 return result; 1736 return result;
1736 } 1737 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_android.cc ('k') | runtime/embedders/openglui/openglui_embedder.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698