Commit 1793e046 authored by Scott Graham's avatar Scott Graham

Revert of Fixes for two different HUD issues related to win32k lockdown...

Revert of Fixes for two different HUD issues related to win32k lockdown (patchset #9 id:350001 of https://codereview.chromium.org/900063002/)

Reason for revert:
Causes regression in cold start on Android and maybe Mac.

Details in http://crbug.com/457248.

Original issue's description:
> Fixes for two different HUD issues related to win32k lockdown
>
> 1. Using a GDI bitmap -- switch to SkSurface instead
>
> 2. Lazily loading a font. This breaks for two different reasons.
> The first is a DCHECK for doing IO on the Compositor thread. This
> could have been just ignored in general since it's only for debug
> usage, the drawbacks of minor jank are limited.
>
> However, once lockdown is on, the font load hard fails from the
> renderer. So, load the typeface before lockdown and pass it into
> CC and the hud via LayerTreeSettings.
>
> R=danakj@chromium.org
> BUG=453731,455104
> TEST=run chrome with --enable-win32k-renderer-lockdown --show-fps-counter --ui-show-fps-counter on Win8
>
> Committed: https://crrev.com/616a8e656b2d923ed393bde86adc150e555ba799
> Cr-Commit-Position: refs/heads/master@{#314929}

TBR=enne@chromium.org,danakj@chromium.org,piman@chromium.org
BUG=453731,455104,457248

Review URL: https://codereview.chromium.org/922293006

Cr-Commit-Position: refs/heads/master@{#317648}
parent 9b3d6f1d
......@@ -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 =
......
......@@ -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_;
......
......@@ -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;
};
......
......@@ -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,
......
......@@ -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
......
......@@ -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(
......
......@@ -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",
......
......@@ -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',
......
// 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
// 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_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment