Skip to content

Commit

Permalink
Remove strict check from ColorTypeForVisual()
Browse files Browse the repository at this point in the history
When running xvfb, the R,G,B color masks will all be 0. To prevent
breaking this configuration, remove the strict check from
ColorTypeForVisual() and silently continue without graphics.

R=msisov

Change-Id: Iab55663c0f9541060ca231c679ab75f2c85eba30
Bug: 1025266, 1049066
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2047767
Reviewed-by: Maksim Sisov <msisov@igalia.com>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740341}
  • Loading branch information
tanderson-google authored and Commit Bot committed Feb 11, 2020
1 parent b8bd599 commit f5b9b62
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
8 changes: 6 additions & 2 deletions ui/base/x/x11_shm_image_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ bool XShmImagePool::Resize(const gfx::Size& pixel_size) {
return false;
}

SkColorType color_type = ColorTypeForVisual(visual_);
if (color_type == kUnknown_SkColorType)
return false;

std::size_t needed_frame_bytes;
for (std::size_t i = 0; i < frame_states_.size(); ++i) {
FrameState& state = frame_states_[i];
Expand Down Expand Up @@ -199,8 +203,8 @@ bool XShmImagePool::Resize(const gfx::Size& pixel_size) {
for (FrameState& state : frame_states_) {
state.image->data = state.shminfo_.shmaddr;
SkImageInfo image_info =
SkImageInfo::Make(state.image->width, state.image->height,
ColorTypeForVisual(visual_), kPremul_SkAlphaType);
SkImageInfo::Make(state.image->width, state.image->height, color_type,
kPremul_SkAlphaType);
state.bitmap = SkBitmap();
if (!state.bitmap.installPixels(image_info, state.image->data,
state.image->bytes_per_line)) {
Expand Down
11 changes: 7 additions & 4 deletions ui/base/x/x11_software_bitmap_presenter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,12 @@ void X11SoftwareBitmapPresenter::Resize(const gfx::Size& pixel_size) {
needs_swap_ = false;
surface_ = nullptr;
} else {
SkImageInfo info = SkImageInfo::Make(
viewport_pixel_size_.width(), viewport_pixel_size_.height(),
ColorTypeForVisual(attributes_.visual), kOpaque_SkAlphaType);
SkColorType color_type = ColorTypeForVisual(attributes_.visual);
if (color_type == kUnknown_SkColorType)
return;
SkImageInfo info = SkImageInfo::Make(viewport_pixel_size_.width(),
viewport_pixel_size_.height(),
color_type, kOpaque_SkAlphaType);
surface_ = SkSurface::MakeRaster(info);
}
}
Expand Down Expand Up @@ -224,7 +227,7 @@ void X11SoftwareBitmapPresenter::EndPaint(const gfx::Rect& damage_rect) {
return;
}
skia_pixmap = shm_pool_->CurrentBitmap().pixmap();
} else {
} else if (surface_) {
surface_->peekPixels(&skia_pixmap);
}

Expand Down
14 changes: 4 additions & 10 deletions ui/base/x/x11_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "base/bind.h"
#include "base/command_line.h"
#include "base/debug/crash_logging.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
Expand Down Expand Up @@ -1323,15 +1322,10 @@ SkColorType ColorTypeForVisual(void* visual) {
return color_info.color_type;
}
}
char visual_masks[static_cast<size_t>(base::debug::CrashKeySize::Size64)];
snprintf(visual_masks, sizeof(visual_masks), "0x%08lx, 0x%08lx, 0x%08lx",
vis->red_mask, vis->green_mask, vis->blue_mask);
static auto* crash_key_string = base::debug::AllocateCrashKeyString(
"visual_masks", base::debug::CrashKeySize::Size64);
base::debug::ScopedCrashKeyString scoped_crash_key(crash_key_string,
visual_masks);
LOG(FATAL) << "Unsupported visual with rgb masks " << visual_masks
<< ". Please report this to https://crbug.com/1048386";
LOG(ERROR) << "Unsupported visual with rgb mask 0x" << std::hex
<< vis->red_mask << ", 0x" << vis->green_mask << ", 0x"
<< vis->blue_mask
<< ". Please report this to https://crbug.com/1025266";
return kUnknown_SkColorType;
}

Expand Down

0 comments on commit f5b9b62

Please sign in to comment.