1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-15 13:51:40 +00:00

Style: Apply clang-format on all files

Thus fixing some invalid changes that had still made it to the 2.1 branch.
This commit is contained in:
Rémi Verschelde
2017-07-30 23:00:25 +02:00
parent 6d3fea6864
commit c1f54e1a45
17 changed files with 280 additions and 296 deletions

View File

@@ -2314,12 +2314,12 @@ void Image::blend_rect(const Image &p_src, const Rect2 &p_src_rect, const Point2
BColor src = p_src._get_pixel(rrect.pos.x + j, rrect.pos.y + i, src_data_ptr, srcdsize);
BColor dst = _get_pixel(p_dest.x + j, p_dest.y + i, dst_data_ptr, dst_data_size);
float ba = (float) dst.a / 255.0;
float fa = (float) src.a / 255.0;
dst.r = (uint8_t) (fa*src.r + ba*(1.0 - fa) * dst.r);
dst.g = (uint8_t) (fa*src.g + ba*(1.0 - fa) * dst.g);
dst.b = (uint8_t) (fa*src.b + ba*(1.0 - fa) * dst.b);
dst.a = (uint8_t) (255.0 * (fa + ba * (1.0 - fa)));
float ba = (float)dst.a / 255.0;
float fa = (float)src.a / 255.0;
dst.r = (uint8_t)(fa * src.r + ba * (1.0 - fa) * dst.r);
dst.g = (uint8_t)(fa * src.g + ba * (1.0 - fa) * dst.g);
dst.b = (uint8_t)(fa * src.b + ba * (1.0 - fa) * dst.b);
dst.a = (uint8_t)(255.0 * (fa + ba * (1.0 - fa)));
_put_pixel(p_dest.x + j, p_dest.y + i, dst, dst_data_ptr);
}
}
@@ -2369,12 +2369,12 @@ void Image::blend_rect_mask(const Image &p_src, const Image &p_mask, const Rect2
if (msk.a != 0) {
BColor src = p_src._get_pixel(rrect.pos.x + j, rrect.pos.y + i, src_data_ptr, srcdsize);
BColor dst = _get_pixel(p_dest.x + j, p_dest.y + i, dst_data_ptr, dst_data_size);
float ba = (float) dst.a / 255.0;
float fa = (float) src.a / 255.0;
dst.r = (uint8_t) (fa*src.r + ba*(1.0 - fa) * dst.r);
dst.g = (uint8_t) (fa*src.g + ba*(1.0 - fa) * dst.g);
dst.b = (uint8_t) (fa*src.b + ba*(1.0 - fa) * dst.b);
dst.a = (uint8_t) (255.0 * (fa + ba * (1.0 - fa)));
float ba = (float)dst.a / 255.0;
float fa = (float)src.a / 255.0;
dst.r = (uint8_t)(fa * src.r + ba * (1.0 - fa) * dst.r);
dst.g = (uint8_t)(fa * src.g + ba * (1.0 - fa) * dst.g);
dst.b = (uint8_t)(fa * src.b + ba * (1.0 - fa) * dst.b);
dst.a = (uint8_t)(255.0 * (fa + ba * (1.0 - fa)));
_put_pixel(p_dest.x + j, p_dest.y + i, dst, dst_data_ptr);
}
}
@@ -2389,7 +2389,7 @@ void Image::fill(const Color &p_color) {
DVector<uint8_t>::Write wp = data.write();
unsigned char *dst_data_ptr = wp.ptr();
BColor c = BColor(p_color.r*255, p_color.g*255, p_color.b*255, p_color.a*255);
BColor c = BColor(p_color.r * 255, p_color.g * 255, p_color.b * 255, p_color.a * 255);
for (int i = 0; i < height; i++) {
@@ -2398,7 +2398,6 @@ void Image::fill(const Color &p_color) {
_put_pixel(j, i, c, dst_data_ptr);
}
}
}
Image (*Image::_png_mem_loader_func)(const uint8_t *, int) = NULL;

View File

@@ -111,7 +111,7 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p
switch (p_mode) {
case MODE_FASTLZ: {
int ret_size=0;
int ret_size = 0;
if (p_dst_max_size < 16) {
uint8_t dst[16];

View File

@@ -120,7 +120,7 @@ public:
bool is_subsequence_ofi(const String &p_string) const;
Vector<String> bigrams() const;
float similarity(const String &p_string) const;
String format(const Variant& values, String placeholder = "{_}") const;
String format(const Variant &values, String placeholder = "{_}") const;
String replace_first(String p_key, String p_with) const;
String replace(String p_key, String p_with) const;
String replacen(String p_key, String p_with) const;

View File

@@ -512,7 +512,6 @@ Error EditorMeshImportPlugin::import(const String &p_path, const Ref<ResourceImp
surf_tool->add_smooth_group(true);
has_index_data = false;
}
if (l.begins_with("o ")) //name

View File

@@ -1041,8 +1041,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
v_scroll->set_val(v_scroll->get_val() + int(EditorSettings::get_singleton()->get("2d_editor/pan_speed")) / zoom * b.factor);
}
else {
} else {
if (zoom < MIN_ZOOM)
return;
@@ -1055,7 +1054,6 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
h_scroll->set_val(h_scroll->get_val() + ofs.x);
v_scroll->set_val(v_scroll->get_val() + ofs.y);
}
}
_update_scroll(0);
@@ -1069,8 +1067,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
v_scroll->set_val(v_scroll->get_val() - int(EditorSettings::get_singleton()->get("2d_editor/pan_speed")) / zoom * b.factor);
}
else {
} else {
if (zoom > MAX_ZOOM)
return;
@@ -1083,7 +1080,6 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
h_scroll->set_val(h_scroll->get_val() + ofs.x);
v_scroll->set_val(v_scroll->get_val() + ofs.y);
}
}
_update_scroll(0);
@@ -1099,9 +1095,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
_update_scroll(0);
viewport->update();
}
}
if (b.button_index == BUTTON_WHEEL_RIGHT) {
@@ -1112,9 +1106,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent &p_event) {
_update_scroll(0);
viewport->update();
}
}
if (b.button_index == BUTTON_RIGHT) {

View File

@@ -29,11 +29,11 @@
/*************************************************************************/
#import "app_delegate.h"
#include "audio_driver_iphone.h"
#include "core/globals.h"
#import "gl_view.h"
#include "main/main.h"
#include "os_iphone.h"
#include "audio_driver_iphone.h"
#ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED
#include "modules/FacebookScorer_ios/FacebookScorer.h"
@@ -605,8 +605,7 @@ static int frame_count = 0;
view_controller.view = glView;
window.rootViewController = view_controller;
_set_keep_screen_on(bool(GLOBAL_DEF("display/keep_screen_on", true)) ? YES
: NO);
_set_keep_screen_on(bool(GLOBAL_DEF("display/keep_screen_on", true)) ? YES : NO);
glView.useCADisplayLink =
bool(GLOBAL_DEF("display.iOS/use_cadisplaylink", true)) ? YES : NO;
printf("cadisaplylink: %d", glView.useCADisplayLink);
@@ -728,7 +727,7 @@ static int frame_count = 0;
};
// Fixed audio can not resume if it is interrupted cause by an incoming phone call
if(AudioDriverIphone::get_singleton() != NULL)
if (AudioDriverIphone::get_singleton() != NULL)
AudioDriverIphone::get_singleton()->start();
}

View File

@@ -36,7 +36,7 @@ void iOS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_rate_url", "app_id"), &iOS::get_rate_url);
};
void iOS::alert(const char* p_alert, const char* p_title) {
void iOS::alert(const char *p_alert, const char *p_title) {
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:[NSString stringWithUTF8String:p_title] message:[NSString stringWithUTF8String:p_alert] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] autorelease];
[alert show];
}

View File

@@ -257,7 +257,6 @@ AudioDriverOSX::AudioDriverOSX() {
samples_in = NULL;
};
AudioDriverOSX::~AudioDriverOSX() {
};
AudioDriverOSX::~AudioDriverOSX(){};
#endif

View File

@@ -1740,7 +1740,7 @@ OS_OSX::OS_OSX() {
[apple_menu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
menu_item = [apple_menu addItemWithTitle:NSLocalizedString(@"Hide Others", nil) action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
[menu_item setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
[menu_item setKeyEquivalentModifierMask:(NSAlternateKeyMask | NSCommandKeyMask)];
[apple_menu addItemWithTitle:NSLocalizedString(@"Show all", nil) action:@selector(unhideAllApplications:) keyEquivalent:@""];

View File

@@ -35,6 +35,9 @@
#include "GLES2/gl2.h"
#include "os_winrt.h"
/** clang-format does not play nice with this C++/CX hybrid, needs investigation. */
/* clang-format off */
namespace GodotWinRT
{
ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView
@@ -106,3 +109,5 @@ namespace GodotWinRT
};
}
/* clang-format on */

View File

@@ -37,8 +37,7 @@ using namespace Windows::Media::MediaProperties;
using namespace Windows::Media::Editing;
using namespace Windows::Foundation;
const char * AudioDriverWinRT::get_name() const
{
const char *AudioDriverWinRT::get_name() const {
return "WinRT";
}
@@ -50,7 +49,6 @@ Error AudioDriverWinRT::init() {
pcm_open = false;
samples_in = NULL;
mix_rate = 48000;
output_format = OUTPUT_STEREO;
channels = 2;
@@ -58,11 +56,11 @@ Error AudioDriverWinRT::init() {
int latency = GLOBAL_DEF("audio/output_latency", 25);
buffer_size = nearest_power_of_2(latency * mix_rate / 1000);
samples_in = memnew_arr(int32_t, buffer_size*channels);
samples_in = memnew_arr(int32_t, buffer_size * channels);
for (int i = 0; i < AUDIO_BUFFERS; i++) {
samples_out[i] = memnew_arr(int16_t, buffer_size*channels);
samples_out[i] = memnew_arr(int16_t, buffer_size * channels);
xaudio_buffer[i].AudioBytes = buffer_size * channels * sizeof(int16_t);
xaudio_buffer[i].pAudioData = (const BYTE*)(samples_out[i]);
xaudio_buffer[i].pAudioData = (const BYTE *)(samples_out[i]);
xaudio_buffer[i].Flags = 0;
}
@@ -100,15 +98,14 @@ Error AudioDriverWinRT::init() {
return OK;
};
void AudioDriverWinRT::thread_func(void* p_udata) {
void AudioDriverWinRT::thread_func(void *p_udata) {
AudioDriverWinRT* ad = (AudioDriverWinRT*)p_udata;
AudioDriverWinRT *ad = (AudioDriverWinRT *)p_udata;
uint64_t usdelay = (ad->buffer_size / float(ad->mix_rate)) * 1000000;
while (!ad->exit_thread) {
if (!ad->active) {
for (int i = 0; i < AUDIO_BUFFERS; i++) {
@@ -123,30 +120,27 @@ void AudioDriverWinRT::thread_func(void* p_udata) {
ad->unlock();
for (unsigned int i = 0;i < ad->buffer_size*ad->channels;i++) {
for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) {
ad->samples_out[ad->current_buffer][i] = ad->samples_in[i] >> 16;
}
ad->xaudio_buffer[ad->current_buffer].Flags = 0;
ad->xaudio_buffer[ad->current_buffer].AudioBytes = ad->buffer_size * ad->channels * sizeof(int16_t);
ad->xaudio_buffer[ad->current_buffer].pAudioData = (const BYTE*)(ad->samples_out[ad->current_buffer]);
ad->xaudio_buffer[ad->current_buffer].pAudioData = (const BYTE *)(ad->samples_out[ad->current_buffer]);
ad->xaudio_buffer[ad->current_buffer].PlayBegin = 0;
ad->source_voice->SubmitSourceBuffer(&(ad->xaudio_buffer[ad->current_buffer]));
ad->current_buffer = (ad->current_buffer + 1) % AUDIO_BUFFERS;
XAUDIO2_VOICE_STATE state;
while (ad->source_voice->GetState(&state), state.BuffersQueued > AUDIO_BUFFERS - 1)
{
while (ad->source_voice->GetState(&state), state.BuffersQueued > AUDIO_BUFFERS - 1) {
WaitForSingleObject(ad->voice_callback->buffer_end_event, INFINITE);
}
}
};
ad->thread_exited = true;
};
void AudioDriverWinRT::start() {
@@ -236,9 +230,6 @@ AudioDriverWinRT::AudioDriverWinRT() {
current_buffer = 0;
};
AudioDriverWinRT::~AudioDriverWinRT() {
AudioDriverWinRT::~AudioDriverWinRT(){
};

View File

@@ -31,14 +31,14 @@
#include "servers/audio/audio_server_sw.h"
#include "core/os/thread.h"
#include "core/os/mutex.h"
#include "core/os/thread.h"
#include <windows.h>
#include <mmsystem.h>
#include <mmreg.h>
#include <xaudio2.h>
#include <mmsystem.h>
#include <windows.h>
#include <wrl/client.h>
#include <xaudio2.h>
class AudioDriverWinRT : public AudioDriverSW {
@@ -49,26 +49,28 @@ class AudioDriverWinRT : public AudioDriverSW {
struct XAudio2DriverVoiceCallback : public IXAudio2VoiceCallback {
HANDLE buffer_end_event;
XAudio2DriverVoiceCallback() : buffer_end_event(CreateEvent(NULL, FALSE, FALSE, NULL)) {}
void STDMETHODCALLTYPE OnBufferEnd(void* pBufferContext) { /*print_line("buffer ended");*/ SetEvent(buffer_end_event); }
XAudio2DriverVoiceCallback()
: buffer_end_event(CreateEvent(NULL, FALSE, FALSE, NULL)) {}
void STDMETHODCALLTYPE OnBufferEnd(void *pBufferContext) { /*print_line("buffer ended");*/
SetEvent(buffer_end_event);
}
//Unused methods are stubs
void STDMETHODCALLTYPE OnStreamEnd() { }
void STDMETHODCALLTYPE OnVoiceProcessingPassEnd() { }
void STDMETHODCALLTYPE OnVoiceProcessingPassStart(UINT32 SamplesRequired) { }
void STDMETHODCALLTYPE OnBufferStart(void * pBufferContext) { }
void STDMETHODCALLTYPE OnLoopEnd(void * pBufferContext) { }
void STDMETHODCALLTYPE OnVoiceError(void * pBufferContext, HRESULT Error) { }
void STDMETHODCALLTYPE OnStreamEnd() {}
void STDMETHODCALLTYPE OnVoiceProcessingPassEnd() {}
void STDMETHODCALLTYPE OnVoiceProcessingPassStart(UINT32 SamplesRequired) {}
void STDMETHODCALLTYPE OnBufferStart(void *pBufferContext) {}
void STDMETHODCALLTYPE OnLoopEnd(void *pBufferContext) {}
void STDMETHODCALLTYPE OnVoiceError(void *pBufferContext, HRESULT Error) {}
};
Thread* thread;
Mutex* mutex;
Thread *thread;
Mutex *mutex;
int32_t* samples_in;
int16_t* samples_out[AUDIO_BUFFERS];
int32_t *samples_in;
int16_t *samples_out[AUDIO_BUFFERS];
static void thread_func(void* p_udata);
static void thread_func(void *p_udata);
int buffer_size;
unsigned int mix_rate;
@@ -84,14 +86,13 @@ class AudioDriverWinRT : public AudioDriverSW {
WAVEFORMATEX wave_format;
Microsoft::WRL::ComPtr<IXAudio2> xaudio;
int current_buffer;
IXAudio2MasteringVoice* mastering_voice;
IXAudio2MasteringVoice *mastering_voice;
XAUDIO2_BUFFER xaudio_buffer[AUDIO_BUFFERS];
IXAudio2SourceVoice* source_voice;
XAudio2DriverVoiceCallback* voice_callback;
IXAudio2SourceVoice *source_voice;
XAudio2DriverVoiceCallback *voice_callback;
public:
const char* get_name() const;
const char *get_name() const;
virtual Error init();
virtual void start();

View File

@@ -101,8 +101,7 @@ Error ContextEGL::initialize() {
try {
const EGLint displayAttributes[] =
{
const EGLint displayAttributes[] = {
/*EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9,
EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3,

View File

@@ -53,7 +53,7 @@ uint32_t JoystickWinrt::process_controllers(uint32_t p_last_id) {
case ControllerType::GAMEPAD_CONTROLLER: {
GamepadReading reading = ((Gamepad ^) joy.controller_reference)->GetCurrentReading();
GamepadReading reading = ((Gamepad ^)joy.controller_reference)->GetCurrentReading();
int button_mask = (int)GamepadButtons::Menu;
for (int j = 0; j < 14; j++) {
@@ -162,7 +162,7 @@ void JoystickWinrt::joypad_vibration_start(int p_device, float p_weak_magnitude,
GamepadVibration vibration;
vibration.LeftMotor = p_strong_magnitude;
vibration.RightMotor = p_weak_magnitude;
((Gamepad ^) joy.controller_reference)->Vibration = vibration;
((Gamepad ^)joy.controller_reference)->Vibration = vibration;
joy.ff_timestamp = p_timestamp;
joy.ff_end_timestamp = p_duration == 0 ? 0 : p_timestamp + (uint64_t)(p_duration * 1000000.0);
@@ -176,7 +176,7 @@ void JoystickWinrt::joypad_vibration_stop(int p_device, uint64_t p_timestamp) {
GamepadVibration vibration;
vibration.LeftMotor = 0.0;
vibration.RightMotor = 0.0;
((Gamepad ^) joy.controller_reference)->Vibration = vibration;
((Gamepad ^)joy.controller_reference)->Vibration = vibration;
joy.ff_timestamp = p_timestamp;
joy.vibrating = false;

View File

@@ -33,10 +33,12 @@
ref class JoystickWinrt sealed {
/** clang-format breaks this, it does not understand this token. */
/* clang-format off */
internal:
void register_events();
uint32_t process_controllers(uint32_t p_last_id);
/* clang-format on */
JoystickWinrt();
JoystickWinrt(InputDefault *p_input);

View File

@@ -520,12 +520,10 @@ void ItemList::_input_event(const InputEvent &p_event) {
if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == BUTTON_WHEEL_UP && p_event.mouse_button.pressed) {
scroll_bar->set_val(scroll_bar->get_val() - scroll_bar->get_page() * p_event.mouse_button.factor / 8);
}
if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == BUTTON_WHEEL_DOWN && p_event.mouse_button.pressed) {
scroll_bar->set_val(scroll_bar->get_val() + scroll_bar->get_page() * p_event.mouse_button.factor / 8);
}
if (p_event.is_pressed() && items.size() > 0) {