Commit ff88cb88 authored by Katie Dektar's avatar Katie Dektar Committed by Chromium LUCI CQ

Revert "[X11] Split PutImage requests into multiple requests if necessary"

This reverts commit 3fe154df.

Reason for revert: Appears to have caused compile failure: https://ci.chromium.org/p/chromium/builders/ci/Linux%20Builder%20(dbg)(32)/166101?

[1052/1665] CXX obj/ui/base/x/x/selection_owner.o
FAILED: obj/ui/base/x/x/selection_owner.o
/b/s/w/ir/cache/goma/client/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF...(too long)
../../ui/base/x/selection_owner.cc:46:10: error: no matching function for call to 'min'
return std::min(size - 100, 0x100000l);
^~~~~~~~
../../buildtools/third_party/libc++/trunk/include/algorithm:2532:1: note: candidate template ignored: deduced conflicting types for parameter '_Tp' ('int' vs. 'long')
min(const _Tp& __a, const _Tp& __b)
^

Original change's description:
> [X11] Split PutImage requests into multiple requests if necessary
>
> R=​sky
>
> Change-Id: I1befaef494c74797333d6bf02e204bcdc721e752
> Bug: 1164669
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2643711
> Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
> Commit-Queue: Scott Violet <sky@chromium.org>
> Reviewed-by: Scott Violet <sky@chromium.org>
> Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#846344}

TBR=sky@chromium.org,thomasanderson@chromium.org,chromium-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I3989bb05bc58bfadf33f7b67bae0ac2c4a5402e7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1164669
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2644744Reviewed-by: default avatarKatie Dektar <katie@chromium.org>
Commit-Queue: Katie Dektar <katie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846351}
parent 530f0508
...@@ -39,11 +39,16 @@ const int kIncrementalTransferTimeoutMs = 10000; ...@@ -39,11 +39,16 @@ const int kIncrementalTransferTimeoutMs = 10000;
static_assert(KSelectionOwnerTimerPeriodMs <= kIncrementalTransferTimeoutMs, static_assert(KSelectionOwnerTimerPeriodMs <= kIncrementalTransferTimeoutMs,
"timer period must be <= transfer timeout"); "timer period must be <= transfer timeout");
size_t GetMaxIncrementalTransferSize() { // Returns a conservative max size of the data we can pass into
ssize_t size = x11::Connection::Get()->MaxRequestSizeInBytes(); // XChangeProperty(). Copied from GTK.
// Conservatively subtract 100 bytes for the GetProperty request, padding etc. size_t GetMaxRequestSize(x11::Connection* connection) {
DCHECK_GT(size, 100); long extended_max_size = connection->extended_max_request_length();
return std::min(size - 100, 0x100000l); long max_size =
(extended_max_size ? extended_max_size
: connection->setup().maximum_request_length) -
100;
return std::min(static_cast<long>(0x40000),
std::max(static_cast<long>(0), max_size));
} }
// Gets the value of an atom pair array property. On success, true is returned // Gets the value of an atom pair array property. On success, true is returned
...@@ -80,7 +85,9 @@ void SetSelectionOwner(x11::Window window, ...@@ -80,7 +85,9 @@ void SetSelectionOwner(x11::Window window,
SelectionOwner::SelectionOwner(x11::Connection* connection, SelectionOwner::SelectionOwner(x11::Connection* connection,
x11::Window x_window, x11::Window x_window,
x11::Atom selection_name) x11::Atom selection_name)
: x_window_(x_window), selection_name_(selection_name) {} : x_window_(x_window),
selection_name_(selection_name),
max_request_size_(GetMaxRequestSize(connection)) {}
SelectionOwner::~SelectionOwner() { SelectionOwner::~SelectionOwner() {
// If we are the selection owner, we need to release the selection so we // If we are the selection owner, we need to release the selection so we
...@@ -210,7 +217,7 @@ bool SelectionOwner::ProcessTarget(x11::Atom target, ...@@ -210,7 +217,7 @@ bool SelectionOwner::ProcessTarget(x11::Atom target,
// Try to find the data type in map. // Try to find the data type in map.
auto it = format_map_.find(target); auto it = format_map_.find(target);
if (it != format_map_.end()) { if (it != format_map_.end()) {
if (it->second->size() > GetMaxIncrementalTransferSize()) { if (it->second->size() > max_request_size_) {
// We must send the data back in several chunks due to a limitation in // We must send the data back in several chunks due to a limitation in
// the size of X requests. Notify the selection requestor that the data // the size of X requests. Notify the selection requestor that the data
// will be sent incrementally by returning data of type "INCR". // will be sent incrementally by returning data of type "INCR".
...@@ -253,7 +260,7 @@ bool SelectionOwner::ProcessTarget(x11::Atom target, ...@@ -253,7 +260,7 @@ bool SelectionOwner::ProcessTarget(x11::Atom target,
void SelectionOwner::ProcessIncrementalTransfer(IncrementalTransfer* transfer) { void SelectionOwner::ProcessIncrementalTransfer(IncrementalTransfer* transfer) {
size_t remaining = transfer->data->size() - transfer->offset; size_t remaining = transfer->data->size() - transfer->offset;
size_t chunk_length = std::min(remaining, GetMaxIncrementalTransferSize()); size_t chunk_length = std::min(remaining, max_request_size_);
const uint8_t* data = transfer->data->front() + transfer->offset; const uint8_t* data = transfer->data->front() + transfer->offset;
std::vector<uint8_t> buf(data, data + chunk_length); std::vector<uint8_t> buf(data, data + chunk_length);
SetArrayProperty(transfer->window, transfer->property, transfer->target, buf); SetArrayProperty(transfer->window, transfer->property, transfer->target, buf);
......
...@@ -136,6 +136,9 @@ class COMPONENT_EXPORT(UI_BASE_X) SelectionOwner { ...@@ -136,6 +136,9 @@ class COMPONENT_EXPORT(UI_BASE_X) SelectionOwner {
// The time that this instance took ownership of its selection. // The time that this instance took ownership of its selection.
x11::Time acquired_selection_timestamp_; x11::Time acquired_selection_timestamp_;
// The maximum size of data we can put in XChangeProperty().
size_t max_request_size_;
// The data we are currently serving. // The data we are currently serving.
SelectionFormatMap format_map_; SelectionFormatMap format_map_;
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "base/location.h" #include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ref_counted_memory.h" #include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/no_destructor.h" #include "base/no_destructor.h"
...@@ -249,10 +248,6 @@ void DrawPixmap(x11::Connection* connection, ...@@ -249,10 +248,6 @@ void DrawPixmap(x11::Connection* connection,
int dst_y, int dst_y,
int width, int width,
int height) { int height) {
// 24 bytes for the PutImage header, an additional 4 bytes in case this is an
// extended size request, and an additional 4 bytes in case padding is needed.
constexpr size_t kPutImageExtraSize = 32;
const auto* visual_info = connection->GetVisualInfoFromId(visual); const auto* visual_info = connection->GetVisualInfoFromId(visual);
if (!visual_info) if (!visual_info)
return; return;
...@@ -276,30 +271,19 @@ void DrawPixmap(x11::Connection* connection, ...@@ -276,30 +271,19 @@ void DrawPixmap(x11::Connection* connection,
std::vector<uint8_t> vec(row_bytes * height); std::vector<uint8_t> vec(row_bytes * height);
SkPixmap pixmap(image_info, vec.data(), row_bytes); SkPixmap pixmap(image_info, vec.data(), row_bytes);
skia_pixmap.readPixels(pixmap, src_x, src_y); skia_pixmap.readPixels(pixmap, src_x, src_y);
x11::PutImageRequest put_image_request{
DCHECK_GT(connection->MaxRequestSizeInBytes(), kPutImageExtraSize); .format = x11::ImageFormat::ZPixmap,
int rows_per_request = .drawable = drawable,
(connection->MaxRequestSizeInBytes() - kPutImageExtraSize) / row_bytes; .gc = gc,
DCHECK_GT(rows_per_request, 1); .width = width,
for (int row = 0; row < height; row += rows_per_request) { .height = height,
size_t n_rows = std::min<size_t>(rows_per_request, height - row); .dst_x = dst_x,
auto data = base::MakeRefCounted<base::RefCountedStaticMemory>( .dst_y = dst_y,
vec.data() + row * row_bytes, n_rows * row_bytes); .left_pad = 0,
connection->PutImage({ .depth = visual_info->format->depth,
.format = x11::ImageFormat::ZPixmap, .data = base::RefCountedBytes::TakeVector(&vec),
.drawable = drawable, };
.gc = gc, connection->PutImage(put_image_request);
.width = width,
.height = n_rows,
.dst_x = dst_x,
.dst_y = dst_y + row,
.left_pad = 0,
.depth = visual_info->format->depth,
.data = data,
});
}
// Flush since the PutImage requests depend on |vec| being alive.
connection->Flush();
} }
bool IsXInput2Available() { bool IsXInput2Available() {
......
...@@ -184,11 +184,6 @@ Connection::~Connection() { ...@@ -184,11 +184,6 @@ Connection::~Connection() {
xcb_disconnect(connection_); xcb_disconnect(connection_);
} }
size_t Connection::MaxRequestSizeInBytes() const {
return 4 * std::max<size_t>(extended_max_request_length_,
setup_.maximum_request_length);
}
XlibDisplayWrapper Connection::GetXlibDisplay(XlibDisplayType type) { XlibDisplayWrapper Connection::GetXlibDisplay(XlibDisplayType type) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!xlib_display_) if (!xlib_display_)
......
...@@ -90,7 +90,10 @@ class COMPONENT_EXPORT(X11) Connection : public XProto, ...@@ -90,7 +90,10 @@ class COMPONENT_EXPORT(X11) Connection : public XProto,
XlibDisplayWrapper GetXlibDisplay( XlibDisplayWrapper GetXlibDisplay(
XlibDisplayType type = XlibDisplayType::kNormal); XlibDisplayType type = XlibDisplayType::kNormal);
size_t MaxRequestSizeInBytes() const; uint32_t extended_max_request_length() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return extended_max_request_length_;
}
const Setup& setup() const { const Setup& setup() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment