Merge pull request #19645 from hrydgard/more-buffer-opt
Some checks are pending
Build / build-windows (ARM64) (push) Waiting to run
Build / build-windows (x64) (push) Waiting to run
Build / build-uwp (push) Waiting to run
Build / test-windows (push) Blocked by required conditions
Build / build (./b.sh --headless --unittest --fat --no-png --no-sdl2, clang, clang++, test, macos, macos-latest) (push) Waiting to run
Build / build (./b.sh --headless --unittest, clang, clang++, test, clang-normal, ubuntu-latest) (push) Waiting to run
Build / build (./b.sh --headless --unittest, gcc, g++, gcc-normal, ubuntu-latest) (push) Waiting to run
Build / build (./b.sh --ios, clang, clang++, ios, ios, macos-latest) (push) Waiting to run
Build / build (./b.sh --libretro_android ppsspp_libretro, clang, clang++, android, android-libretro, ubuntu-latest) (push) Waiting to run
Build / build (./b.sh --qt, gcc, g++, qt, qt, ubuntu-latest) (push) Waiting to run
Build / build (cd android && ./ab.sh -j2 APP_ABI=arm64-v8a OPENXR=1, clang, clang++, android, android-vr, ubuntu-latest) (push) Waiting to run
Build / build (cd android && ./ab.sh -j2 APP_ABI=arm64-v8a UNITTEST=1 HEADLESS=1, clang, clang++, android, android-arm64, ubuntu-latest) (push) Waiting to run
Build / build (cd android && ./ab.sh -j2 APP_ABI=armeabi-v7a UNITTEST=1 HEADLESS=1, clang, clang++, android, android-arm32, ubuntu-latest) (push) Waiting to run
Build / build (cd android && ./ab.sh -j2 APP_ABI=x86_64 UNITTEST=1 HEADLESS=1, clang, clang++, android, android-x86_64, ubuntu-latest) (push) Waiting to run
Build / build (make -C libretro -f Makefile -j2, clang, clang++, libretro, clang-libretro, ubuntu-latest) (push) Waiting to run
Build / build (make -C libretro -f Makefile -j2, gcc, g++, libretro, gcc-libretro, ubuntu-latest) (push) Waiting to run
Build / test (macos-latest) (push) Blocked by required conditions
Build / test (ubuntu-latest) (push) Blocked by required conditions
Build / build_test_headless_alpine (push) Waiting to run
Generate Docker Layer / build (push) Waiting to run

Optimize Buffer slightly more, fix using touchscreen controls using the mouse
This commit is contained in:
Henrik Rydgård 2024-11-22 11:06:34 +01:00 committed by GitHub
commit 21ffc37ebd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 48 additions and 15 deletions

View File

@ -95,12 +95,12 @@ int Buffer::SkipLineCRLF() {
// This relies on having buffered data! // This relies on having buffered data!
int Buffer::OffsetToAfterNextCRLF() { int Buffer::OffsetToAfterNextCRLF() {
for (int i = 0; i < (int)data_.size() - 1; i++) { int offset = data_.next_crlf_offset();
if (data_.peek(i) == '\r' && data_.peek(i + 1) == '\n') { if (offset >= 0) {
return i + 2; return offset + 2;
} } else {
return -1;
} }
return -1;
} }
void Buffer::Printf(const char *fmt, ...) { void Buffer::Printf(const char *fmt, ...) {

View File

@ -186,6 +186,27 @@ public:
head_ = b; head_ = b;
} }
// If return value is negative, one wasn't found.
int next_crlf_offset() {
int offset = 0;
Block *b = head_;
do {
int remain = b->tail - b->head;
for (int i = 0; i < remain; i++) {
if (b->data[b->head + i] == '\r') {
// Use peek to avoid handling edge cases.
if (peek(offset + i + 1) == '\n') {
return offset + i;
}
}
}
offset += remain;
b = b->next;
} while (b);
// Ran out of data.
return -1;
}
private: private:
struct Block { struct Block {
~Block() { ~Block() {

View File

@ -15,6 +15,10 @@
#define MSG_NOSIGNAL 0x00 #define MSG_NOSIGNAL 0x00
#endif #endif
#if _MSC_VER
#pragma warning(disable:4267)
#endif
#include "Common/File/FileDescriptor.h" #include "Common/File/FileDescriptor.h"
#include "Common/Log.h" #include "Common/Log.h"
#include "Common/Net/NetBuffer.h" #include "Common/Net/NetBuffer.h"
@ -118,7 +122,7 @@ bool Buffer::ReadAllWithProgress(int fd, int knownSize, RequestProgress *progres
} }
int Buffer::Read(int fd, size_t sz) { int Buffer::Read(int fd, size_t sz) {
char buf[1024]; char buf[4096];
int retval; int retval;
size_t received = 0; size_t received = 0;
while ((retval = recv(fd, buf, std::min(sz, sizeof(buf)), MSG_NOSIGNAL)) > 0) { while ((retval = recv(fd, buf, std::min(sz, sizeof(buf)), MSG_NOSIGNAL)) > 0) {

View File

@ -107,10 +107,12 @@ bool MultiTouchButton::Touch(const TouchInput &input) {
usedPointerMask |= 1 << input.id; usedPointerMask |= 1 << input.id;
} }
if (input.flags & TOUCH_MOVE) { if (input.flags & TOUCH_MOVE) {
if (bounds_.Contains(input.x, input.y) && !(analogPointerMask & (1 << input.id))) if (!(input.flags & TOUCH_MOUSE) || input.buttons) {
pointerDownMask_ |= 1 << input.id; if (bounds_.Contains(input.x, input.y) && !(analogPointerMask & (1 << input.id)))
else pointerDownMask_ |= 1 << input.id;
pointerDownMask_ &= ~(1 << input.id); else
pointerDownMask_ &= ~(1 << input.id);
}
} }
if (input.flags & TOUCH_UP) { if (input.flags & TOUCH_UP) {
pointerDownMask_ &= ~(1 << input.id); pointerDownMask_ &= ~(1 << input.id);
@ -291,11 +293,13 @@ bool PSPDpad::Touch(const TouchInput &input) {
} }
} }
if (input.flags & TOUCH_MOVE) { if (input.flags & TOUCH_MOVE) {
if (dragPointerId_ == -1 && bounds_.Contains(input.x, input.y) && !(analogPointerMask & (1 << input.id))) { if (!(input.flags & TOUCH_MOUSE) || input.buttons) {
dragPointerId_ = input.id; if (dragPointerId_ == -1 && bounds_.Contains(input.x, input.y) && !(analogPointerMask & (1 << input.id))) {
} dragPointerId_ = input.id;
if (input.id == dragPointerId_) { }
ProcessTouch(input.x, input.y, true); if (input.id == dragPointerId_) {
ProcessTouch(input.x, input.y, true);
}
} }
} }
if (input.flags & TOUCH_UP) { if (input.flags & TOUCH_UP) {

View File

@ -1076,6 +1076,10 @@ bool TestCharQueue() {
queue.pop_front_bulk(dest, 4); queue.pop_front_bulk(dest, 4);
EXPECT_EQ_MEM(dest, "opqr", 4); EXPECT_EQ_MEM(dest, "opqr", 4);
EXPECT_TRUE(queue.empty()); EXPECT_TRUE(queue.empty());
queue.push_back("asdf");
EXPECT_EQ_INT(queue.next_crlf_offset(), -1);
queue.push_back("\r\r\n");
EXPECT_EQ_INT(queue.next_crlf_offset(), 5);
return true; return true;
} }