diff options
-rw-r--r-- | cc/layers/heads_up_display_layer_impl.cc | 31 | ||||
-rw-r--r-- | cc/layers/heads_up_display_layer_impl.h | 4 | ||||
-rw-r--r-- | cc/trees/layer_tree_settings.h | 3 | ||||
-rw-r--r-- | content/renderer/gpu/render_widget_compositor.cc | 3 | ||||
-rw-r--r-- | content/renderer/renderer_main_platform_delegate_win.cc | 10 | ||||
-rw-r--r-- | ui/compositor/compositor.cc | 2 | ||||
-rw-r--r-- | ui/gfx/BUILD.gn | 8 | ||||
-rw-r--r-- | ui/gfx/gfx.gyp | 2 | ||||
-rw-r--r-- | ui/gfx/hud_font.cc | 30 | ||||
-rw-r--r-- | ui/gfx/hud_font.h | 20 |
10 files changed, 23 insertions, 90 deletions
diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc index 19217c9..6d184f3 100644 --- a/cc/layers/heads_up_display_layer_impl.cc +++ b/cc/layers/heads_up_display_layer_impl.cc @@ -70,6 +70,8 @@ double HeadsUpDisplayLayerImpl::Graph::UpdateUpperBound() { HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl, int id) : LayerImpl(tree_impl, id), + typeface_(skia::AdoptRef( + SkTypeface::CreateFromName("monospace", SkTypeface::kBold))), internal_contents_scale_(1.f), fps_graph_(60.0, 80.0), paint_time_graph_(16.0, 48.0), @@ -177,38 +179,39 @@ void HeadsUpDisplayLayerImpl::UpdateHudTexture( return; SkISize canvas_size; - if (hud_surface_) - canvas_size = hud_surface_->getCanvas()->getDeviceSize(); + if (hud_canvas_) + canvas_size = hud_canvas_->getDeviceSize(); else canvas_size.set(0, 0); if (canvas_size.width() != internal_content_bounds_.width() || canvas_size.height() != internal_content_bounds_.height() || - !hud_surface_) { + !hud_canvas_) { TRACE_EVENT0("cc", "ResizeHudCanvas"); - hud_surface_ = skia::AdoptRef(SkSurface::NewRasterN32Premul( - internal_content_bounds_.width(), internal_content_bounds_.height())); + bool opaque = false; + hud_canvas_ = make_scoped_ptr( + skia::CreateBitmapCanvas(internal_content_bounds_.width(), + internal_content_bounds_.height(), opaque)); } UpdateHudContents(); { TRACE_EVENT0("cc", "DrawHudContents"); - hud_surface_->getCanvas()->clear(SkColorSetARGB(0, 0, 0, 0)); - hud_surface_->getCanvas()->save(); - hud_surface_->getCanvas()->scale(internal_contents_scale_, - internal_contents_scale_); + hud_canvas_->clear(SkColorSetARGB(0, 0, 0, 0)); + hud_canvas_->save(); + hud_canvas_->scale(internal_contents_scale_, internal_contents_scale_); - DrawHudContents(hud_surface_->getCanvas()); + DrawHudContents(hud_canvas_.get()); - hud_surface_->getCanvas()->restore(); + hud_canvas_->restore(); } TRACE_EVENT0("cc", "UploadHudTexture"); SkImageInfo info; size_t row_bytes = 0; - const void* pixels = hud_surface_->getCanvas()->peekPixels(&info, &row_bytes); + const void* pixels = hud_canvas_->peekPixels(&info, &row_bytes); DCHECK(pixels); DCHECK(info.colorType() == kN32_SkColorType); resource_provider->CopyToResource(resources_.back()->id(), @@ -303,7 +306,7 @@ void HeadsUpDisplayLayerImpl::DrawText(SkCanvas* canvas, paint->setTextSize(size); paint->setTextAlign(align); - paint->setTypeface(layer_tree_impl()->settings().hud_typeface.get()); + paint->setTypeface(typeface_.get()); canvas->drawText(text.c_str(), text.length(), x, y, *paint); paint->setAntiAlias(anti_alias); @@ -710,7 +713,7 @@ void HeadsUpDisplayLayerImpl::DrawDebugRect( SkPaint label_paint = CreatePaint(); label_paint.setTextSize(kFontHeight); - label_paint.setTypeface(layer_tree_impl()->settings().hud_typeface.get()); + label_paint.setTypeface(typeface_.get()); label_paint.setColor(stroke_color); const SkScalar label_text_width = diff --git a/cc/layers/heads_up_display_layer_impl.h b/cc/layers/heads_up_display_layer_impl.h index 5c3720e..aa07bf8 100644 --- a/cc/layers/heads_up_display_layer_impl.h +++ b/cc/layers/heads_up_display_layer_impl.h @@ -125,7 +125,9 @@ class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl { void ReleaseUnmatchedSizeResources(ResourceProvider* resource_provider); ScopedPtrVector<ScopedResource> resources_; - skia::RefPtr<SkSurface> hud_surface_; + scoped_ptr<SkCanvas> hud_canvas_; + + skia::RefPtr<SkTypeface> typeface_; float internal_contents_scale_; gfx::Size internal_content_bounds_; diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h index a0fbeaa..06c319a 100644 --- a/cc/trees/layer_tree_settings.h +++ b/cc/trees/layer_tree_settings.h @@ -9,9 +9,7 @@ #include "cc/base/cc_export.h" #include "cc/debug/layer_tree_debug_state.h" #include "cc/output/renderer_settings.h" -#include "skia/ext/refptr.h" #include "third_party/skia/include/core/SkColor.h" -#include "third_party/skia/include/core/SkTypeface.h" #include "ui/gfx/geometry/size.h" namespace cc { @@ -86,7 +84,6 @@ class CC_EXPORT LayerTreeSettings { bool record_full_layer; bool use_display_lists; bool verify_property_trees; - skia::RefPtr<SkTypeface> hud_typeface; LayerTreeDebugState initial_debug_state; }; diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc index 286929b..46ecdb7 100644 --- a/content/renderer/gpu/render_widget_compositor.cc +++ b/content/renderer/gpu/render_widget_compositor.cc @@ -42,7 +42,6 @@ #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" #include "third_party/WebKit/public/web/WebWidget.h" #include "ui/gfx/frame_time.h" -#include "ui/gfx/hud_font.h" #include "ui/gl/gl_switches.h" #include "ui/native_theme/native_theme_switches.h" @@ -455,8 +454,6 @@ void RenderWidgetCompositor::Initialize() { compositor_deps_->CreateExternalBeginFrameSource(widget_->routing_id()); } - settings.hud_typeface = ui::GetHudTypeface(); - if (compositor_thread_task_runner.get()) { layer_tree_host_ = cc::LayerTreeHost::CreateThreaded( this, shared_bitmap_manager, gpu_memory_buffer_manager, settings, diff --git a/content/renderer/renderer_main_platform_delegate_win.cc b/content/renderer/renderer_main_platform_delegate_win.cc index dd749c2..309646c 100644 --- a/content/renderer/renderer_main_platform_delegate_win.cc +++ b/content/renderer/renderer_main_platform_delegate_win.cc @@ -23,7 +23,6 @@ #include "third_party/icu/source/i18n/unicode/timezone.h" #include "third_party/skia/include/ports/SkFontMgr.h" #include "third_party/skia/include/ports/SkTypeface_win.h" -#include "ui/gfx/hud_font.h" #include "ui/gfx/win/direct_write.h" #include "ui/gfx/win/dpi.h" @@ -55,17 +54,10 @@ void SkiaPreCacheFontCharacters(const LOGFONT& logfont, void WarmupDirectWrite() { // The objects used here are intentionally not freed as we want the Skia // code to use these objects after warmup. - SetDefaultSkiaFactory(GetPreSandboxWarmupFontMgr()); SkTypeface* typeface = GetPreSandboxWarmupFontMgr()->legacyCreateTypeface("Times New Roman", 0); DoPreSandboxWarmupForTypeface(typeface); - - // The CC HUD needs a debug font, we warm that up here and pass it down. - skia::RefPtr<SkTypeface> hud_typeface = - skia::AdoptRef(GetPreSandboxWarmupFontMgr()->legacyCreateTypeface( - "Consolas", SkTypeface::kBold)); - DoPreSandboxWarmupForTypeface(hud_typeface.get()); - ui::SetHudTypeface(hud_typeface); + SetDefaultSkiaFactory(GetPreSandboxWarmupFontMgr()); } } // namespace diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc index 7989858..4793cbb 100644 --- a/ui/compositor/compositor.cc +++ b/ui/compositor/compositor.cc @@ -31,7 +31,6 @@ #include "ui/compositor/layer.h" #include "ui/compositor/layer_animator_collection.h" #include "ui/gfx/frame_time.h" -#include "ui/gfx/hud_font.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_switches.h" @@ -133,7 +132,6 @@ Compositor::Compositor(gfx::AcceleratedWidget widget, settings.impl_side_painting = IsUIImplSidePaintingEnabled(); settings.use_zero_copy = IsUIZeroCopyEnabled(); - settings.hud_typeface = ui::GetHudTypeface(); base::TimeTicks before_create = base::TimeTicks::Now(); host_ = cc::LayerTreeHost::CreateSingleThreaded( diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn index 5485a05..47e0056 100644 --- a/ui/gfx/BUILD.gn +++ b/ui/gfx/BUILD.gn @@ -105,8 +105,6 @@ component("gfx") { "gfx_paths.h", "gpu_memory_buffer.cc", "gpu_memory_buffer.h", - "hud_font.cc", - "hud_font.h", "icon_util.cc", "icon_util.h", "image/canvas_image_source.cc", @@ -309,10 +307,8 @@ component("gfx") { # Windows. if (is_win) { - cflags = [ - "/wd4324", # Structure was padded due to __declspec(align()), which is - # uninteresting. - ] + cflags = [ "/wd4324" ] # Structure was padded due to __declspec(align()), which is + # uninteresting. } else { sources -= [ "gdi_util.cc", diff --git a/ui/gfx/gfx.gyp b/ui/gfx/gfx.gyp index d8da3fe..001d180 100644 --- a/ui/gfx/gfx.gyp +++ b/ui/gfx/gfx.gyp @@ -184,8 +184,6 @@ 'gpu_memory_buffer.h', 'harfbuzz_font_skia.cc', 'harfbuzz_font_skia.h', - 'hud_font.cc', - 'hud_font.h', 'image/canvas_image_source.cc', 'image/canvas_image_source.h', 'image/image.cc', diff --git a/ui/gfx/hud_font.cc b/ui/gfx/hud_font.cc deleted file mode 100644 index b64845b..0000000 --- a/ui/gfx/hud_font.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2015 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 "ui/gfx/hud_font.h" - -#include "base/lazy_instance.h" -#include "third_party/skia/include/core/SkTypeface.h" - -namespace ui { - -namespace { -base::LazyInstance<skia::RefPtr<SkTypeface>> g_hud_typeface; -} // namespace - -void SetHudTypeface(skia::RefPtr<SkTypeface> typeface) { - g_hud_typeface.Get() = typeface; -} - -skia::RefPtr<SkTypeface> GetHudTypeface() { - if (!g_hud_typeface.Get()) { - // This will be set pre-sandbox on Windows. On other platforms, just make - // something here. - SetHudTypeface(skia::AdoptRef( - SkTypeface::CreateFromName("monospace", SkTypeface::kBold))); - } - return g_hud_typeface.Get(); -} - -} // namespace ui diff --git a/ui/gfx/hud_font.h b/ui/gfx/hud_font.h deleted file mode 100644 index 3d38d4b..0000000 --- a/ui/gfx/hud_font.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 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 UI_GFX_HUD_FONT_H_ -#define UI_GFX_HUD_FONT_H_ - -#include "skia/ext/refptr.h" -#include "ui/gfx/gfx_export.h" - -class SkTypeface; - -namespace ui { - -GFX_EXPORT void SetHudTypeface(skia::RefPtr<SkTypeface> typeface); -GFX_EXPORT skia::RefPtr<SkTypeface> GetHudTypeface(); - -} // namespace ui - -#endif // UI_GFX_HUD_FONT_H_ |