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

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: Fix windows tests Created 4 years, 9 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 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "content/public/common/content_switches.h" 65 #include "content/public/common/content_switches.h"
66 #include "content/public/common/result_codes.h" 66 #include "content/public/common/result_codes.h"
67 #include "content/public/common/web_preferences.h" 67 #include "content/public/common/web_preferences.h"
68 #include "gpu/GLES2/gl2extchromium.h" 68 #include "gpu/GLES2/gl2extchromium.h"
69 #include "gpu/command_buffer/service/gpu_switches.h" 69 #include "gpu/command_buffer/service/gpu_switches.h"
70 #include "skia/ext/image_operations.h" 70 #include "skia/ext/image_operations.h"
71 #include "skia/ext/platform_canvas.h" 71 #include "skia/ext/platform_canvas.h"
72 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 72 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
73 #include "ui/events/event.h" 73 #include "ui/events/event.h"
74 #include "ui/events/keycodes/keyboard_codes.h" 74 #include "ui/events/keycodes/keyboard_codes.h"
75 #include "ui/gfx/color_profile.h"
75 #include "ui/gfx/geometry/size_conversions.h" 76 #include "ui/gfx/geometry/size_conversions.h"
76 #include "ui/gfx/geometry/vector2d_conversions.h" 77 #include "ui/gfx/geometry/vector2d_conversions.h"
77 #include "ui/gfx/skbitmap_operations.h" 78 #include "ui/gfx/skbitmap_operations.h"
78 #include "ui/snapshot/snapshot.h" 79 #include "ui/snapshot/snapshot.h"
79 80
80 #if defined(OS_WIN) 81 #if defined(OS_WIN)
81 #include "content/common/plugin_constants_win.h" 82 #include "content/common/plugin_constants_win.h"
82 #endif 83 #endif
83 84
84 #if defined(OS_MACOSX) 85 #if defined(OS_MACOSX)
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 next_browser_snapshot_id_(1), 214 next_browser_snapshot_id_(1),
214 owned_by_render_frame_host_(false), 215 owned_by_render_frame_host_(false),
215 is_focused_(false), 216 is_focused_(false),
216 scale_input_to_viewport_(IsUseZoomForDSFEnabled()), 217 scale_input_to_viewport_(IsUseZoomForDSFEnabled()),
217 hung_renderer_delay_( 218 hung_renderer_delay_(
218 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), 219 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)),
219 new_content_rendering_delay_( 220 new_content_rendering_delay_(
220 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), 221 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)),
221 mouse_wheel_coalesce_timer_(new base::ElapsedTimer()), 222 mouse_wheel_coalesce_timer_(new base::ElapsedTimer()),
222 weak_factory_(this) { 223 weak_factory_(this) {
224 #if defined(OS_WIN)
225 // Update the display color profile cache so that it is likely to be up to
226 // date when the renderer process requests the color profile.
227 BrowserThread::PostBlockingPoolTask(
228 FROM_HERE, base::Bind(&gfx::UpdateDisplayColorProfileCache));
229 #endif
230
223 CHECK(delegate_); 231 CHECK(delegate_);
224 CHECK_NE(MSG_ROUTING_NONE, routing_id_); 232 CHECK_NE(MSG_ROUTING_NONE, routing_id_);
225 233
226 std::pair<RoutingIDWidgetMap::iterator, bool> result = 234 std::pair<RoutingIDWidgetMap::iterator, bool> result =
227 g_routing_id_widget_map.Get().insert(std::make_pair( 235 g_routing_id_widget_map.Get().insert(std::make_pair(
228 RenderWidgetHostID(process->GetID(), routing_id_), this)); 236 RenderWidgetHostID(process->GetID(), routing_id_), this));
229 CHECK(result.second) << "Inserting a duplicate item!"; 237 CHECK(result.second) << "Inserting a duplicate item!";
230 process_->AddRoute(routing_id_, this); 238 process_->AddRoute(routing_id_, this);
231 239
232 // If we're initially visible, tell the process host that we're alive. 240 // If we're initially visible, tell the process host that we're alive.
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 643
636 old_resize_params_ = make_scoped_ptr(new ResizeParams(resize_params)); 644 old_resize_params_ = make_scoped_ptr(new ResizeParams(resize_params));
637 } 645 }
638 646
639 void RenderWidgetHostImpl::WasResized() { 647 void RenderWidgetHostImpl::WasResized() {
640 // Skip if the |delegate_| has already been detached because 648 // Skip if the |delegate_| has already been detached because
641 // it's web contents is being deleted. 649 // it's web contents is being deleted.
642 if (resize_ack_pending_ || !process_->HasConnection() || !view_ || 650 if (resize_ack_pending_ || !process_->HasConnection() || !view_ ||
643 !renderer_initialized_ || auto_resize_enabled_ || !delegate_) { 651 !renderer_initialized_ || auto_resize_enabled_ || !delegate_) {
644 if (resize_ack_pending_ && color_profile_out_of_date_) 652 if (resize_ack_pending_ && color_profile_out_of_date_)
645 DispatchColorProfile(); 653 SendColorProfile();
646 return; 654 return;
647 } 655 }
648 656
649 scoped_ptr<ResizeParams> params(new ResizeParams); 657 scoped_ptr<ResizeParams> params(new ResizeParams);
650 if (color_profile_out_of_date_) 658 if (color_profile_out_of_date_)
651 DispatchColorProfile(); 659 SendColorProfile();
652 if (!GetResizeParams(params.get())) 660 if (!GetResizeParams(params.get()))
653 return; 661 return;
654 662
655 bool width_changed = 663 bool width_changed =
656 !old_resize_params_ || 664 !old_resize_params_ ||
657 old_resize_params_->new_size.width() != params->new_size.width(); 665 old_resize_params_->new_size.width() != params->new_size.width();
658 if (Send(new ViewMsg_Resize(routing_id_, *params))) { 666 if (Send(new ViewMsg_Resize(routing_id_, *params))) {
659 resize_ack_pending_ = params->needs_resize_ack; 667 resize_ack_pending_ = params->needs_resize_ack;
660 old_resize_params_.swap(params); 668 old_resize_params_.swap(params);
661 } 669 }
662 670
663 if (delegate_) 671 if (delegate_)
664 delegate_->RenderWidgetWasResized(this, width_changed); 672 delegate_->RenderWidgetWasResized(this, width_changed);
665 } 673 }
666 674
667 void RenderWidgetHostImpl::DispatchColorProfile() { 675 void RenderWidgetHostImpl::SendColorProfile() {
668 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
669 static bool image_profiles = base::CommandLine::ForCurrentProcess()-> 676 static bool image_profiles = base::CommandLine::ForCurrentProcess()->
670 HasSwitch(switches::kEnableImageColorProfiles); 677 HasSwitch(switches::kEnableImageColorProfiles);
671 if (!image_profiles) 678 if (!image_profiles)
672 return; 679 return;
673 #if defined(OS_WIN)
674 // Windows will read disk to get the color profile data if needed, so
675 // dispatch the SendColorProfile() work off the UI thread.
676 BrowserThread::PostBlockingPoolTask(
677 FROM_HERE,
678 base::Bind(&RenderWidgetHostImpl::SendColorProfile,
679 weak_factory_.GetWeakPtr()));
680 #elif !defined(OS_CHROMEOS) && !defined(OS_IOS) && !defined(OS_ANDROID)
681 // Only support desktop Mac and Linux at this time.
682 SendColorProfile();
683 #endif
684 #endif
685 }
686 680
687 void RenderWidgetHostImpl::SendColorProfile() {
688 if (!view_ || !delegate_) 681 if (!view_ || !delegate_)
689 return; 682 return;
690 DCHECK(!view_->GetRequestedRendererSize().IsEmpty()); 683 DCHECK(!view_->GetRequestedRendererSize().IsEmpty());
691 #if defined(OS_WIN)
692 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
693 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
694 #endif
695 std::vector<char> color_profile; 684 std::vector<char> color_profile;
696 if (!GetScreenColorProfile(&color_profile)) 685 if (!GetScreenColorProfile(&color_profile))
697 return; 686 return;
698 if (!renderer_initialized_ || !process_->HasConnection()) 687 if (!renderer_initialized_ || !process_->HasConnection())
699 return; 688 return;
700 if (!Send(new ViewMsg_ColorProfile(routing_id_, color_profile))) 689 if (!Send(new ViewMsg_ColorProfile(routing_id_, color_profile)))
701 return; 690 return;
702 color_profile_out_of_date_ = false; 691 color_profile_out_of_date_ = false;
703 } 692 }
704 693
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after
2242 } 2231 }
2243 2232
2244 #if defined(OS_WIN) 2233 #if defined(OS_WIN)
2245 gfx::NativeViewAccessible 2234 gfx::NativeViewAccessible
2246 RenderWidgetHostImpl::GetParentNativeViewAccessible() { 2235 RenderWidgetHostImpl::GetParentNativeViewAccessible() {
2247 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL; 2236 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL;
2248 } 2237 }
2249 #endif 2238 #endif
2250 2239
2251 } // namespace content 2240 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698