Commit f5b9b624 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

Remove strict check from ColorTypeForVisual()

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/+/2047767Reviewed-by: default avatarMaksim Sisov <msisov@igalia.com>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740341}
parent b8bd5990
......@@ -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];
......@@ -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)) {
......
......@@ -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);
}
}
......@@ -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);
}
......
......@@ -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"
......@@ -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;
}
......
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