| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 library gpu_mojom; | 5 library gpu_mojom; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:mojo/bindings.dart' as bindings; | 9 import 'package:mojo/bindings.dart' as bindings; |
| 10 import 'package:mojo/core.dart' as core; | 10 import 'package:mojo/core.dart' as core; |
| 11 import 'package:mojo_services/mojo/command_buffer.mojom.dart' as command_buffer_
mojom; | 11 import 'package:mojo_services/mojo/command_buffer.mojom.dart' as command_buffer_
mojom; |
| 12 | 12 |
| 13 | 13 |
| 14 | 14 |
| 15 class _GpuCreateOffscreenGleS2ContextParams extends bindings.Struct { | 15 class _GpuCreateOffscreenGles2ContextParams extends bindings.Struct { |
| 16 static const List<bindings.StructDataHeader> kVersions = const [ | 16 static const List<bindings.StructDataHeader> kVersions = const [ |
| 17 const bindings.StructDataHeader(16, 0) | 17 const bindings.StructDataHeader(16, 0) |
| 18 ]; | 18 ]; |
| 19 Object gles2Client = null; | 19 Object gles2Client = null; |
| 20 | 20 |
| 21 _GpuCreateOffscreenGleS2ContextParams() : super(kVersions.last.size); | 21 _GpuCreateOffscreenGles2ContextParams() : super(kVersions.last.size); |
| 22 | 22 |
| 23 static _GpuCreateOffscreenGleS2ContextParams deserialize(bindings.Message mess
age) { | 23 static _GpuCreateOffscreenGles2ContextParams deserialize(bindings.Message mess
age) { |
| 24 var decoder = new bindings.Decoder(message); | 24 var decoder = new bindings.Decoder(message); |
| 25 var result = decode(decoder); | 25 var result = decode(decoder); |
| 26 if (decoder.excessHandles != null) { | 26 if (decoder.excessHandles != null) { |
| 27 decoder.excessHandles.forEach((h) => h.close()); | 27 decoder.excessHandles.forEach((h) => h.close()); |
| 28 } | 28 } |
| 29 return result; | 29 return result; |
| 30 } | 30 } |
| 31 | 31 |
| 32 static _GpuCreateOffscreenGleS2ContextParams decode(bindings.Decoder decoder0)
{ | 32 static _GpuCreateOffscreenGles2ContextParams decode(bindings.Decoder decoder0)
{ |
| 33 if (decoder0 == null) { | 33 if (decoder0 == null) { |
| 34 return null; | 34 return null; |
| 35 } | 35 } |
| 36 _GpuCreateOffscreenGleS2ContextParams result = new _GpuCreateOffscreenGleS2C
ontextParams(); | 36 _GpuCreateOffscreenGles2ContextParams result = new _GpuCreateOffscreenGles2C
ontextParams(); |
| 37 | 37 |
| 38 var mainDataHeader = decoder0.decodeStructDataHeader(); | 38 var mainDataHeader = decoder0.decodeStructDataHeader(); |
| 39 if (mainDataHeader.version <= kVersions.last.version) { | 39 if (mainDataHeader.version <= kVersions.last.version) { |
| 40 // Scan in reverse order to optimize for more recent versions. | 40 // Scan in reverse order to optimize for more recent versions. |
| 41 for (int i = kVersions.length - 1; i >= 0; --i) { | 41 for (int i = kVersions.length - 1; i >= 0; --i) { |
| 42 if (mainDataHeader.version >= kVersions[i].version) { | 42 if (mainDataHeader.version >= kVersions[i].version) { |
| 43 if (mainDataHeader.size == kVersions[i].size) { | 43 if (mainDataHeader.size == kVersions[i].size) { |
| 44 // Found a match. | 44 // Found a match. |
| 45 break; | 45 break; |
| 46 } | 46 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 60 return result; | 60 return result; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void encode(bindings.Encoder encoder) { | 63 void encode(bindings.Encoder encoder) { |
| 64 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); | 64 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); |
| 65 | 65 |
| 66 encoder0.encodeInterfaceRequest(gles2Client, 8, false); | 66 encoder0.encodeInterfaceRequest(gles2Client, 8, false); |
| 67 } | 67 } |
| 68 | 68 |
| 69 String toString() { | 69 String toString() { |
| 70 return "_GpuCreateOffscreenGleS2ContextParams(" | 70 return "_GpuCreateOffscreenGles2ContextParams(" |
| 71 "gles2Client: $gles2Client" ")"; | 71 "gles2Client: $gles2Client" ")"; |
| 72 } | 72 } |
| 73 | 73 |
| 74 Map toJson() { | 74 Map toJson() { |
| 75 throw new bindings.MojoCodecError( | 75 throw new bindings.MojoCodecError( |
| 76 'Object containing handles cannot be encoded to JSON.'); | 76 'Object containing handles cannot be encoded to JSON.'); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 const int _Gpu_createOffscreenGleS2ContextName = 0; | 80 const int _Gpu_createOffscreenGles2ContextName = 0; |
| 81 | 81 |
| 82 abstract class Gpu { | 82 abstract class Gpu { |
| 83 static const String serviceName = "mojo::Gpu"; | 83 static const String serviceName = "mojo::Gpu"; |
| 84 void createOffscreenGleS2Context(Object gles2Client); | 84 void createOffscreenGles2Context(Object gles2Client); |
| 85 } | 85 } |
| 86 | 86 |
| 87 | 87 |
| 88 class _GpuProxyImpl extends bindings.Proxy { | 88 class _GpuProxyImpl extends bindings.Proxy { |
| 89 _GpuProxyImpl.fromEndpoint( | 89 _GpuProxyImpl.fromEndpoint( |
| 90 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 90 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 91 | 91 |
| 92 _GpuProxyImpl.fromHandle(core.MojoHandle handle) : | 92 _GpuProxyImpl.fromHandle(core.MojoHandle handle) : |
| 93 super.fromHandle(handle); | 93 super.fromHandle(handle); |
| 94 | 94 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 113 var superString = super.toString(); | 113 var superString = super.toString(); |
| 114 return "_GpuProxyImpl($superString)"; | 114 return "_GpuProxyImpl($superString)"; |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 | 118 |
| 119 class _GpuProxyCalls implements Gpu { | 119 class _GpuProxyCalls implements Gpu { |
| 120 _GpuProxyImpl _proxyImpl; | 120 _GpuProxyImpl _proxyImpl; |
| 121 | 121 |
| 122 _GpuProxyCalls(this._proxyImpl); | 122 _GpuProxyCalls(this._proxyImpl); |
| 123 void createOffscreenGleS2Context(Object gles2Client) { | 123 void createOffscreenGles2Context(Object gles2Client) { |
| 124 if (!_proxyImpl.isBound) { | 124 if (!_proxyImpl.isBound) { |
| 125 _proxyImpl.proxyError("The Proxy is closed."); | 125 _proxyImpl.proxyError("The Proxy is closed."); |
| 126 return; | 126 return; |
| 127 } | 127 } |
| 128 var params = new _GpuCreateOffscreenGleS2ContextParams(); | 128 var params = new _GpuCreateOffscreenGles2ContextParams(); |
| 129 params.gles2Client = gles2Client; | 129 params.gles2Client = gles2Client; |
| 130 _proxyImpl.sendMessage(params, _Gpu_createOffscreenGleS2ContextName); | 130 _proxyImpl.sendMessage(params, _Gpu_createOffscreenGles2ContextName); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 | 134 |
| 135 class GpuProxy implements bindings.ProxyBase { | 135 class GpuProxy implements bindings.ProxyBase { |
| 136 final bindings.Proxy impl; | 136 final bindings.Proxy impl; |
| 137 Gpu ptr; | 137 Gpu ptr; |
| 138 | 138 |
| 139 GpuProxy(_GpuProxyImpl proxyImpl) : | 139 GpuProxy(_GpuProxyImpl proxyImpl) : |
| 140 impl = proxyImpl, | 140 impl = proxyImpl, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 | 213 |
| 214 dynamic handleMessage(bindings.ServiceMessage message) { | 214 dynamic handleMessage(bindings.ServiceMessage message) { |
| 215 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 215 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 216 return bindings.ControlMessageHandler.handleMessage(this, | 216 return bindings.ControlMessageHandler.handleMessage(this, |
| 217 0, | 217 0, |
| 218 message); | 218 message); |
| 219 } | 219 } |
| 220 assert(_impl != null); | 220 assert(_impl != null); |
| 221 switch (message.header.type) { | 221 switch (message.header.type) { |
| 222 case _Gpu_createOffscreenGleS2ContextName: | 222 case _Gpu_createOffscreenGles2ContextName: |
| 223 var params = _GpuCreateOffscreenGleS2ContextParams.deserialize( | 223 var params = _GpuCreateOffscreenGles2ContextParams.deserialize( |
| 224 message.payload); | 224 message.payload); |
| 225 _impl.createOffscreenGleS2Context(params.gles2Client); | 225 _impl.createOffscreenGles2Context(params.gles2Client); |
| 226 break; | 226 break; |
| 227 default: | 227 default: |
| 228 throw new bindings.MojoCodecError("Unexpected message name"); | 228 throw new bindings.MojoCodecError("Unexpected message name"); |
| 229 break; | 229 break; |
| 230 } | 230 } |
| 231 return null; | 231 return null; |
| 232 } | 232 } |
| 233 | 233 |
| 234 Gpu get impl => _impl; | 234 Gpu get impl => _impl; |
| 235 set impl(Gpu d) { | 235 set impl(Gpu d) { |
| 236 assert(_impl == null); | 236 assert(_impl == null); |
| 237 _impl = d; | 237 _impl = d; |
| 238 } | 238 } |
| 239 | 239 |
| 240 String toString() { | 240 String toString() { |
| 241 var superString = super.toString(); | 241 var superString = super.toString(); |
| 242 return "GpuStub($superString)"; | 242 return "GpuStub($superString)"; |
| 243 } | 243 } |
| 244 | 244 |
| 245 int get version => 0; | 245 int get version => 0; |
| 246 } | 246 } |
| 247 | 247 |
| 248 | 248 |
| OLD | NEW |