1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.ide.eclipse.gltrace.views.detail;
18 
19 import com.android.ide.eclipse.gltrace.GLEnum;
20 import com.android.ide.eclipse.gltrace.GLUtils;
21 import com.android.ide.eclipse.gltrace.GLProtoBuf.GLMessage.Function;
22 import com.android.ide.eclipse.gltrace.model.GLCall;
23 import com.android.ide.eclipse.gltrace.model.GLTrace;
24 import com.google.protobuf.ByteString;
25 
26 import org.eclipse.jface.action.IContributionItem;
27 import org.eclipse.swt.SWT;
28 import org.eclipse.swt.widgets.Composite;
29 import org.eclipse.swt.widgets.Control;
30 import org.eclipse.swt.widgets.Text;
31 
32 import java.util.Collections;
33 import java.util.List;
34 
35 public class VertexAttribPointerDataDetailProvider implements ICallDetailProvider {
36     private Text mText;
37 
38     @Override
isApplicable(GLCall call)39     public boolean isApplicable(GLCall call) {
40         return call.getFunction() == Function.glVertexAttribPointerData;
41     }
42 
43     @Override
createControl(Composite parent)44     public void createControl(Composite parent) {
45         mText = new Text(parent, SWT.BORDER | SWT.READ_ONLY | SWT.MULTI
46                 | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL);
47     }
48 
49     @Override
disposeControl()50     public void disposeControl() {
51     }
52 
53     @Override
getControl()54     public Control getControl() {
55         return mText;
56     }
57 
58     @Override
updateControl(GLTrace trace, GLCall call)59     public void updateControl(GLTrace trace, GLCall call) {
60         // void glVertexAttribPointerData(GLuint indx, GLint size, GLenum type, GLboolean norm,
61         //                      GLsizei stride, const GLvoid* ptr, int minIndex, int maxIndex)
62         GLEnum type = (GLEnum) call.getProperty(GLCall.PROPERTY_VERTEX_ATTRIB_POINTER_TYPE);
63         byte[] data = (byte[]) call.getProperty(GLCall.PROPERTY_VERTEX_ATTRIB_POINTER_DATA);
64 
65         mText.setText(GLUtils.formatData(data, type));
66     }
67 
68     @Override
getToolBarItems()69     public List<IContributionItem> getToolBarItems() {
70         return Collections.emptyList();
71     }
72 }
73