Add ICC profile to DesktopFrame
And fill-in icc profile from the various window and screen capturers. Done on WindowCapturerMac, ScreenCapturerMac, WindowCapturerX11 and ScreenCapturerX11. Follow-up CLs will do it on ScreenCapturerWinDirectx and ScreenCapturerPipeWire. Useful to build the gfx::ColorSpace in chromium, especially from src/content/browser/media/capture/desktop_capture_device.cc. We do not build the color space directly here to avoid duplicating ui/gfx/icc_profile.h,cc code from chromium, which one implements icc profile caching. Bug: chromium:945468 Change-Id: Id6e3920233771e035f7578847406bf1f519dcd49 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133580 Commit-Queue: Julien Isorce <julien.isorce@chromium.org> Reviewed-by: Sergey Ulanov <sergeyu@chromium.org> Reviewed-by: Brave Yao <braveyao@webrtc.org> Reviewed-by: Jamie Walch <jamiewalch@chromium.org> Cr-Commit-Position: refs/heads/master@{#27697}
This commit is contained in:
committed by
Commit Bot
parent
5665572f47
commit
62acb5a8c0
@ -19,6 +19,7 @@
|
||||
#include "modules/desktop_capture/desktop_frame.h"
|
||||
#include "modules/desktop_capture/linux/window_list_utils.h"
|
||||
#include "modules/desktop_capture/linux/x_error_trap.h"
|
||||
#include "modules/desktop_capture/linux/x_window_property.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
|
||||
@ -172,15 +173,28 @@ void XServerPixelBuffer::ReleaseSharedMemorySegment() {
|
||||
shm_segment_info_ = nullptr;
|
||||
}
|
||||
|
||||
bool XServerPixelBuffer::Init(Display* display, Window window) {
|
||||
bool XServerPixelBuffer::Init(XAtomCache* cache, Window window) {
|
||||
Release();
|
||||
display_ = display;
|
||||
display_ = cache->display();
|
||||
|
||||
XWindowAttributes attributes;
|
||||
if (!GetWindowRect(display_, window, &window_rect_, &attributes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cache->IccProfile() != None) {
|
||||
// |window| is the root window when doing screen capture.
|
||||
XWindowProperty<uint8_t> icc_profile_property(cache->display(), window,
|
||||
cache->IccProfile());
|
||||
if (icc_profile_property.is_valid() && icc_profile_property.size() > 0) {
|
||||
icc_profile_ = std::vector<uint8_t>(
|
||||
icc_profile_property.data(),
|
||||
icc_profile_property.data() + icc_profile_property.size());
|
||||
} else {
|
||||
RTC_LOG(LS_WARNING) << "Failed to get icc profile";
|
||||
}
|
||||
}
|
||||
|
||||
window_ = window;
|
||||
InitShm(attributes);
|
||||
|
||||
@ -348,6 +362,9 @@ bool XServerPixelBuffer::CaptureRect(const DesktopRect& rect,
|
||||
SlowBlit(image, data, rect, frame);
|
||||
}
|
||||
|
||||
if (!icc_profile_.empty())
|
||||
frame->set_icc_profile(icc_profile_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user