Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 1796293003: Image decode color: Push color profile from browser to renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 #include "content/public/common/result_codes.h" 68 #include "content/public/common/result_codes.h"
69 #include "content/public/common/web_preferences.h" 69 #include "content/public/common/web_preferences.h"
70 #include "gpu/GLES2/gl2extchromium.h" 70 #include "gpu/GLES2/gl2extchromium.h"
71 #include "gpu/command_buffer/service/gpu_switches.h" 71 #include "gpu/command_buffer/service/gpu_switches.h"
72 #include "gpu/ipc/common/gpu_messages.h" 72 #include "gpu/ipc/common/gpu_messages.h"
73 #include "skia/ext/image_operations.h" 73 #include "skia/ext/image_operations.h"
74 #include "skia/ext/platform_canvas.h" 74 #include "skia/ext/platform_canvas.h"
75 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 75 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
76 #include "ui/events/event.h" 76 #include "ui/events/event.h"
77 #include "ui/events/keycodes/keyboard_codes.h" 77 #include "ui/events/keycodes/keyboard_codes.h"
78 #include "ui/gfx/color_profile.h"
78 #include "ui/gfx/geometry/size_conversions.h" 79 #include "ui/gfx/geometry/size_conversions.h"
79 #include "ui/gfx/geometry/vector2d_conversions.h" 80 #include "ui/gfx/geometry/vector2d_conversions.h"
80 #include "ui/gfx/skbitmap_operations.h" 81 #include "ui/gfx/skbitmap_operations.h"
81 #include "ui/snapshot/snapshot.h" 82 #include "ui/snapshot/snapshot.h"
82 83
83 #if defined(OS_MACOSX) 84 #if defined(OS_MACOSX)
84 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" 85 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
85 #endif 86 #endif
86 87
87 using base::Time; 88 using base::Time;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 received_paint_after_load_(false), 206 received_paint_after_load_(false),
206 next_browser_snapshot_id_(1), 207 next_browser_snapshot_id_(1),
207 owned_by_render_frame_host_(false), 208 owned_by_render_frame_host_(false),
208 is_focused_(false), 209 is_focused_(false),
209 scale_input_to_viewport_(IsUseZoomForDSFEnabled()), 210 scale_input_to_viewport_(IsUseZoomForDSFEnabled()),
210 hung_renderer_delay_( 211 hung_renderer_delay_(
211 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), 212 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)),
212 new_content_rendering_delay_( 213 new_content_rendering_delay_(
213 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), 214 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)),
214 weak_factory_(this) { 215 weak_factory_(this) {
216 #if defined(OS_WIN)
217 // Update the display color profile cache so that it is likely to be up to
218 // date when the renderer process requests the color profile.
219 BrowserThread::PostBlockingPoolTask(
220 FROM_HERE, base::Bind(&gfx::UpdateDisplayColorProfileCache));
221 #endif
222
215 CHECK(delegate_); 223 CHECK(delegate_);
216 CHECK_NE(MSG_ROUTING_NONE, routing_id_); 224 CHECK_NE(MSG_ROUTING_NONE, routing_id_);
217 225
218 std::pair<RoutingIDWidgetMap::iterator, bool> result = 226 std::pair<RoutingIDWidgetMap::iterator, bool> result =
219 g_routing_id_widget_map.Get().insert(std::make_pair( 227 g_routing_id_widget_map.Get().insert(std::make_pair(
220 RenderWidgetHostID(process->GetID(), routing_id_), this)); 228 RenderWidgetHostID(process->GetID(), routing_id_), this));
221 CHECK(result.second) << "Inserting a duplicate item!"; 229 CHECK(result.second) << "Inserting a duplicate item!";
222 process_->AddRoute(routing_id_, this); 230 process_->AddRoute(routing_id_, this);
223 231
224 // If we're initially visible, tell the process host that we're alive. 232 // If we're initially visible, tell the process host that we're alive.
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 624
617 old_resize_params_ = base::WrapUnique(new ResizeParams(resize_params)); 625 old_resize_params_ = base::WrapUnique(new ResizeParams(resize_params));
618 } 626 }
619 627
620 void RenderWidgetHostImpl::WasResized() { 628 void RenderWidgetHostImpl::WasResized() {
621 // Skip if the |delegate_| has already been detached because 629 // Skip if the |delegate_| has already been detached because
622 // it's web contents is being deleted. 630 // it's web contents is being deleted.
623 if (resize_ack_pending_ || !process_->HasConnection() || !view_ || 631 if (resize_ack_pending_ || !process_->HasConnection() || !view_ ||
624 !renderer_initialized_ || auto_resize_enabled_ || !delegate_) { 632 !renderer_initialized_ || auto_resize_enabled_ || !delegate_) {
625 if (resize_ack_pending_ && color_profile_out_of_date_) 633 if (resize_ack_pending_ && color_profile_out_of_date_)
626 DispatchColorProfile(); 634 SendColorProfile();
627 return; 635 return;
628 } 636 }
629 637
630 std::unique_ptr<ResizeParams> params(new ResizeParams); 638 std::unique_ptr<ResizeParams> params(new ResizeParams);
631 if (color_profile_out_of_date_) 639 if (color_profile_out_of_date_)
632 DispatchColorProfile(); 640 SendColorProfile();
633 if (!GetResizeParams(params.get())) 641 if (!GetResizeParams(params.get()))
634 return; 642 return;
635 643
636 bool width_changed = 644 bool width_changed =
637 !old_resize_params_ || 645 !old_resize_params_ ||
638 old_resize_params_->new_size.width() != params->new_size.width(); 646 old_resize_params_->new_size.width() != params->new_size.width();
639 if (Send(new ViewMsg_Resize(routing_id_, *params))) { 647 if (Send(new ViewMsg_Resize(routing_id_, *params))) {
640 resize_ack_pending_ = params->needs_resize_ack; 648 resize_ack_pending_ = params->needs_resize_ack;
641 old_resize_params_.swap(params); 649 old_resize_params_.swap(params);
642 } 650 }
643 651
644 if (delegate_) 652 if (delegate_)
645 delegate_->RenderWidgetWasResized(this, width_changed); 653 delegate_->RenderWidgetWasResized(this, width_changed);
646 } 654 }
647 655
648 void RenderWidgetHostImpl::DispatchColorProfile() { 656 void RenderWidgetHostImpl::SendColorProfile() {
649 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
650 static bool image_profiles = base::CommandLine::ForCurrentProcess()-> 657 static bool image_profiles = base::CommandLine::ForCurrentProcess()->
651 HasSwitch(switches::kEnableImageColorProfiles); 658 HasSwitch(switches::kEnableImageColorProfiles);
652 if (!image_profiles) 659 if (!image_profiles)
653 return; 660 return;
654 #if defined(OS_WIN)
655 // Windows will read disk to get the color profile data if needed, so
656 // dispatch the SendColorProfile() work off the UI thread.
657 BrowserThread::PostBlockingPoolTask(
658 FROM_HERE,
659 base::Bind(&RenderWidgetHostImpl::SendColorProfile,
660 weak_factory_.GetWeakPtr()));
661 #elif !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
662 // Only support desktop Mac and Linux at this time.
663 SendColorProfile();
664 #endif
665 #endif
666 }
667
668 void RenderWidgetHostImpl::SendColorProfile() {
669 if (!view_ || !delegate_) 661 if (!view_ || !delegate_)
670 return; 662 return;
671 DCHECK(!view_->GetRequestedRendererSize().IsEmpty()); 663 DCHECK(!view_->GetRequestedRendererSize().IsEmpty());
672 #if defined(OS_WIN)
673 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
674 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
675 #endif
676 std::vector<char> color_profile; 664 std::vector<char> color_profile;
677 if (!GetScreenColorProfile(&color_profile)) 665 if (!GetScreenColorProfile(&color_profile))
678 return; 666 return;
679 if (!renderer_initialized_ || !process_->HasConnection()) 667 if (!renderer_initialized_ || !process_->HasConnection())
680 return; 668 return;
681 if (!Send(new ViewMsg_ColorProfile(routing_id_, color_profile))) 669 if (!Send(new ViewMsg_ColorProfile(routing_id_, color_profile)))
682 return; 670 return;
683 color_profile_out_of_date_ = false; 671 color_profile_out_of_date_ = false;
684 } 672 }
685 673
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after
2150 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; 2138 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL;
2151 } 2139 }
2152 2140
2153 BrowserAccessibilityManager* 2141 BrowserAccessibilityManager*
2154 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { 2142 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() {
2155 return delegate_ ? 2143 return delegate_ ?
2156 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; 2144 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL;
2157 } 2145 }
2158 2146
2159 } // namespace content 2147 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698