Merge branch 'master' of https://code.google.com/p/dolphin-emu into dx9-ssaa-fix

This commit is contained in:
Rodolfo Bogado 2013-08-15 00:21:28 -03:00
commit 979718484f
43 changed files with 434 additions and 239 deletions

View File

@ -152,6 +152,7 @@ PH_SZFar = 0
PH_ExtraParam = 0 PH_ExtraParam = 0
PH_ZNear = PH_ZNear =
PH_ZFar = PH_ZFar =
PerformanceQueriesEnable = True
[Video_Settings] [Video_Settings]
wideScreenHack = False wideScreenHack = False

View File

@ -74,6 +74,7 @@ PH_SZFar = 0
PH_ExtraParam = 0 PH_ExtraParam = 0
PH_ZNear = PH_ZNear =
PH_ZFar = PH_ZFar =
PerformanceQueriesEnable = True
[Video_Settings] [Video_Settings]
wideScreenHack = False wideScreenHack = False

View File

@ -39,5 +39,15 @@
android:gravity="center_vertical" android:gravity="center_vertical"
android:text="Title" android:text="Title"
android:textStyle="bold" />/> android:textStyle="bold" />
<ImageView
android:src="@android:drawable/divider_horizontal_dark"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingBottom="2dp"
android:paddingTop="2dp" />
</RelativeLayout> </RelativeLayout>

View File

@ -5,10 +5,6 @@
android:gravity="left" android:gravity="left"
android:orientation="vertical" > android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -26,6 +22,5 @@
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -16,7 +16,8 @@ import java.util.List;
* Licensed under GPLv2 * Licensed under GPLv2
* Refer to the license.txt file included. * Refer to the license.txt file included.
*/ */
public class AboutFragment extends Fragment { public final class AboutFragment extends Fragment
{
private static Activity m_activity; private static Activity m_activity;
private ListView mMainList; private ListView mMainList;
@ -25,13 +26,14 @@ public class AboutFragment extends Fragment {
boolean Configuring = false; boolean Configuring = false;
boolean firstEvent = true; boolean firstEvent = true;
public AboutFragment() { public AboutFragment()
{
// Empty constructor required for fragment subclasses // Empty constructor required for fragment subclasses
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Bundle savedInstanceState) { {
View rootView = inflater.inflate(R.layout.gamelist_listview, container, false); View rootView = inflater.inflate(R.layout.gamelist_listview, container, false);
mMainList = (ListView) rootView.findViewById(R.id.gamelist); mMainList = (ListView) rootView.findViewById(R.id.gamelist);
@ -47,15 +49,20 @@ public class AboutFragment extends Fragment {
return mMainList; return mMainList;
} }
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity)
{
super.onAttach(activity); super.onAttach(activity);
// This makes sure that the container activity has implemented // This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception // the callback interface. If not, it throws an exception
try { try
{
m_activity = activity; m_activity = activity;
} catch (ClassCastException e) { }
catch (ClassCastException e)
{
throw new ClassCastException(activity.toString() throw new ClassCastException(activity.toString()
+ " must implement OnGameListZeroListener"); + " must implement OnGameListZeroListener");
} }

View File

@ -17,7 +17,7 @@ import android.view.WindowManager;
import java.io.*; import java.io.*;
import java.util.List; import java.util.List;
public class DolphinEmulator<MainActivity> extends Activity public final class DolphinEmulator<MainActivity> extends Activity
{ {
static private NativeGLSurfaceView GLview = null; static private NativeGLSurfaceView GLview = null;
static private boolean Running = false; static private boolean Running = false;
@ -25,24 +25,32 @@ public class DolphinEmulator<MainActivity> extends Activity
private float screenWidth; private float screenWidth;
private float screenHeight; private float screenHeight;
private void CopyAsset(String asset, String output) { private void CopyAsset(String asset, String output)
{
InputStream in = null; InputStream in = null;
OutputStream out = null; OutputStream out = null;
try {
try
{
in = getAssets().open(asset); in = getAssets().open(asset);
out = new FileOutputStream(output); out = new FileOutputStream(output);
copyFile(in, out); copyFile(in, out);
in.close(); in.close();
out.close(); out.close();
} catch(IOException e) { }
catch(IOException e)
{
Log.e("DolphinEmulator", "Failed to copy asset file: " + asset, e); Log.e("DolphinEmulator", "Failed to copy asset file: " + asset, e);
} }
} }
private void copyFile(InputStream in, OutputStream out) throws IOException { private void copyFile(InputStream in, OutputStream out) throws IOException
{
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
int read; int read;
while((read = in.read(buffer)) != -1){
while((read = in.read(buffer)) != -1)
{
out.write(buffer, 0, read); out.write(buffer, 0, read);
} }
} }
@ -54,6 +62,7 @@ public class DolphinEmulator<MainActivity> extends Activity
if (Running) if (Running)
NativeLibrary.StopEmulation(); NativeLibrary.StopEmulation();
} }
@Override @Override
public void onPause() public void onPause()
{ {
@ -61,6 +70,7 @@ public class DolphinEmulator<MainActivity> extends Activity
if (Running) if (Running)
NativeLibrary.PauseEmulation(); NativeLibrary.PauseEmulation();
} }
@Override @Override
public void onResume() public void onResume()
{ {
@ -71,7 +81,8 @@ public class DolphinEmulator<MainActivity> extends Activity
/** Called when the activity is first created. */ /** Called when the activity is first created. */
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (savedInstanceState == null) if (savedInstanceState == null)
{ {
@ -158,7 +169,8 @@ public class DolphinEmulator<MainActivity> extends Activity
// Gets button presses // Gets button presses
@Override @Override
public boolean dispatchKeyEvent(KeyEvent event) { public boolean dispatchKeyEvent(KeyEvent event)
{
int action = 0; int action = 0;
// Special catch for the back key // Special catch for the back key
@ -180,7 +192,8 @@ public class DolphinEmulator<MainActivity> extends Activity
if (Running) if (Running)
{ {
switch (event.getAction()) { switch (event.getAction())
{
case KeyEvent.ACTION_DOWN: case KeyEvent.ACTION_DOWN:
action = 0; action = 0;
break; break;
@ -198,8 +211,10 @@ public class DolphinEmulator<MainActivity> extends Activity
} }
@Override @Override
public boolean dispatchGenericMotionEvent(MotionEvent event) { public boolean dispatchGenericMotionEvent(MotionEvent event)
if (((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0) || !Running) { {
if (((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0) || !Running)
{
return super.dispatchGenericMotionEvent(event); return super.dispatchGenericMotionEvent(event);
} }
@ -213,5 +228,4 @@ public class DolphinEmulator<MainActivity> extends Activity
return true; return true;
} }
} }

View File

@ -14,7 +14,8 @@ import android.widget.Toast;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
public class FolderBrowser extends Fragment { public final class FolderBrowser extends Fragment
{
private Activity m_activity; private Activity m_activity;
private FolderBrowserAdapter adapter; private FolderBrowserAdapter adapter;
private ListView mDrawerList; private ListView mDrawerList;
@ -44,7 +45,7 @@ public class FolderBrowser extends Fragment {
{ {
if(entry.isDirectory()) if(entry.isDirectory())
{ {
dir.add(new FolderBrowserItem(m_activity, entryName, getString(R.string.folder), entry.getAbsolutePath(), true)); dir.add(new FolderBrowserItem(m_activity, entryName, entry.getAbsolutePath(), true));
} }
else else
{ {
@ -77,9 +78,9 @@ public class FolderBrowser extends Fragment {
mDrawerList.setAdapter(adapter); mDrawerList.setAdapter(adapter);
mDrawerList.setOnItemClickListener(mMenuItemClickListener); mDrawerList.setOnItemClickListener(mMenuItemClickListener);
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Bundle savedInstanceState)
{ {
if(currentDir == null) if(currentDir == null)
currentDir = new File(Environment.getExternalStorageDirectory().getPath()); currentDir = new File(Environment.getExternalStorageDirectory().getPath());
@ -111,14 +112,18 @@ public class FolderBrowser extends Fragment {
}; };
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity)
{
super.onAttach(activity); super.onAttach(activity);
// This makes sure that the container activity has implemented // This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception // the callback interface. If not, it throws an exception
try { try
{
m_activity = activity; m_activity = activity;
} catch (ClassCastException e) { }
catch (ClassCastException e)
{
throw new ClassCastException(activity.toString() throw new ClassCastException(activity.toString()
+ " must implement OnGameListZeroListener"); + " must implement OnGameListZeroListener");
} }

View File

@ -1,7 +1,7 @@
package org.dolphinemu.dolphinemu; package org.dolphinemu.dolphinemu;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.content.res.Resources;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -11,13 +11,14 @@ import android.widget.TextView;
import java.util.List; import java.util.List;
public class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>{ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
{
private final Context c;
private final int id;
private final List<FolderBrowserItem> items;
private Context c; public FolderBrowserAdapter(Context context, int textViewResourceId, List<FolderBrowserItem> objects)
private int id; {
private List<FolderBrowserItem> items;
public FolderBrowserAdapter(Context context, int textViewResourceId, List<FolderBrowserItem> objects) {
super(context, textViewResourceId, objects); super(context, textViewResourceId, objects);
c = context; c = context;
id = textViewResourceId; id = textViewResourceId;
@ -58,7 +59,15 @@ public class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>{
if(subtitleText != null) if(subtitleText != null)
{ {
subtitleText.setText(item.getSubtitle()); // Remove the subtitle for all folders, except for the parent directory folder.
if (item.isDirectory() && !item.getSubtitle().equals(c.getResources().getString(R.string.parent_directory)))
{
subtitleText.setVisibility(View.GONE);
}
else
{
subtitleText.setText(item.getSubtitle());
}
} }
if (iconView != null) if (iconView != null)

View File

@ -37,6 +37,24 @@ public final class FolderBrowserItem implements Comparable<FolderBrowserItem>
this.underlyingFile = new File(path); this.underlyingFile = new File(path);
} }
/**
* Constructor. Initializes a FolderBrowserItem with an empty subtitle.
*
* @param ctx Context this FolderBrowserItem is being used in.
* @param name The name of the file/folder represented by this item.
* @param path The path of the file/folder represented by this item.
* @param isValid Whether or not this item represents a file type that can be handled.
*/
public FolderBrowserItem(Context ctx, String name, String path, boolean isValid)
{
this.ctx = ctx;
this.name = name;
this.subtitle = "";
this.path = path;
this.isValid = isValid;
this.underlyingFile = new File(path);
}
/** /**
* Gets the name of the file/folder represented by this FolderBrowserItem. * Gets the name of the file/folder represented by this FolderBrowserItem.
* *

View File

@ -22,8 +22,9 @@ import java.util.List;
* Licensed under GPLv2 * Licensed under GPLv2
* Refer to the license.txt file included. * Refer to the license.txt file included.
*/ */
public class GameListActivity extends Activity public final class GameListActivity extends Activity
implements GameListFragment.OnGameListZeroListener{ implements GameListFragment.OnGameListZeroListener
{
private int mCurFragmentNum = 0; private int mCurFragmentNum = 0;
private Fragment mCurFragment; private Fragment mCurFragment;
@ -43,7 +44,8 @@ public class GameListActivity extends Activity
} }
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.gamelist_activity); setContentView(R.layout.gamelist_activity);
mMe = this; mMe = this;
@ -94,16 +96,19 @@ public class GameListActivity extends Activity
FragmentManager fragmentManager = getFragmentManager(); FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
} }
public void SwitchPage(int toPage) public void SwitchPage(int toPage)
{ {
if (mCurFragmentNum == toPage) if (mCurFragmentNum == toPage)
return; return;
switch (mCurFragmentNum) switch (mCurFragmentNum)
{ {
// Folder browser // Folder browser
case 1: case 1:
recreateFragment(); recreateFragment();
break; break;
// Settings // Settings
case 2: case 2:
{ {
@ -147,6 +152,7 @@ public class GameListActivity extends Activity
} }
} }
break; break;
case 3: // Gamepad settings case 3: // Gamepad settings
{ {
InputConfigAdapter adapter = ((InputConfigFragment)mCurFragment).getAdapter(); InputConfigAdapter adapter = ((InputConfigFragment)mCurFragment).getAdapter();
@ -162,11 +168,13 @@ public class GameListActivity extends Activity
} }
} }
break; break;
case 0: // Game List case 0: // Game List
case 4: // About case 4: // About
/* Do Nothing */ /* Do Nothing */
break; break;
} }
switch(toPage) switch(toPage)
{ {
case 0: case 0:
@ -177,6 +185,7 @@ public class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
} }
break; break;
case 1: case 1:
{ {
Toast.makeText(mMe, getString(R.string.loading_browser), Toast.LENGTH_SHORT).show(); Toast.makeText(mMe, getString(R.string.loading_browser), Toast.LENGTH_SHORT).show();
@ -186,6 +195,7 @@ public class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
} }
break; break;
case 2: case 2:
{ {
Toast.makeText(mMe, getString(R.string.loading_settings), Toast.LENGTH_SHORT).show(); Toast.makeText(mMe, getString(R.string.loading_settings), Toast.LENGTH_SHORT).show();
@ -195,6 +205,7 @@ public class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
} }
break; break;
case 3: case 3:
{ {
Toast.makeText(mMe, getString(R.string.loading_gamepad), Toast.LENGTH_SHORT).show(); Toast.makeText(mMe, getString(R.string.loading_gamepad), Toast.LENGTH_SHORT).show();
@ -204,6 +215,7 @@ public class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
} }
break; break;
case 4: case 4:
{ {
Toast.makeText(mMe, getString(R.string.about), Toast.LENGTH_SHORT).show(); Toast.makeText(mMe, getString(R.string.about), Toast.LENGTH_SHORT).show();
@ -213,10 +225,12 @@ public class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
} }
break; break;
default: default:
break; break;
} }
} }
private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener() private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener()
{ {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) public void onItemClick(AdapterView<?> parent, View view, int position, long id)
@ -232,57 +246,75 @@ public class GameListActivity extends Activity
*/ */
@Override @Override
protected void onPostCreate(Bundle savedInstanceState) { protected void onPostCreate(Bundle savedInstanceState)
{
super.onPostCreate(savedInstanceState); super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred. // Sync the toggle state after onRestoreInstanceState has occurred.
mDrawerToggle.syncState(); mDrawerToggle.syncState();
} }
@Override @Override
public void onConfigurationChanged(Configuration newConfig) { public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
// Pass any configuration change to the drawer toggls // Pass any configuration change to the drawer toggle
mDrawerToggle.onConfigurationChanged(newConfig); mDrawerToggle.onConfigurationChanged(newConfig);
} }
/* Called whenever we call invalidateOptionsMenu() */ /* Called whenever we call invalidateOptionsMenu() */
@Override @Override
public boolean onPrepareOptionsMenu(Menu menu) { public boolean onPrepareOptionsMenu(Menu menu)
{
return super.onPrepareOptionsMenu(menu); return super.onPrepareOptionsMenu(menu);
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item)
{
// The action bar home/up action should open or close the drawer. // The action bar home/up action should open or close the drawer.
// ActionBarDrawerToggle will take care of this. // ActionBarDrawerToggle will take care of this.
if (mDrawerToggle.onOptionsItemSelected(item)) { if (mDrawerToggle.onOptionsItemSelected(item))
{
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
public void onBackPressed() public void onBackPressed()
{ {
SwitchPage(0); SwitchPage(0);
} }
public interface OnGameConfigListener { public interface OnGameConfigListener
{
public boolean onMotionEvent(MotionEvent event); public boolean onMotionEvent(MotionEvent event);
public boolean onKeyEvent(KeyEvent event); public boolean onKeyEvent(KeyEvent event);
} }
// Gets move(triggers, joystick) events // Gets move(triggers, joystick) events
@Override @Override
public boolean dispatchGenericMotionEvent(MotionEvent event) { public boolean dispatchGenericMotionEvent(MotionEvent event)
{
if (mCurFragmentNum == 3) if (mCurFragmentNum == 3)
{
if (((OnGameConfigListener)mCurFragment).onMotionEvent(event)) if (((OnGameConfigListener)mCurFragment).onMotionEvent(event))
return true; return true;
}
return super.dispatchGenericMotionEvent(event); return super.dispatchGenericMotionEvent(event);
} }
// Gets button presses // Gets button presses
@Override @Override
public boolean dispatchKeyEvent(KeyEvent event) { public boolean dispatchKeyEvent(KeyEvent event)
{
if (mCurFragmentNum == 3) if (mCurFragmentNum == 3)
{
if (((OnGameConfigListener)mCurFragment).onKeyEvent(event)) if (((OnGameConfigListener)mCurFragment).onKeyEvent(event))
return true; return true;
}
return super.dispatchKeyEvent(event); return super.dispatchKeyEvent(event);
} }

View File

@ -10,13 +10,14 @@ import android.widget.TextView;
import java.util.List; import java.util.List;
public class GameListAdapter extends ArrayAdapter<GameListItem>{ public final class GameListAdapter extends ArrayAdapter<GameListItem>
{
private final Context c;
private final int id;
private final List<GameListItem>items;
private Context c; public GameListAdapter(Context context, int textViewResourceId, List<GameListItem> objects)
private int id; {
private List<GameListItem>items;
public GameListAdapter(Context context, int textViewResourceId, List<GameListItem> objects) {
super(context, textViewResourceId, objects); super(context, textViewResourceId, objects);
c = context; c = context;
id = textViewResourceId; id = textViewResourceId;
@ -29,26 +30,30 @@ public class GameListAdapter extends ArrayAdapter<GameListItem>{
} }
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent)
{
View v = convertView; View v = convertView;
if (v == null) { if (v == null)
{
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(id, null); v = vi.inflate(id, null);
} }
final GameListItem o = items.get(position); final GameListItem item = items.get(position);
if (o != null) { if (item != null)
TextView t1 = (TextView) v.findViewById(R.id.GameItemTitle); {
TextView t2 = (TextView) v.findViewById(R.id.GameItemSubText); TextView title = (TextView) v.findViewById(R.id.GameItemTitle);
ImageView v1 = (ImageView) v.findViewById(R.id.GameItemIcon); TextView subtitle = (TextView) v.findViewById(R.id.GameItemSubText);
ImageView icon = (ImageView) v.findViewById(R.id.GameItemIcon);
if(title != null)
title.setText(item.getName());
if(subtitle != null)
subtitle.setText(item.getData());
if(icon != null)
icon.setImageBitmap(item.getImage());
}
if(t1!=null)
t1.setText(o.getName());
if(t2!=null)
t2.setText(o.getData());
if(v1!=null)
v1.setImageBitmap(o.getImage());
}
return v; return v;
} }
} }

View File

@ -24,20 +24,23 @@ import java.util.Set;
* Licensed under GPLv2 * Licensed under GPLv2
* Refer to the license.txt file included. * Refer to the license.txt file included.
*/ */
public class GameListFragment extends Fragment public final class GameListFragment extends Fragment
{ {
private ListView mMainList; private ListView mMainList;
private GameListAdapter mGameAdapter; private GameListAdapter mGameAdapter;
private static GameListActivity mMe; private static GameListActivity mMe;
OnGameListZeroListener mCallback; OnGameListZeroListener mCallback;
public interface OnGameListZeroListener { public interface OnGameListZeroListener
{
public void onZeroFiles(); public void onZeroFiles();
} }
public GameListFragment() { public GameListFragment()
{
// Empty constructor required for fragment subclasses // Empty constructor required for fragment subclasses
} }
private void Fill() private void Fill()
{ {
List<GameListItem> fls = new ArrayList<GameListItem>(); List<GameListItem> fls = new ArrayList<GameListItem>();
@ -51,7 +54,7 @@ public class GameListFragment extends Fragment
{ {
String BrowseDir = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPath" + a, ""); String BrowseDir = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPath" + a, "");
File currentDir = new File(BrowseDir); File currentDir = new File(BrowseDir);
File[]dirs = currentDir.listFiles(); File[] dirs = currentDir.listFiles();
try try
{ {
for(File entry : dirs) for(File entry : dirs)
@ -81,8 +84,8 @@ public class GameListFragment extends Fragment
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Bundle savedInstanceState) { {
View rootView = inflater.inflate(R.layout.gamelist_listview, container, false); View rootView = inflater.inflate(R.layout.gamelist_listview, container, false);
mMainList = (ListView) rootView.findViewById(R.id.gamelist); mMainList = (ListView) rootView.findViewById(R.id.gamelist);
mMainList.setOnItemClickListener(mGameItemClickListener); mMainList.setOnItemClickListener(mGameItemClickListener);
@ -91,6 +94,7 @@ public class GameListFragment extends Fragment
return mMainList; return mMainList;
} }
private AdapterView.OnItemClickListener mGameItemClickListener = new AdapterView.OnItemClickListener() private AdapterView.OnItemClickListener mGameItemClickListener = new AdapterView.OnItemClickListener()
{ {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) public void onItemClick(AdapterView<?> parent, View view, int position, long id)
@ -102,6 +106,7 @@ public class GameListFragment extends Fragment
} }
} }
}; };
private void onFileClick(String o) private void onFileClick(String o)
{ {
Toast.makeText(mMe, getString(R.string.file_clicked) + o, Toast.LENGTH_SHORT).show(); Toast.makeText(mMe, getString(R.string.file_clicked) + o, Toast.LENGTH_SHORT).show();
@ -111,16 +116,21 @@ public class GameListFragment extends Fragment
mMe.setResult(Activity.RESULT_OK, intent); mMe.setResult(Activity.RESULT_OK, intent);
mMe.finish(); mMe.finish();
} }
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity)
{
super.onAttach(activity); super.onAttach(activity);
// This makes sure that the container activity has implemented // This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception // the callback interface. If not, it throws an exception
try { try
{
mCallback = (OnGameListZeroListener) activity; mCallback = (OnGameListZeroListener) activity;
mMe = (GameListActivity) activity; mMe = (GameListActivity) activity;
} catch (ClassCastException e) { }
catch (ClassCastException e)
{
throw new ClassCastException(activity.toString() throw new ClassCastException(activity.toString()
+ " must implement OnGameListZeroListener"); + " must implement OnGameListZeroListener");
} }

View File

@ -8,36 +8,44 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
public class GameListItem implements Comparable<GameListItem>{ public final class GameListItem implements Comparable<GameListItem>
private String name; {
private String data; private final String name;
private String path; private final String data;
private final String path;
private final boolean isValid;
private Bitmap image; private Bitmap image;
private boolean m_valid;
public GameListItem(Context ctx, String n,String d,String p, boolean valid) public GameListItem(Context ctx, String name, String data, String path, boolean isValid)
{ {
name = n; this.name = name;
data = d; this.data = data;
path = p; this.path = path;
m_valid = valid; this.isValid = isValid;
File file = new File(path); File file = new File(path);
if (!file.isDirectory() && !path.equals("")) if (!file.isDirectory() && !path.equals(""))
{ {
int[] Banner = NativeLibrary.GetBanner(path); int[] Banner = NativeLibrary.GetBanner(path);
if (Banner[0] == 0) if (Banner[0] == 0)
{ {
try { try
InputStream path = ctx.getAssets().open("NoBanner.png"); {
image = BitmapFactory.decodeStream(path); InputStream noBannerPath = ctx.getAssets().open("NoBanner.png");
} catch (IOException e) { image = BitmapFactory.decodeStream(noBannerPath);
}
catch (IOException e)
{
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
else else
{
image = Bitmap.createBitmap(Banner, 96, 32, Bitmap.Config.ARGB_8888); image = Bitmap.createBitmap(Banner, 96, 32, Bitmap.Config.ARGB_8888);
}
name = NativeLibrary.GetTitle(path); name = NativeLibrary.GetTitle(path);
} }
} }
@ -56,13 +64,15 @@ public class GameListItem implements Comparable<GameListItem>{
{ {
return path; return path;
} }
public Bitmap getImage() public Bitmap getImage()
{ {
return image; return image;
} }
public boolean isValid() public boolean isValid()
{ {
return m_valid; return isValid;
} }
public int compareTo(GameListItem o) public int compareTo(GameListItem o)

View File

@ -14,13 +14,14 @@ import java.util.List;
* Licensed under GPLv2 * Licensed under GPLv2
* Refer to the license.txt file included. * Refer to the license.txt file included.
*/ */
public class InputConfigAdapter extends ArrayAdapter<InputConfigItem> { public final class InputConfigAdapter extends ArrayAdapter<InputConfigItem>
private Context c; {
private int id; private final Context c;
private List<InputConfigItem> items; private final int id;
private final List<InputConfigItem> items;
public InputConfigAdapter(Context context, int textViewResourceId, public InputConfigAdapter(Context context, int textViewResourceId, List<InputConfigItem> objects)
List<InputConfigItem> objects) { {
super(context, textViewResourceId, objects); super(context, textViewResourceId, objects);
c = context; c = context;
id = textViewResourceId; id = textViewResourceId;
@ -31,26 +32,30 @@ public class InputConfigAdapter extends ArrayAdapter<InputConfigItem> {
{ {
return items.get(i); return items.get(i);
} }
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(id, null);
}
final InputConfigItem o = items.get(position);
if (o != null) {
TextView t1 = (TextView) v.findViewById(R.id.FolderTitle);
TextView t2 = (TextView) v.findViewById(R.id.FolderSubTitle);
if(t1!=null) @Override
t1.setText(o.getName()); public View getView(int position, View convertView, ViewGroup parent)
if(t2!=null) {
t2.setText(o.getBind()); View v = convertView;
if (v == null)
{
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(id, parent, false);
} }
final InputConfigItem item = items.get(position);
if (item != null)
{
TextView title = (TextView) v.findViewById(R.id.FolderTitle);
TextView subtitle = (TextView) v.findViewById(R.id.FolderSubTitle);
if(title != null)
title.setText(item.getName());
if(subtitle != null)
subtitle.setText(item.getBind());
}
return v; return v;
} }
} }

View File

@ -18,8 +18,9 @@ import java.util.List;
* Licensed under GPLv2 * Licensed under GPLv2
* Refer to the license.txt file included. * Refer to the license.txt file included.
*/ */
public class InputConfigFragment extends Fragment public final class InputConfigFragment extends Fragment
implements GameListActivity.OnGameConfigListener{ implements GameListActivity.OnGameConfigListener
{
private Activity m_activity; private Activity m_activity;
private ListView mDrawerList; private ListView mDrawerList;
private InputConfigAdapter adapter; private InputConfigAdapter adapter;
@ -31,20 +32,24 @@ public class InputConfigFragment extends Fragment
{ {
if (input == null) if (input == null)
return "null"; // Happens when the inputdevice is from an unknown source return "null"; // Happens when the inputdevice is from an unknown source
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
{
return input.getDescriptor(); return input.getDescriptor();
}
else else
{ {
List<InputDevice.MotionRange> motions = input.getMotionRanges(); List<InputDevice.MotionRange> motions = input.getMotionRanges();
String fakeid = ""; String fakeid = "";
for (InputDevice.MotionRange range : motions) for (InputDevice.MotionRange range : motions)
fakeid += range.getAxis(); fakeid += range.getAxis();
return fakeid; return fakeid;
} }
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Bundle savedInstanceState)
{ {
List<InputConfigItem> Input = new ArrayList<InputConfigItem>(); List<InputConfigItem> Input = new ArrayList<InputConfigItem>();
Input.add(new InputConfigItem(getString(R.string.draw_onscreen_controls), "Android-ScreenControls", "True")); Input.add(new InputConfigItem(getString(R.string.draw_onscreen_controls), "Android-ScreenControls", "True"));
@ -77,6 +82,7 @@ public class InputConfigFragment extends Fragment
mDrawerList.setOnItemClickListener(mMenuItemClickListener); mDrawerList.setOnItemClickListener(mMenuItemClickListener);
return mDrawerList; return mDrawerList;
} }
private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener() private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener()
{ {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) public void onItemClick(AdapterView<?> parent, View view, int position, long id)
@ -100,6 +106,7 @@ public class InputConfigFragment extends Fragment
o.setBind(newBind); o.setBind(newBind);
adapter.insert(o, position); adapter.insert(o, position);
break; break;
default: // gamepad controls default: // gamepad controls
Toast.makeText(m_activity, getString(R.string.press_button_to_config, o.getName()), Toast.LENGTH_SHORT).show(); Toast.makeText(m_activity, getString(R.string.press_button_to_config, o.getName()), Toast.LENGTH_SHORT).show();
@ -111,19 +118,21 @@ public class InputConfigFragment extends Fragment
} }
}; };
static ArrayList<Float> m_values = new ArrayList<Float>(); private static ArrayList<Float> m_values = new ArrayList<Float>();
void AssignBind(String bind) private void AssignBind(String bind)
{ {
InputConfigItem o = adapter.getItem(configPosition); InputConfigItem o = adapter.getItem(configPosition);
adapter.remove(o); adapter.remove(o);
o.setBind(bind); o.setBind(bind);
adapter.insert(o, configPosition); adapter.insert(o, configPosition);
} }
public InputConfigAdapter getAdapter() public InputConfigAdapter getAdapter()
{ {
return adapter; return adapter;
} }
// Called from GameListActivity // Called from GameListActivity
public boolean onMotionEvent(MotionEvent event) public boolean onMotionEvent(MotionEvent event)
{ {
@ -149,8 +158,8 @@ public class InputConfigFragment extends Fragment
{ {
for (int a = 0; a < motions.size(); ++a) for (int a = 0; a < motions.size(); ++a)
{ {
InputDevice.MotionRange range; InputDevice.MotionRange range = motions.get(a);
range = motions.get(a);
if (m_values.get(a) > (event.getAxisValue(range.getAxis()) + 0.5f)) if (m_values.get(a) > (event.getAxisValue(range.getAxis()) + 0.5f))
{ {
AssignBind("Device '" + InputConfigFragment.getInputDesc(input) + "'-Axis " + range.getAxis() + "-"); AssignBind("Device '" + InputConfigFragment.getInputDesc(input) + "'-Axis " + range.getAxis() + "-");
@ -166,10 +175,12 @@ public class InputConfigFragment extends Fragment
} }
return true; return true;
} }
public boolean onKeyEvent(KeyEvent event) public boolean onKeyEvent(KeyEvent event)
{ {
Log.w("InputConfigFragment", "Got Event " + event.getAction()); Log.w("InputConfigFragment", "Got Event " + event.getAction());
switch (event.getAction()) { switch (event.getAction())
{
case KeyEvent.ACTION_DOWN: case KeyEvent.ACTION_DOWN:
case KeyEvent.ACTION_UP: case KeyEvent.ACTION_UP:
if (Configuring) if (Configuring)
@ -179,6 +190,7 @@ public class InputConfigFragment extends Fragment
Configuring = false; Configuring = false;
return true; return true;
} }
default: default:
break; break;
} }
@ -187,14 +199,18 @@ public class InputConfigFragment extends Fragment
} }
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity)
{
super.onAttach(activity); super.onAttach(activity);
// This makes sure that the container activity has implemented // This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception // the callback interface. If not, it throws an exception
try { try
{
m_activity = activity; m_activity = activity;
} catch (ClassCastException e) { }
catch (ClassCastException e)
{
throw new ClassCastException(activity.toString() throw new ClassCastException(activity.toString()
+ " must implement OnGameListZeroListener"); + " must implement OnGameListZeroListener");
} }

View File

@ -9,7 +9,8 @@ package org.dolphinemu.dolphinemu;
/** /**
* Represents a controller input item (button, stick, etc). * Represents a controller input item (button, stick, etc).
*/ */
public class InputConfigItem implements Comparable<InputConfigItem>{ public final class InputConfigItem implements Comparable<InputConfigItem>
{
private String m_name; private String m_name;
private String m_Config; private String m_Config;
private String m_bind; private String m_bind;

View File

@ -4,12 +4,14 @@ import android.content.Context;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
import android.view.SurfaceView; import android.view.SurfaceView;
public class NativeGLSurfaceView extends SurfaceView { public final class NativeGLSurfaceView extends SurfaceView
{
static private Thread myRun; static private Thread myRun;
static private boolean Running = false; static private boolean Running = false;
static private boolean Created = false; static private boolean Created = false;
public NativeGLSurfaceView(Context context) { public NativeGLSurfaceView(Context context)
{
super(context); super(context);
if (!Created) if (!Created)
{ {
@ -20,8 +22,10 @@ public class NativeGLSurfaceView extends SurfaceView {
NativeLibrary.Run(getHolder().getSurface()); NativeLibrary.Run(getHolder().getSurface());
} }
}; };
getHolder().addCallback(new SurfaceHolder.Callback() { getHolder().addCallback(new SurfaceHolder.Callback() {
public void surfaceCreated(SurfaceHolder holder) { public void surfaceCreated(SurfaceHolder holder)
{
// TODO Auto-generated method stub // TODO Auto-generated method stub
if (!Running) if (!Running)
{ {
@ -30,17 +34,17 @@ public class NativeGLSurfaceView extends SurfaceView {
} }
} }
public void surfaceChanged(SurfaceHolder arg0, int arg1, public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3)
int arg2, int arg3) { {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
public void surfaceDestroyed(SurfaceHolder arg0) { public void surfaceDestroyed(SurfaceHolder arg0)
{
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
}); });
Created = true; Created = true;
} }
} }

View File

@ -13,7 +13,8 @@ import android.view.Surface;
* Class which contains methods that interact * Class which contains methods that interact
* with the native side of the Dolphin code. * with the native side of the Dolphin code.
*/ */
public class NativeLibrary { public final class NativeLibrary
{
public static native void onTouchEvent(int Action, float X, float Y); public static native void onTouchEvent(int Action, float X, float Y);
public static native void onGamePadEvent(String Device, int Button, int Action); public static native void onGamePadEvent(String Device, int Button, int Action);
public static native void onGamePadMoveEvent(String Device, int Axis, float Value); public static native void onGamePadMoveEvent(String Device, int Axis, float Value);

View File

@ -17,10 +17,12 @@ import javax.microedition.khronos.opengles.GL10;
* Licensed under GPLv2 * Licensed under GPLv2
* Refer to the license.txt file included. * Refer to the license.txt file included.
*/ */
public class PrefsFragment extends PreferenceFragment { public final class PrefsFragment extends PreferenceFragment
{
private Activity m_activity; private Activity m_activity;
static public class VersionCheck { static public class VersionCheck
{
EGL10 mEGL; EGL10 mEGL;
EGLDisplay mEGLDisplay; EGLDisplay mEGLDisplay;
EGLConfig[] mEGLConfigs; EGLConfig[] mEGLConfigs;
@ -31,8 +33,8 @@ public class PrefsFragment extends PreferenceFragment {
String mThreadOwner; String mThreadOwner;
public VersionCheck() { public VersionCheck()
{
int[] version = new int[2]; int[] version = new int[2];
int[] attribList = new int[] { int[] attribList = new int[] {
EGL10.EGL_WIDTH, 1, EGL10.EGL_WIDTH, 1,
@ -69,11 +71,14 @@ public class PrefsFragment extends PreferenceFragment {
{ {
return mGL.glGetString(GL10.GL_VENDOR); return mGL.glGetString(GL10.GL_VENDOR);
} }
public String getRenderer() public String getRenderer()
{ {
return mGL.glGetString(GL10.GL_RENDERER); return mGL.glGetString(GL10.GL_RENDERER);
} }
private EGLConfig chooseConfig() {
private EGLConfig chooseConfig()
{
int[] attribList = new int[] { int[] attribList = new int[] {
EGL10.EGL_DEPTH_SIZE, 0, EGL10.EGL_DEPTH_SIZE, 0,
EGL10.EGL_STENCIL_SIZE, 0, EGL10.EGL_STENCIL_SIZE, 0,
@ -95,6 +100,7 @@ public class PrefsFragment extends PreferenceFragment {
return mEGLConfigs[0]; // Best match is probably the first configuration return mEGLConfigs[0]; // Best match is probably the first configuration
} }
} }
static public boolean SupportsGLES3() static public boolean SupportsGLES3()
{ {
VersionCheck mbuffer = new VersionCheck(); VersionCheck mbuffer = new VersionCheck();
@ -134,8 +140,10 @@ public class PrefsFragment extends PreferenceFragment {
} }
return mSupportsGLES3; return mSupportsGLES3;
} }
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Load the preferences from an XML resource // Load the preferences from an XML resource
@ -197,14 +205,18 @@ public class PrefsFragment extends PreferenceFragment {
} }
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity)
{
super.onAttach(activity); super.onAttach(activity);
// This makes sure that the container activity has implemented // This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception // the callback interface. If not, it throws an exception
try { try
{
m_activity = activity; m_activity = activity;
} catch (ClassCastException e) { }
catch (ClassCastException e)
{
throw new ClassCastException(activity.toString() throw new ClassCastException(activity.toString()
+ " must implement OnGameListZeroListener"); + " must implement OnGameListZeroListener");
} }

View File

@ -9,14 +9,13 @@ import android.widget.TextView;
import java.util.List; import java.util.List;
public class SideMenuAdapter extends ArrayAdapter<SideMenuItem>{ public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
{
private final Context c;
private final int id;
private final List<SideMenuItem>items;
private Context c; public SideMenuAdapter(Context context, int textViewResourceId, List<SideMenuItem> objects)
private int id;
private List<SideMenuItem>items;
public SideMenuAdapter(Context context, int textViewResourceId,
List<SideMenuItem> objects)
{ {
super(context, textViewResourceId, objects); super(context, textViewResourceId, objects);
c = context; c = context;
@ -28,6 +27,7 @@ public class SideMenuAdapter extends ArrayAdapter<SideMenuItem>{
{ {
return items.get(i); return items.get(i);
} }
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) public View getView(int position, View convertView, ViewGroup parent)
{ {
@ -38,13 +38,13 @@ public class SideMenuAdapter extends ArrayAdapter<SideMenuItem>{
v = vi.inflate(id, null); v = vi.inflate(id, null);
} }
final SideMenuItem o = items.get(position); final SideMenuItem item = items.get(position);
if (o != null) if (item != null)
{ {
TextView t1 = (TextView) v.findViewById(R.id.SideMenuTitle); TextView title = (TextView) v.findViewById(R.id.SideMenuTitle);
if(t1!=null) if(title != null)
t1.setText(o.getName()); title.setText(item.getName());
} }
return v; return v;

View File

@ -10,10 +10,10 @@ package org.dolphinemu.dolphinemu;
/** /**
* Represents an item that goes in the sidemenu of the app. * Represents an item that goes in the sidemenu of the app.
*/ */
public class SideMenuItem implements Comparable<SideMenuItem> public final class SideMenuItem implements Comparable<SideMenuItem>
{ {
private String m_name; private final String m_name;
private int m_id; private final int m_id;
/** /**
* Constructor * Constructor

View File

@ -20,7 +20,6 @@ set(SRCS Src/BreakPoints.cpp
Src/Thread.cpp Src/Thread.cpp
Src/Timer.cpp Src/Timer.cpp
Src/Version.cpp Src/Version.cpp
Src/VideoBackendBase.cpp
Src/x64ABI.cpp Src/x64ABI.cpp
Src/x64Analyzer.cpp Src/x64Analyzer.cpp
Src/x64Emitter.cpp Src/x64Emitter.cpp

View File

@ -195,7 +195,6 @@
<ClCompile Include="Src\Thread.cpp" /> <ClCompile Include="Src\Thread.cpp" />
<ClCompile Include="Src\Timer.cpp" /> <ClCompile Include="Src\Timer.cpp" />
<ClCompile Include="Src\Version.cpp" /> <ClCompile Include="Src\Version.cpp" />
<ClCompile Include="Src\VideoBackendBase.cpp" />
<ClCompile Include="Src\x64ABI.cpp" /> <ClCompile Include="Src\x64ABI.cpp" />
<ClCompile Include="Src\x64Analyzer.cpp" /> <ClCompile Include="Src\x64Analyzer.cpp" />
<ClCompile Include="Src\x64CPUDetect.cpp" /> <ClCompile Include="Src\x64CPUDetect.cpp" />
@ -250,7 +249,6 @@
<ClInclude Include="Src\Thread.h" /> <ClInclude Include="Src\Thread.h" />
<ClInclude Include="Src\Thunk.h" /> <ClInclude Include="Src\Thunk.h" />
<ClInclude Include="Src\Timer.h" /> <ClInclude Include="Src\Timer.h" />
<ClInclude Include="Src\VideoBackendBase.h" />
<ClInclude Include="Src\x64ABI.h" /> <ClInclude Include="Src\x64ABI.h" />
<ClInclude Include="Src\x64Analyzer.h" /> <ClInclude Include="Src\x64Analyzer.h" />
<ClInclude Include="Src\x64Emitter.h" /> <ClInclude Include="Src\x64Emitter.h" />

View File

@ -23,7 +23,6 @@
<ClCompile Include="Src\Thread.cpp" /> <ClCompile Include="Src\Thread.cpp" />
<ClCompile Include="Src\Timer.cpp" /> <ClCompile Include="Src\Timer.cpp" />
<ClCompile Include="Src\Version.cpp" /> <ClCompile Include="Src\Version.cpp" />
<ClCompile Include="Src\VideoBackendBase.cpp" />
<ClCompile Include="Src\x64Analyzer.cpp" /> <ClCompile Include="Src\x64Analyzer.cpp" />
<ClCompile Include="Src\x64Emitter.cpp" /> <ClCompile Include="Src\x64Emitter.cpp" />
<ClCompile Include="Src\LogManager.cpp"> <ClCompile Include="Src\LogManager.cpp">
@ -92,7 +91,6 @@
<ClInclude Include="Src\Thread.h" /> <ClInclude Include="Src\Thread.h" />
<ClInclude Include="Src\Thunk.h" /> <ClInclude Include="Src\Thunk.h" />
<ClInclude Include="Src\Timer.h" /> <ClInclude Include="Src\Timer.h" />
<ClInclude Include="Src\VideoBackendBase.h" />
<ClInclude Include="Src\x64Analyzer.h" /> <ClInclude Include="Src\x64Analyzer.h" />
<ClInclude Include="Src\x64Emitter.h" /> <ClInclude Include="Src\x64Emitter.h" />
<ClInclude Include="Src\Log.h"> <ClInclude Include="Src\Log.h">

View File

@ -20,6 +20,7 @@
#include <linux/ashmem.h> #include <linux/ashmem.h>
#endif #endif
#endif #endif
#include <set>
#if defined(__APPLE__) #if defined(__APPLE__)
static const char* ram_temp_file = "/tmp/gc_mem.tmp"; static const char* ram_temp_file = "/tmp/gc_mem.tmp";
@ -214,27 +215,7 @@ static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32
bail: bail:
// Argh! ERROR! Free what we grabbed so far so we can try again. // Argh! ERROR! Free what we grabbed so far so we can try again.
for (int j = 0; j <= i; j++) MemoryMap_Shutdown(views, i+1, flags, arena);
{
SKIP(flags, views[i].flags);
if (views[j].out_ptr_low && *views[j].out_ptr_low)
{
arena->ReleaseView(*views[j].out_ptr_low, views[j].size);
*views[j].out_ptr_low = NULL;
}
if (*views[j].out_ptr)
{
#ifdef _M_X64
arena->ReleaseView(*views[j].out_ptr, views[j].size);
#else
if (!(views[j].flags & MV_MIRROR_PREVIOUS))
{
arena->ReleaseView(*views[j].out_ptr, views[j].size);
}
#endif
*views[j].out_ptr = NULL;
}
}
return false; return false;
} }
@ -300,15 +281,20 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena
void MemoryMap_Shutdown(const MemoryView *views, int num_views, u32 flags, MemArena *arena) void MemoryMap_Shutdown(const MemoryView *views, int num_views, u32 flags, MemArena *arena)
{ {
std::set<void*> freeset;
for (int i = 0; i < num_views; i++) for (int i = 0; i < num_views; i++)
{ {
SKIP(flags, views[i].flags); const MemoryView* view = &views[i];
if (views[i].out_ptr_low && *views[i].out_ptr_low) u8** outptrs[2] = {view->out_ptr_low, view->out_ptr};
arena->ReleaseView(*views[i].out_ptr_low, views[i].size); for (int j = 0; j < 2; j++)
if (*views[i].out_ptr && (views[i].out_ptr_low && *views[i].out_ptr != *views[i].out_ptr_low)) {
arena->ReleaseView(*views[i].out_ptr, views[i].size); u8** outptr = outptrs[j];
*views[i].out_ptr = NULL; if (outptr && *outptr && !freeset.count(*outptr))
if (views[i].out_ptr_low) {
*views[i].out_ptr_low = NULL; arena->ReleaseView(*outptr, view->size);
freeset.insert(*outptr);
*outptr = NULL;
}
}
} }
} }

View File

@ -581,6 +581,8 @@ bool NetPlayServer::StopGame()
std::lock_guard<std::recursive_mutex> lks(m_crit.send); std::lock_guard<std::recursive_mutex> lks(m_crit.send);
SendToClients(spac); SendToClients(spac);
m_is_running = false;
return true; return true;
} }

View File

@ -1049,6 +1049,7 @@ void CFrame::DoStop()
DoRecordingSave(); DoRecordingSave();
if(Movie::IsPlayingInput() || Movie::IsRecordingInput()) if(Movie::IsPlayingInput() || Movie::IsRecordingInput())
Movie::EndPlayInput(false); Movie::EndPlayInput(false);
NetPlay::StopGame();
wxBeginBusyCursor(); wxBeginBusyCursor();
BootManager::Stop(); BootManager::Stop();

View File

@ -17,6 +17,7 @@
#include <string> #include <string>
#define NETPLAY_TITLEBAR "Dolphin NetPlay" #define NETPLAY_TITLEBAR "Dolphin NetPlay"
#define INITIAL_PAD_BUFFER_SIZE 20
BEGIN_EVENT_TABLE(NetPlayDiag, wxFrame) BEGIN_EVENT_TABLE(NetPlayDiag, wxFrame)
EVT_COMMAND(wxID_ANY, wxEVT_THREAD, NetPlayDiag::OnThread) EVT_COMMAND(wxID_ANY, wxEVT_THREAD, NetPlayDiag::OnThread)
@ -246,6 +247,7 @@ void NetPlaySetupDiag::OnHost(wxCommandEvent&)
m_host_port_text->GetValue().ToULong(&port); m_host_port_text->GetValue().ToULong(&port);
netplay_server = new NetPlayServer(u16(port)); netplay_server = new NetPlayServer(u16(port));
netplay_server->ChangeGame(game); netplay_server->ChangeGame(game);
netplay_server->AdjustPadBufferSize(INITIAL_PAD_BUFFER_SIZE);
if (netplay_server->is_connected) if (netplay_server->is_connected)
{ {
#ifdef USE_UPNP #ifdef USE_UPNP
@ -281,6 +283,7 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game
: wxFrame(parent, wxID_ANY, wxT(NETPLAY_TITLEBAR), wxDefaultPosition, wxDefaultSize) : wxFrame(parent, wxID_ANY, wxT(NETPLAY_TITLEBAR), wxDefaultPosition, wxDefaultSize)
, m_selected_game(game) , m_selected_game(game)
, m_game_list(game_list) , m_game_list(game_list)
, m_start_btn(NULL)
{ {
wxPanel* const panel = new wxPanel(this); wxPanel* const panel = new wxPanel(this);
@ -338,15 +341,13 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game
wxBoxSizer* const bottom_szr = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* const bottom_szr = new wxBoxSizer(wxHORIZONTAL);
if (is_hosting) if (is_hosting)
{ {
wxButton* const start_btn = new wxButton(panel, wxID_ANY, _("Start")); m_start_btn = new wxButton(panel, wxID_ANY, _("Start"));
start_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &NetPlayDiag::OnStart, this); m_start_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &NetPlayDiag::OnStart, this);
bottom_szr->Add(start_btn); bottom_szr->Add(m_start_btn);
wxButton* const stop_btn = new wxButton(panel, wxID_ANY, _("Stop"));
stop_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &NetPlayDiag::OnStop, this);
bottom_szr->Add(stop_btn);
bottom_szr->Add(new wxStaticText(panel, wxID_ANY, _("Buffer:")), 0, wxLEFT | wxCENTER, 5 ); bottom_szr->Add(new wxStaticText(panel, wxID_ANY, _("Buffer:")), 0, wxLEFT | wxCENTER, 5 );
wxSpinCtrl* const padbuf_spin = new wxSpinCtrl(panel, wxID_ANY, wxT("20") wxSpinCtrl* const padbuf_spin = new wxSpinCtrl(panel, wxID_ANY, wxT("20")
, wxDefaultPosition, wxSize(64, -1), wxSP_ARROW_KEYS, 0, 200, 20); , wxDefaultPosition, wxSize(64, -1), wxSP_ARROW_KEYS, 0, 200, INITIAL_PAD_BUFFER_SIZE);
padbuf_spin->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &NetPlayDiag::OnAdjustBuffer, this); padbuf_spin->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &NetPlayDiag::OnAdjustBuffer, this);
bottom_szr->Add(padbuf_spin, 0, wxCENTER); bottom_szr->Add(padbuf_spin, 0, wxCENTER);
} }
@ -428,11 +429,6 @@ void NetPlayDiag::OnStart(wxCommandEvent&)
netplay_server->StartGame(FindGame()); netplay_server->StartGame(FindGame());
} }
void NetPlayDiag::OnStop(wxCommandEvent&)
{
netplay_server->StopGame();
}
void NetPlayDiag::BootGame(const std::string& filename) void NetPlayDiag::BootGame(const std::string& filename)
{ {
main_frame->BootGame(filename); main_frame->BootGame(filename);
@ -469,12 +465,16 @@ void NetPlayDiag::OnMsgStartGame()
{ {
wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_START_GAME); wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_START_GAME);
GetEventHandler()->AddPendingEvent(evt); GetEventHandler()->AddPendingEvent(evt);
if (m_start_btn)
m_start_btn->Disable();
} }
void NetPlayDiag::OnMsgStopGame() void NetPlayDiag::OnMsgStopGame()
{ {
wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_STOP_GAME); wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_STOP_GAME);
GetEventHandler()->AddPendingEvent(evt); GetEventHandler()->AddPendingEvent(evt);
if (m_start_btn)
m_start_btn->Enable();
} }
void NetPlayDiag::OnAdjustBuffer(wxCommandEvent& event) void NetPlayDiag::OnAdjustBuffer(wxCommandEvent& event)
@ -659,3 +659,11 @@ void PadMapDiag::OnAdjust(wxCommandEvent& event)
for (unsigned int i=0; i<4; ++i) for (unsigned int i=0; i<4; ++i)
m_mapping[i] = m_map_cbox[i]->GetSelection() - 1; m_mapping[i] = m_map_cbox[i]->GetSelection() - 1;
} }
void NetPlay::StopGame()
{
if (netplay_server != NULL)
netplay_server->StopGame();
// TODO: allow non-hosting clients to close the window
}

View File

@ -67,7 +67,6 @@ public:
Common::FifoQueue<std::string> chat_msgs; Common::FifoQueue<std::string> chat_msgs;
void OnStart(wxCommandEvent& event); void OnStart(wxCommandEvent& event);
void OnStop(wxCommandEvent& event);
// implementation of NetPlayUI methods // implementation of NetPlayUI methods
void BootGame(const std::string& filename); void BootGame(const std::string& filename);
@ -101,6 +100,7 @@ private:
std::string m_selected_game; std::string m_selected_game;
wxButton* m_game_btn; wxButton* m_game_btn;
wxButton* m_start_btn;
std::vector<int> m_playerids; std::vector<int> m_playerids;
@ -133,5 +133,10 @@ private:
int* const m_mapping; int* const m_mapping;
}; };
namespace NetPlay
{
void StopGame();
}
#endif // _NETWINDOW_H_ #endif // _NETWINDOW_H_

View File

@ -33,6 +33,7 @@ set(SRCS Src/BPFunctions.cpp
Src/VertexManagerBase.cpp Src/VertexManagerBase.cpp
Src/VertexShaderGen.cpp Src/VertexShaderGen.cpp
Src/VertexShaderManager.cpp Src/VertexShaderManager.cpp
Src/VideoBackendBase.cpp
Src/VideoConfig.cpp Src/VideoConfig.cpp
Src/VideoState.cpp Src/VideoState.cpp
Src/XFMemory.cpp Src/XFMemory.cpp

View File

@ -153,7 +153,10 @@ void BPWritten(const BPCmd& bp)
bpmem.genMode.numtexgens, bpmem.genMode.numcolchans, bpmem.genMode.numtexgens, bpmem.genMode.numcolchans,
bpmem.genMode.multisampling, bpmem.genMode.numtevstages+1, bpmem.genMode.cullmode, bpmem.genMode.multisampling, bpmem.genMode.numtevstages+1, bpmem.genMode.cullmode,
bpmem.genMode.numindstages, bpmem.genMode.zfreeze); bpmem.genMode.numindstages, bpmem.genMode.zfreeze);
SetGenerationMode();
// Only call SetGenerationMode when cull mode changes.
if (bp.changes & 0xC000)
SetGenerationMode();
break; break;
} }
case BPMEM_IND_MTXA: // Index Matrix Changed case BPMEM_IND_MTXA: // Index Matrix Changed

View File

@ -1,3 +1,9 @@
#include "PerfQueryBase.h" #include "PerfQueryBase.h"
#include "VideoConfig.h"
PerfQueryBase* g_perf_query = 0; PerfQueryBase* g_perf_query = 0;
bool PerfQueryBase::ShouldEmulate() const
{
return g_ActiveConfig.bPerfQueriesEnable;
}

View File

@ -25,9 +25,12 @@ enum PerfQueryGroup
class PerfQueryBase class PerfQueryBase
{ {
public: public:
PerfQueryBase() {}; PerfQueryBase() {}
virtual ~PerfQueryBase() {} virtual ~PerfQueryBase() {}
// Checks if performance queries are enabled in the gameini configuration.
bool ShouldEmulate() const;
// Begin querying the specified value for the following host GPU commands // Begin querying the specified value for the following host GPU commands
virtual void EnableQuery(PerfQueryGroup type) {} virtual void EnableQuery(PerfQueryGroup type) {}

View File

@ -92,8 +92,6 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
_assert_(bpmem.genMode.numtexgens == xfregs.numTexGen.numTexGens); _assert_(bpmem.genMode.numtexgens == xfregs.numTexGen.numTexGens);
_assert_(bpmem.genMode.numcolchans == xfregs.numChan.numColorChans); _assert_(bpmem.genMode.numcolchans == xfregs.numChan.numColorChans);
bool is_d3d = (api_type & API_D3D9 || api_type == API_D3D11);
// uniforms // uniforms
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
out.Write("layout(std140) uniform VSBlock {\n"); out.Write("layout(std140) uniform VSBlock {\n");
@ -177,19 +175,9 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
if (components & VB_HAS_NRM0) if (components & VB_HAS_NRM0)
out.Write(" float3 rawnorm0 : NORMAL0,\n"); out.Write(" float3 rawnorm0 : NORMAL0,\n");
if (components & VB_HAS_NRM1) if (components & VB_HAS_NRM1)
{ out.Write(" float3 rawnorm1 : NORMAL1,\n");
if (is_d3d)
out.Write(" float3 rawnorm1 : NORMAL1,\n");
else
out.Write(" float3 rawnorm1 : ATTR%d,\n", SHADER_NORM1_ATTRIB);
}
if (components & VB_HAS_NRM2) if (components & VB_HAS_NRM2)
{ out.Write(" float3 rawnorm2 : NORMAL2,\n");
if (is_d3d)
out.Write(" float3 rawnorm2 : NORMAL2,\n");
else
out.Write(" float3 rawnorm2 : ATTR%d,\n", SHADER_NORM2_ATTRIB);
}
if (components & VB_HAS_COL0) if (components & VB_HAS_COL0)
out.Write(" float4 color0 : COLOR0,\n"); out.Write(" float4 color0 : COLOR0,\n");
if (components & VB_HAS_COL1) if (components & VB_HAS_COL1)
@ -201,12 +189,7 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
out.Write(" float%d tex%d : TEXCOORD%d,\n", hastexmtx ? 3 : 2, i, i); out.Write(" float%d tex%d : TEXCOORD%d,\n", hastexmtx ? 3 : 2, i, i);
} }
if (components & VB_HAS_POSMTXIDX) if (components & VB_HAS_POSMTXIDX)
{ out.Write(" float4 blend_indices : BLENDINDICES,\n");
if (is_d3d)
out.Write(" float4 blend_indices : BLENDINDICES,\n");
else
out.Write(" float fposmtx : ATTR%d,\n", SHADER_POSMTX_ATTRIB);
}
out.Write(" float4 rawpos : POSITION) {\n"); out.Write(" float4 rawpos : POSITION) {\n");
} }
out.Write("VS_OUTPUT o;\n"); out.Write("VS_OUTPUT o;\n");
@ -471,7 +454,7 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
//write the true depth value, if the game uses depth textures pixel shaders will override with the correct values //write the true depth value, if the game uses depth textures pixel shaders will override with the correct values
//if not early z culling will improve speed //if not early z culling will improve speed
if (is_d3d) if (api_type & API_D3D9 || api_type == API_D3D11)
{ {
out.Write("o.pos.z = " I_DEPTHPARAMS".x * o.pos.w + o.pos.z * " I_DEPTHPARAMS".y;\n"); out.Write("o.pos.z = " I_DEPTHPARAMS".x * o.pos.w + o.pos.z * " I_DEPTHPARAMS".y;\n");
} }

View File

@ -19,6 +19,8 @@ VideoBackend* g_video_backend = NULL;
static VideoBackend* s_default_backend = NULL; static VideoBackend* s_default_backend = NULL;
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h>
// http://msdn.microsoft.com/en-us/library/ms725491.aspx // http://msdn.microsoft.com/en-us/library/ms725491.aspx
static bool IsGteVista() static bool IsGteVista()
{ {

View File

@ -182,6 +182,7 @@ void VideoConfig::GameIniLoad(const char *ini_file)
iniFile.GetIfExists("Video", "PH_ZFar", &sPhackvalue[1]); iniFile.GetIfExists("Video", "PH_ZFar", &sPhackvalue[1]);
iniFile.GetIfExists("Video", "ZTPSpeedupHack", &bZTPSpeedHack); iniFile.GetIfExists("Video", "ZTPSpeedupHack", &bZTPSpeedHack);
iniFile.GetIfExists("Video", "UseBBox", &bUseBBox); iniFile.GetIfExists("Video", "UseBBox", &bUseBBox);
iniFile.GetIfExists("Video", "PerfQueriesEnable", &bPerfQueriesEnable);
} }
void VideoConfig::VerifyValidity() void VideoConfig::VerifyValidity()

View File

@ -108,6 +108,7 @@ struct VideoConfig
// Hacks // Hacks
bool bEFBAccessEnable; bool bEFBAccessEnable;
bool bDlistCachingEnable; bool bDlistCachingEnable;
bool bPerfQueriesEnable;
bool bEFBCopyEnable; bool bEFBCopyEnable;
bool bEFBCopyCacheEnable; bool bEFBCopyCacheEnable;

View File

@ -213,6 +213,7 @@
<ClCompile Include="Src\VertexManagerBase.cpp" /> <ClCompile Include="Src\VertexManagerBase.cpp" />
<ClCompile Include="Src\VertexShaderGen.cpp" /> <ClCompile Include="Src\VertexShaderGen.cpp" />
<ClCompile Include="Src\VertexShaderManager.cpp" /> <ClCompile Include="Src\VertexShaderManager.cpp" />
<ClCompile Include="Src\VideoBackendBase.cpp" />
<ClCompile Include="Src\VideoConfig.cpp" /> <ClCompile Include="Src\VideoConfig.cpp" />
<ClCompile Include="Src\VideoState.cpp" /> <ClCompile Include="Src\VideoState.cpp" />
<ClCompile Include="Src\x64DLCache.cpp" /> <ClCompile Include="Src\x64DLCache.cpp" />
@ -266,6 +267,7 @@
<ClInclude Include="Src\VertexShaderGen.h" /> <ClInclude Include="Src\VertexShaderGen.h" />
<ClInclude Include="Src\VertexShaderManager.h" /> <ClInclude Include="Src\VertexShaderManager.h" />
<ClInclude Include="Src\VideoCommon.h" /> <ClInclude Include="Src\VideoCommon.h" />
<ClInclude Include="Src\VideoBackendBase.h" />
<ClInclude Include="Src\VideoConfig.h" /> <ClInclude Include="Src\VideoConfig.h" />
<ClInclude Include="Src\VideoState.h" /> <ClInclude Include="Src\VideoState.h" />
<ClInclude Include="Src\XFMemory.h" /> <ClInclude Include="Src\XFMemory.h" />

View File

@ -4,6 +4,7 @@
<ClCompile Include="Src\CommandProcessor.cpp" /> <ClCompile Include="Src\CommandProcessor.cpp" />
<ClCompile Include="Src\memcpy_amd.cpp" /> <ClCompile Include="Src\memcpy_amd.cpp" />
<ClCompile Include="Src\PixelEngine.cpp" /> <ClCompile Include="Src\PixelEngine.cpp" />
<ClCompile Include="Src\VideoBackendBase.cpp" />
<ClCompile Include="Src\VideoConfig.cpp" /> <ClCompile Include="Src\VideoConfig.cpp" />
<ClCompile Include="Src\VertexLoader.cpp"> <ClCompile Include="Src\VertexLoader.cpp">
<Filter>Vertex Loading</Filter> <Filter>Vertex Loading</Filter>
@ -128,6 +129,7 @@
<ClInclude Include="Src\NativeVertexFormat.h" /> <ClInclude Include="Src\NativeVertexFormat.h" />
<ClInclude Include="Src\PixelEngine.h" /> <ClInclude Include="Src\PixelEngine.h" />
<ClInclude Include="Src\VideoCommon.h" /> <ClInclude Include="Src\VideoCommon.h" />
<ClInclude Include="Src\VideoBackendBase.h" />
<ClInclude Include="Src\VideoConfig.h" /> <ClInclude Include="Src\VideoConfig.h" />
<ClInclude Include="Src\DataReader.h"> <ClInclude Include="Src\DataReader.h">
<Filter>Vertex Loading</Filter> <Filter>Vertex Loading</Filter>

View File

@ -333,11 +333,7 @@ HRESULT Create(HWND wnd)
swap_chain_desc.BufferDesc.Width = xres; swap_chain_desc.BufferDesc.Width = xres;
swap_chain_desc.BufferDesc.Height = yres; swap_chain_desc.BufferDesc.Height = yres;
#if defined(_DEBUG) || defined(DEBUGFAST)
D3D11_CREATE_DEVICE_FLAG device_flags = (D3D11_CREATE_DEVICE_FLAG)(D3D11_CREATE_DEVICE_DEBUG|D3D11_CREATE_DEVICE_SINGLETHREADED);
#else
D3D11_CREATE_DEVICE_FLAG device_flags = D3D11_CREATE_DEVICE_SINGLETHREADED; D3D11_CREATE_DEVICE_FLAG device_flags = D3D11_CREATE_DEVICE_SINGLETHREADED;
#endif
hr = PD3D11CreateDeviceAndSwapChain(adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, device_flags, hr = PD3D11CreateDeviceAndSwapChain(adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, device_flags,
supported_feature_levels, NUM_SUPPORTED_FEATURE_LEVELS, supported_feature_levels, NUM_SUPPORTED_FEATURE_LEVELS,
D3D11_SDK_VERSION, &swap_chain_desc, &swapchain, &device, D3D11_SDK_VERSION, &swap_chain_desc, &swapchain, &device,

View File

@ -28,6 +28,9 @@ PerfQuery::~PerfQuery()
void PerfQuery::EnableQuery(PerfQueryGroup type) void PerfQuery::EnableQuery(PerfQueryGroup type)
{ {
if (!ShouldEmulate())
return;
// Is this sane? // Is this sane?
if (m_query_count > ARRAYSIZE(m_query_buffer) / 2) if (m_query_count > ARRAYSIZE(m_query_buffer) / 2)
WeakFlush(); WeakFlush();
@ -53,6 +56,9 @@ void PerfQuery::EnableQuery(PerfQueryGroup type)
void PerfQuery::DisableQuery(PerfQueryGroup type) void PerfQuery::DisableQuery(PerfQueryGroup type)
{ {
if (!ShouldEmulate())
return;
// stop query // stop query
if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP) if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP)
{ {
@ -69,6 +75,9 @@ void PerfQuery::ResetQuery()
u32 PerfQuery::GetQueryResult(PerfQueryType type) u32 PerfQuery::GetQueryResult(PerfQueryType type)
{ {
if (!ShouldEmulate())
return 0;
u32 result = 0; u32 result = 0;
if (type == PQ_ZCOMP_INPUT_ZCOMPLOC || type == PQ_ZCOMP_OUTPUT_ZCOMPLOC) if (type == PQ_ZCOMP_INPUT_ZCOMPLOC || type == PQ_ZCOMP_OUTPUT_ZCOMPLOC)
@ -93,6 +102,9 @@ u32 PerfQuery::GetQueryResult(PerfQueryType type)
void PerfQuery::FlushOne() void PerfQuery::FlushOne()
{ {
if (!ShouldEmulate())
return;
auto& entry = m_query_buffer[m_query_read_pos]; auto& entry = m_query_buffer[m_query_read_pos];
UINT64 result = 0; UINT64 result = 0;
@ -113,12 +125,18 @@ void PerfQuery::FlushOne()
// TODO: could selectively flush things, but I don't think that will do much // TODO: could selectively flush things, but I don't think that will do much
void PerfQuery::FlushResults() void PerfQuery::FlushResults()
{ {
if (!ShouldEmulate())
return;
while (!IsFlushed()) while (!IsFlushed())
FlushOne(); FlushOne();
} }
void PerfQuery::WeakFlush() void PerfQuery::WeakFlush()
{ {
if (!ShouldEmulate())
return;
while (!IsFlushed()) while (!IsFlushed())
{ {
auto& entry = m_query_buffer[m_query_read_pos]; auto& entry = m_query_buffer[m_query_read_pos];
@ -143,6 +161,9 @@ void PerfQuery::WeakFlush()
bool PerfQuery::IsFlushed() const bool PerfQuery::IsFlushed() const
{ {
if (!ShouldEmulate())
return true;
return 0 == m_query_count; return 0 == m_query_count;
} }

View File

@ -23,6 +23,9 @@ PerfQuery::~PerfQuery()
void PerfQuery::EnableQuery(PerfQueryGroup type) void PerfQuery::EnableQuery(PerfQueryGroup type)
{ {
if (!ShouldEmulate())
return;
// Is this sane? // Is this sane?
if (m_query_count > ARRAYSIZE(m_query_buffer) / 2) if (m_query_count > ARRAYSIZE(m_query_buffer) / 2)
WeakFlush(); WeakFlush();
@ -47,6 +50,9 @@ void PerfQuery::EnableQuery(PerfQueryGroup type)
void PerfQuery::DisableQuery(PerfQueryGroup type) void PerfQuery::DisableQuery(PerfQueryGroup type)
{ {
if (!ShouldEmulate())
return;
// stop query // stop query
if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP) if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP)
{ {
@ -56,11 +62,17 @@ void PerfQuery::DisableQuery(PerfQueryGroup type)
bool PerfQuery::IsFlushed() const bool PerfQuery::IsFlushed() const
{ {
if (!ShouldEmulate())
return true;
return 0 == m_query_count; return 0 == m_query_count;
} }
void PerfQuery::FlushOne() void PerfQuery::FlushOne()
{ {
if (!ShouldEmulate())
return;
auto& entry = m_query_buffer[m_query_read_pos]; auto& entry = m_query_buffer[m_query_read_pos];
GLuint result = 0; GLuint result = 0;
@ -76,12 +88,18 @@ void PerfQuery::FlushOne()
// TODO: could selectively flush things, but I don't think that will do much // TODO: could selectively flush things, but I don't think that will do much
void PerfQuery::FlushResults() void PerfQuery::FlushResults()
{ {
if (!ShouldEmulate())
return;
while (!IsFlushed()) while (!IsFlushed())
FlushOne(); FlushOne();
} }
void PerfQuery::WeakFlush() void PerfQuery::WeakFlush()
{ {
if (!ShouldEmulate())
return;
while (!IsFlushed()) while (!IsFlushed())
{ {
auto& entry = m_query_buffer[m_query_read_pos]; auto& entry = m_query_buffer[m_query_read_pos];
@ -108,6 +126,9 @@ void PerfQuery::ResetQuery()
u32 PerfQuery::GetQueryResult(PerfQueryType type) u32 PerfQuery::GetQueryResult(PerfQueryType type)
{ {
if (!ShouldEmulate())
return 0;
u32 result = 0; u32 result = 0;
if (type == PQ_ZCOMP_INPUT_ZCOMPLOC || type == PQ_ZCOMP_OUTPUT_ZCOMPLOC) if (type == PQ_ZCOMP_INPUT_ZCOMPLOC || type == PQ_ZCOMP_OUTPUT_ZCOMPLOC)