diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_main.cc | 5 | ||||
-rw-r--r-- | chrome/browser/chromeos/native_theme_chromeos.cc | 76 | ||||
-rw-r--r-- | chrome/browser/chromeos/native_theme_chromeos.h | 6 | ||||
-rw-r--r-- | chrome/browser/renderer_preferences_util.cc | 2 | ||||
-rw-r--r-- | chrome/chrome.gyp | 1 | ||||
-rw-r--r-- | chrome/chrome_common.gypi | 2 | ||||
-rw-r--r-- | chrome/common/gfx_resource_provider.cc | 16 | ||||
-rw-r--r-- | chrome/common/gfx_resource_provider.h | 20 | ||||
-rw-r--r-- | chrome/renderer/renderer_main.cc | 5 |
9 files changed, 58 insertions, 75 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index c18f2a8d..fea615c 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -76,6 +76,7 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/env_vars.h" +#include "chrome/common/gfx_resource_provider.h" #include "chrome/common/hi_res_timer_manager.h" #include "chrome/common/json_pref_store.h" #include "chrome/common/jstemplate_builder.h" @@ -85,6 +86,7 @@ #include "chrome/common/pref_names.h" #include "chrome/common/result_codes.h" #include "chrome/installer/util/google_update_settings.h" +#include "gfx/gfx_module.h" #include "grit/app_locale_settings.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -1507,8 +1509,9 @@ int BrowserMain(const MainFunctionParams& parameters) { #endif #endif - // Configure the network module so it has access to resources. + // Configure modules that need access to resources. net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); + gfx::GfxModule::SetResourceProvider(chrome::GfxResourceProvider); // Register our global network handler for chrome:// and // chrome-extension:// URLs. diff --git a/chrome/browser/chromeos/native_theme_chromeos.cc b/chrome/browser/chromeos/native_theme_chromeos.cc index c0cd025..c8bc6da 100644 --- a/chrome/browser/chromeos/native_theme_chromeos.cc +++ b/chrome/browser/chromeos/native_theme_chromeos.cc @@ -4,8 +4,6 @@ #include "chrome/browser/chromeos/native_theme_chromeos.h" -#include <limits> - #include "app/resource_bundle.h" #include "base/logging.h" #include "gfx/insets.h" @@ -15,67 +13,6 @@ #include "grit/theme_resources.h" #include "third_party/skia/include/core/SkShader.h" -namespace { - -bool IntersectsClipRectInt( - skia::PlatformCanvas* canvas, int x, int y, int w, int h) { - SkRect clip; - return canvas->getClipBounds(&clip) && - clip.intersect(SkIntToScalar(x), SkIntToScalar(y), SkIntToScalar(x + w), - SkIntToScalar(y + h)); -} - -void DrawBitmapInt( - skia::PlatformCanvas* canvas, const SkBitmap& bitmap, - int src_x, int src_y, int src_w, int src_h, - int dest_x, int dest_y, int dest_w, int dest_h) { - DLOG_ASSERT(src_x + src_w < std::numeric_limits<int16_t>::max() && - src_y + src_h < std::numeric_limits<int16_t>::max()); - if (src_w <= 0 || src_h <= 0 || dest_w <= 0 || dest_h <= 0) { - NOTREACHED() << "Attempting to draw bitmap to/from an empty rect!"; - return; - } - - if (!IntersectsClipRectInt(canvas, dest_x, dest_y, dest_w, dest_h)) - return; - - SkRect dest_rect = { SkIntToScalar(dest_x), - SkIntToScalar(dest_y), - SkIntToScalar(dest_x + dest_w), - SkIntToScalar(dest_y + dest_h) }; - - if (src_w == dest_w && src_h == dest_h) { - // Workaround for apparent bug in Skia that causes image to occasionally - // shift. - SkIRect src_rect = { src_x, src_y, src_x + src_w, src_y + src_h }; - canvas->drawBitmapRect(bitmap, &src_rect, dest_rect); - return; - } - - // Make a bitmap shader that contains the bitmap we want to draw. This is - // basically what SkCanvas.drawBitmap does internally, but it gives us - // more control over quality and will use the mipmap in the source image if - // it has one, whereas drawBitmap won't. - SkShader* shader = SkShader::CreateBitmapShader(bitmap, - SkShader::kRepeat_TileMode, - SkShader::kRepeat_TileMode); - SkMatrix shader_scale; - shader_scale.setScale(SkFloatToScalar(static_cast<float>(dest_w) / src_w), - SkFloatToScalar(static_cast<float>(dest_h) / src_h)); - shader_scale.preTranslate(SkIntToScalar(-src_x), SkIntToScalar(-src_y)); - shader_scale.postTranslate(SkIntToScalar(dest_x), SkIntToScalar(dest_y)); - shader->setLocalMatrix(shader_scale); - - // The rect will be filled by the bitmap. - SkPaint p; - p.setFilterBitmap(true); - p.setShader(shader); - shader->unref(); - canvas->drawRect(dest_rect, p); -} - -} - /* static */ gfx::NativeThemeLinux* gfx::NativeThemeLinux::instance() { // The global NativeThemeChromeos instance. @@ -89,7 +26,7 @@ NativeThemeChromeos::NativeThemeChromeos() { NativeThemeChromeos::~NativeThemeChromeos() { } -gfx::Size NativeThemeChromeos::GetSize(Part part) const { +gfx::Size NativeThemeChromeos::GetPartSize(Part part) const { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); int scrollbar_width = rb.GetBitmapNamed(IDR_SCROLL_BACKGROUND)->width(); int width = 0, height = 0; @@ -124,11 +61,13 @@ gfx::Size NativeThemeChromeos::GetSize(Part part) const { width = scrollbar_width; height = scrollbar_width; break; + default: + return NativeThemeLinux::GetPartSize(part); } return gfx::Size(width, height); } -void NativeThemeChromeos::PaintTrack(skia::PlatformCanvas* canvas, +void NativeThemeChromeos::PaintScrollbarTrack(skia::PlatformCanvas* canvas, Part part, State state, const ScrollbarTrackExtraParams& extra_params, const gfx::Rect& rect) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); @@ -174,11 +113,11 @@ void NativeThemeChromeos::PaintTrack(skia::PlatformCanvas* canvas, } } -void NativeThemeChromeos::PaintThumb(skia::PlatformCanvas* canvas, +void NativeThemeChromeos::PaintScrollbarThumb(skia::PlatformCanvas* canvas, Part part, State state, const gfx::Rect& rect) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); int resource_id = IDR_SCROLL_THUMB; - if (state == kHover) + if (state == kHovered) resource_id++; else if (state == kPressed) resource_id += 2; @@ -225,7 +164,7 @@ void NativeThemeChromeos::PaintArrowButton(skia::PlatformCanvas* canvas, int resource_id = (part == kScrollbarUpArrow || part == kScrollbarLeftArrow) ? IDR_SCROLL_ARROW_UP : IDR_SCROLL_ARROW_DOWN; - if (state == kHover) + if (state == kHovered) resource_id++; else if (state == kPressed) resource_id += 2; @@ -255,4 +194,3 @@ SkBitmap* NativeThemeChromeos::GetHorizontalBitmapNamed(int resource_id) { } return NULL; } - diff --git a/chrome/browser/chromeos/native_theme_chromeos.h b/chrome/browser/chromeos/native_theme_chromeos.h index d501f682e..fe92c91 100644 --- a/chrome/browser/chromeos/native_theme_chromeos.h +++ b/chrome/browser/chromeos/native_theme_chromeos.h @@ -17,14 +17,14 @@ class NativeThemeChromeos : public gfx::NativeThemeLinux { virtual ~NativeThemeChromeos(); // Scrollbar painting overrides - virtual gfx::Size GetSize(Part part) const; - virtual void PaintTrack(skia::PlatformCanvas* canvas, + virtual gfx::Size GetPartSize(Part part) const; + virtual void PaintScrollbarTrack(skia::PlatformCanvas* canvas, Part part, State state, const ScrollbarTrackExtraParams& extra_params, const gfx::Rect& rect); virtual void PaintArrowButton(skia::PlatformCanvas* canvas, const gfx::Rect& rect, Part direction, State state); - virtual void PaintThumb(skia::PlatformCanvas* canvas, + virtual void PaintScrollbarThumb(skia::PlatformCanvas* canvas, Part part, State state, const gfx::Rect& rect); SkBitmap* GetHorizontalBitmapNamed(int resource_id); diff --git a/chrome/browser/renderer_preferences_util.cc b/chrome/browser/renderer_preferences_util.cc index 2c021c8..e487b93 100644 --- a/chrome/browser/renderer_preferences_util.cc +++ b/chrome/browser/renderer_preferences_util.cc @@ -31,7 +31,7 @@ void UpdateFromSystemSettings(RendererPreferences* prefs, Profile* profile) { prefs->inactive_selection_fg_color = provider->get_inactive_selection_fg_color(); #else - prefs->focus_ring_color = SkColorSetARGB(255, 229, 151, 0); + prefs->focus_ring_color = SkColorSetRGB(0x50, 0x7A, 0xD5); prefs->active_selection_bg_color = SkColorSetRGB(0xDC, 0xE4, 0xFA); prefs->active_selection_fg_color = SK_ColorBLACK; prefs->inactive_selection_bg_color = SkColorSetRGB(0xF7, 0xF7, 0xF7); diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 9145889..05ff5f4 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -1833,6 +1833,7 @@ '<(grit_out_dir)/renderer_resources.pak', '<(grit_out_dir)/theme_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/app/app_resources/app_resources.pak', + '<(SHARED_INTERMEDIATE_DIR)/gfx/gfx_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources.pak', diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index dfec0d6..7d8d62d 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -77,6 +77,8 @@ 'common/font_config_ipc_linux.h', 'common/geoposition.cc', 'common/geoposition.h', + 'common/gfx_resource_provider.cc', + 'common/gfx_resource_provider.h', 'common/gpu_create_command_buffer_config.cc', 'common/gpu_create_command_buffer_config.h', 'common/gpu_feature_flags.cc', diff --git a/chrome/common/gfx_resource_provider.cc b/chrome/common/gfx_resource_provider.cc new file mode 100644 index 0000000..f508c28 --- /dev/null +++ b/chrome/common/gfx_resource_provider.cc @@ -0,0 +1,16 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/gfx_resource_provider.h" + +#include "app/resource_bundle.h" +#include "base/string_piece.h" + +namespace chrome { + +base::StringPiece GfxResourceProvider(int key) { + return ResourceBundle::GetSharedInstance().GetRawDataResource(key); +} + +} // namespace chrome diff --git a/chrome/common/gfx_resource_provider.h b/chrome/common/gfx_resource_provider.h new file mode 100644 index 0000000..41b67b8 --- /dev/null +++ b/chrome/common/gfx_resource_provider.h @@ -0,0 +1,20 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_COMMON_GFX_RESOURCE_PROVIDER_H_ +#define CHROME_COMMON_GFX_RESOURCE_PROVIDER_H_ +#pragma once + +namespace base { +class StringPiece; +} + +namespace chrome { + +// This is called indirectly by the gfx theme code to access resources. +base::StringPiece GfxResourceProvider(int key); + +} // namespace chrome + +#endif // CHROME_COMMON_GFX_RESOURCE_PROVIDER_H_ diff --git a/chrome/renderer/renderer_main.cc b/chrome/renderer/renderer_main.cc index 970aa3e..b6cdd6c 100644 --- a/chrome/renderer/renderer_main.cc +++ b/chrome/renderer/renderer_main.cc @@ -21,6 +21,7 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_counters.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/gfx_resource_provider.h" #include "chrome/common/hi_res_timer_manager.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/main_function_params.h" @@ -29,6 +30,7 @@ #include "chrome/renderer/renderer_main_platform_delegate.h" #include "chrome/renderer/render_process_impl.h" #include "chrome/renderer/render_thread.h" +#include "gfx/gfx_module.h" #include "grit/generated_resources.h" #include "net/base/net_module.h" #include "ui/base/system_monitor/system_monitor.h" @@ -213,8 +215,9 @@ int RendererMain(const MainFunctionParams& parameters) { InitCrashReporter(); #endif - // Configure the network module so it has access to resources. + // Configure modules that need access to resources. net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); + gfx::GfxModule::SetResourceProvider(chrome::GfxResourceProvider); // This function allows pausing execution using the --renderer-startup-dialog // flag allowing us to attach a debugger. |