From c3870f4f8eb28a1e1685426368758e2cd8754e03 Mon Sep 17 00:00:00 2001 From: "wjmaclean@chromium.org" Date: Fri, 10 Jun 2011 16:43:27 +0000 Subject: [PATCH] Remove COMPOSITOR_2 flag, old compositor code. BUG=none TEST=compiles, run manually Review URL: http://codereview.chromium.org/6975051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88671 0039d316-1c4b-4281-b951-d872f2087c98 --- build/common.gypi | 3 +- chrome/browser/ui/views/wrench_menu.cc | 10 ----- chrome/test/unit/chrome_test_suite.cc | 2 +- ui/gfx/compositor/compositor.h | 42 ------------------- ui/gfx/compositor/compositor_gl.cc | 67 ------------------------------- views/run_all_unittests.cc | 4 +- views/view.cc | 73 ++-------------------------------- views/view.h | 19 --------- views/view_unittest.cc | 2 +- views/widget/root_view.cc | 2 - views/widget/root_view.h | 2 - views/widget/widget.cc | 11 ----- 12 files changed, 8 insertions(+), 229 deletions(-) diff --git a/build/common.gypi b/build/common.gypi index 54d06d394185..11c5a34170a7 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -653,8 +653,7 @@ 'defines': ['TOOLKIT_VIEWS=1'], }], ['views_compositor==1', { - # TODO(sky): nuke COMPOSITOR_2 when we remove it from views. - 'defines': ['VIEWS_COMPOSITOR=1', 'COMPOSITOR_2=1'], + 'defines': ['VIEWS_COMPOSITOR=1'], }], ['chromeos==1', { 'defines': ['OS_CHROMEOS=1'], diff --git a/chrome/browser/ui/views/wrench_menu.cc b/chrome/browser/ui/views/wrench_menu.cc index 7e7023a86795..9094a9e2e1de 100644 --- a/chrome/browser/ui/views/wrench_menu.cc +++ b/chrome/browser/ui/views/wrench_menu.cc @@ -234,15 +234,6 @@ class ScheduleAllView : public views::View { public: ScheduleAllView() {} -#if !defined(COMPOSITOR_2) - virtual void SchedulePaintInRect(const gfx::Rect& r) { - if (!IsVisible()) - return; - - if (parent()) - parent()->SchedulePaintInRect(GetMirroredBounds()); - } -#else virtual void SchedulePaintInRect(const gfx::Rect& r) { View::SchedulePaintInRect(gfx::Rect(0, 0, width(), height())); } @@ -250,7 +241,6 @@ class ScheduleAllView : public views::View { virtual void SchedulePaintInternal(const gfx::Rect& r) { View::SchedulePaintInternal(gfx::Rect(0, 0, width(), height())); } -#endif private: DISALLOW_COPY_AND_ASSIGN(ScheduleAllView); diff --git a/chrome/test/unit/chrome_test_suite.cc b/chrome/test/unit/chrome_test_suite.cc index 3acb89a7dbf2..09e184d338f6 100644 --- a/chrome/test/unit/chrome_test_suite.cc +++ b/chrome/test/unit/chrome_test_suite.cc @@ -145,7 +145,7 @@ void ChromeTestSuite::Initialize() { stats_table_ = new base::StatsTable(stats_filename_, 20, 200); base::StatsTable::set_current(stats_table_); -#if defined(TOUCH_UI) +#if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) // Turn of GPU compositing in browser during unit tests. views::View::set_use_acceleration_when_possible(false); #endif diff --git a/ui/gfx/compositor/compositor.h b/ui/gfx/compositor/compositor.h index 12b2e682f071..2c71b4aeadb4 100644 --- a/ui/gfx/compositor/compositor.h +++ b/ui/gfx/compositor/compositor.h @@ -19,47 +19,6 @@ class Size; namespace ui { class Transform; -#if !defined(COMPOSITOR_2) -typedef unsigned int TextureID; - -// NOTE: all coordinates passed to Texture/Compositor have 0x0 as the upper left -// corner. - -// Compositor object to take care of GPU painting. -// A Browser compositor object is responsible for generating the final -// displayable form of pixels comprising a single widget's contents. It draws an -// appropriately transformed texture for each transformed view in the widget's -// view hierarchy. The initial implementation uses GL for this purpose. -// Future CLs will adapt this to ongoing Skia development. -class Compositor : public base::RefCounted { - public: - // Create a compositor from the provided handle. - static Compositor* Create(gfx::AcceleratedWidget widget); - - // Notifies the compositor that compositing is about to start. - virtual void NotifyStart() = 0; - - // Notifies the compositor that compositing is complete. - virtual void NotifyEnd() = 0; - - // Draws the given texture with the given transform. - virtual void DrawTextureWithTransform(TextureID txt, - const ui::Transform& transform) = 0; - - // Save the current transformation that can be restored with RestoreTransform. - virtual void SaveTransform() = 0; - - // Restore a previously saved transformation using SaveTransform. - virtual void RestoreTransform() = 0; - - protected: - virtual ~Compositor() {} - - private: - friend class base::RefCounted; -}; - -#else // Textures are created by a Compositor for managing an accelerated view. // Any time a View with a texture needs to redraw itself it invokes SetBitmap(). // When the view is ready to be drawn Draw() is invoked. @@ -111,7 +70,6 @@ class Compositor : public base::RefCounted { friend class base::RefCounted; }; -#endif // COMPOSITOR_2 } // namespace ui #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ diff --git a/ui/gfx/compositor/compositor_gl.cc b/ui/gfx/compositor/compositor_gl.cc index e591e2accf08..5c68add57c32 100644 --- a/ui/gfx/compositor/compositor_gl.cc +++ b/ui/gfx/compositor/compositor_gl.cc @@ -23,7 +23,6 @@ namespace ui { -#if defined COMPOSITOR_2 namespace glHidden { class CompositorGL; @@ -362,71 +361,5 @@ Compositor* Compositor::Create(gfx::AcceleratedWidget widget) { return new glHidden::CompositorGL(widget); return NULL; } -#else -class CompositorGL : public Compositor { - public: - explicit CompositorGL(gfx::AcceleratedWidget widget); - - private: - // Overridden from Compositor. - void NotifyStart() OVERRIDE; - void NotifyEnd() OVERRIDE; - void DrawTextureWithTransform(TextureID txt, - const ui::Transform& transform) OVERRIDE; - void SaveTransform() OVERRIDE; - void RestoreTransform() OVERRIDE; - - // The GL context used for compositing. - scoped_refptr gl_surface_; - scoped_refptr gl_context_; - - // Keep track of whether compositing has started or not. - bool started_; - - DISALLOW_COPY_AND_ASSIGN(CompositorGL); -}; - -CompositorGL::CompositorGL(gfx::AcceleratedWidget widget) - : started_(false) { - gl_surface_ = gfx::GLSurface::CreateViewGLSurface(widget); - gl_context_ = gfx::GLContext::CreateGLContext(NULL, gl_surface_.get()); -} - -void CompositorGL::NotifyStart() { - started_ = true; - gl_context_->MakeCurrent(gl_surface_.get()); -} - -void CompositorGL::NotifyEnd() { - DCHECK(started_); - gl_surface_->SwapBuffers(); - started_ = false; -} - -void CompositorGL::DrawTextureWithTransform(TextureID txt, - const ui::Transform& transform) { - DCHECK(started_); - - // TODO(wjmaclean): - NOTIMPLEMENTED(); -} - -void CompositorGL::SaveTransform() { - // TODO(sadrul): - NOTIMPLEMENTED(); -} - -void CompositorGL::RestoreTransform() { - // TODO(sadrul): - NOTIMPLEMENTED(); -} - -// static -Compositor* Compositor::Create(gfx::AcceleratedWidget widget) { - if (gfx::GetGLImplementation() != gfx::kGLImplementationNone) - return new CompositorGL(widget); - return NULL; -} -#endif } // namespace ui diff --git a/views/run_all_unittests.cc b/views/run_all_unittests.cc index 3a0e106f1204..9d68e169ca19 100644 --- a/views/run_all_unittests.cc +++ b/views/run_all_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -19,7 +19,7 @@ class ViewTestSuite : public base::TestSuite { base::TestSuite::Initialize(); ResourceBundle::InitSharedInstance("en-US"); -#if defined(TOUCH_UI) +#if defined(OS_LINUX) // Disable GPU browser compositor during unit tests. views::View::set_use_acceleration_when_possible(false); #endif diff --git a/views/view.cc b/views/view.cc index 7ed2ac87415a..807316d6f0f4 100644 --- a/views/view.cc +++ b/views/view.cc @@ -106,9 +106,6 @@ View::View() clip_y_(0.0), needs_layout_(true), flip_canvas_on_paint_for_rtl_ui_(false), -#if !defined(COMPOSITOR_2) - texture_id_(0), // TODO(sadrul): 0 can be a valid texture id. -#endif texture_needs_updating_(true), paint_to_texture_(false), accelerator_registration_delayed_(false), @@ -177,9 +174,8 @@ void View::AddChildViewAt(View* view, int index) { if (layout_manager_.get()) layout_manager_->ViewAdded(this, view); -#if defined(COMPOSITOR_2) + view->MarkTextureDirty(); -#endif } void View::RemoveChildView(View* view) { @@ -402,16 +398,13 @@ void View::SetTransform(const ui::Transform& transform) { if (!transform_.get()) return; transform_.reset(NULL); -#if !defined(COMPOSITOR_2) - canvas_.reset(); -#else + if (!paint_to_texture_) texture_.reset(); -#endif + SchedulePaint(); } else { transform_.reset(new ui::Transform(transform)); -#if defined(COMPOSITOR_2) if (!texture_.get()) { // We don't yet have a texture. SchedulePaint so one is created. SchedulePaint(); @@ -426,19 +419,16 @@ void View::SetTransform(const ui::Transform& transform) { if (widget) widget->SchedulePaintInRect(widget->GetRootView()->bounds()); } -#endif } } void View::SetPaintToTexture(bool value) { -#if defined(COMPOSITOR_2) if (value == paint_to_texture_) return; paint_to_texture_ = value; if (!ShouldPaintToTexture()) texture_.reset(); -#endif } // RTL positioning ------------------------------------------------------------- @@ -630,18 +620,8 @@ void View::SchedulePaintInRect(const gfx::Rect& rect) { if (!IsVisible()) return; -#if defined(COMPOSITOR_2) MarkTextureDirty(); SchedulePaintInternal(rect); -#else - if (parent_) { - // Translate the requested paint rect to the parent's coordinate system - // then pass this notification up to the parent. - gfx::Rect paint_rect = ConvertRectToParent(rect); - paint_rect.Offset(GetMirroredPosition()); - parent_->SchedulePaintInRect(paint_rect); - } -#endif } void View::Paint(gfx::Canvas* canvas) { @@ -652,13 +632,6 @@ void View::Paint(gfx::Canvas* canvas) { scoped_ptr texture_canvas; gfx::Rect texture_rect; -#if !defined(COMPOSITOR_2) - if (use_acceleration_when_possible && - transform_.get() && transform_->HasChange()) { - // This view has a transformation. So this maintains its own canvas. - if (!canvas_.get()) - canvas_.reset(gfx::Canvas::CreateCanvas(width(), height(), false)); -#else if (ShouldPaintToTexture()) { gfx::Rect dirty_rect; if (!texture_clip_rect_.IsEmpty()) { @@ -689,7 +662,6 @@ void View::Paint(gfx::Canvas* canvas) { texture_canvas->TranslateInt(-dirty_rect.x(), -dirty_rect.y()); canvas = texture_canvas.get(); texture_rect = dirty_rect; -#endif } else { // We're going to modify the canvas, save its state first. scoped_canvas.SetCanvas(canvas); @@ -732,13 +704,6 @@ void View::Paint(gfx::Canvas* canvas) { PaintChildren(canvas); -#if !defined(COMPOSITOR_2) - if (canvas == canvas_.get()) { - texture_id_ = canvas->GetTextureID(); - - // TODO(sadrul): Make sure the Widget's compositor tree updates itself? - } -#else if (texture_canvas.get()) { texture_->SetBitmap( texture_canvas->AsCanvasSkia()->getDevice()->accessBitmap(false), @@ -746,7 +711,6 @@ void View::Paint(gfx::Canvas* canvas) { size()); texture_needs_updating_ = false; } -#endif } ThemeProvider* View::GetThemeProvider() const { @@ -1155,22 +1119,6 @@ void View::OnPaintFocusBorder(gfx::Canvas* canvas) { // Accelerated Painting -------------------------------------------------------- -#if !defined(COMPOSITOR_2) -void View::PaintComposite(ui::Compositor* compositor) { - compositor->SaveTransform(); - - // TODO(sad): Push a transform matrix for the offset and bounds of the view? - if (texture_id_) - compositor->DrawTextureWithTransform(texture_id_, GetTransform()); - - for (int i = 0, count = child_count(); i < count; ++i) { - View* child = GetChildViewAt(i); - child->PaintComposite(compositor); - } - - compositor->RestoreTransform(); -} -#else void View::PaintComposite() { if (!IsVisible()) return; @@ -1230,8 +1178,6 @@ void View::PaintToTexture(const gfx::Rect& dirty_region) { void View::OnWillCompositeTexture() { } -#endif - bool View::ShouldPaintToTexture() const { return use_acceleration_when_possible && (paint_to_texture_ || (transform_.get() && transform_->HasChange())) && @@ -1447,11 +1393,6 @@ void View::VisibilityChangedImpl(View* starting_from, bool is_visible) { } void View::BoundsChanged(const gfx::Rect& previous_bounds) { -#if !defined(COMPOSITOR_2) - if (canvas_.get()) - canvas_.reset(gfx::Canvas::CreateCanvas(width(), height(), false)); -#endif - if (IsVisible()) { if (parent_) { // Paint the old bounds. @@ -1616,7 +1557,6 @@ bool View::ConvertPointFromAncestor(const View* ancestor, // Accelerated painting -------------------------------------------------------- -#if defined(COMPOSITOR_2) void View::MarkTextureDirty() { View* owner = this; while (!((owner->transform_.get() && owner->transform_->HasChange()) || @@ -1624,14 +1564,11 @@ void View::MarkTextureDirty() { owner = owner->parent(); owner->texture_needs_updating_ = true; } -#endif void View::ResetTexture() { -#if defined(COMPOSITOR_2) texture_.reset(); for (int i = child_count() - 1; i >= 0; --i) GetChildViewAt(i)->ResetTexture(); -#endif } // Input ----------------------------------------------------------------------- @@ -1876,11 +1813,7 @@ std::string View::PrintViewGraph(bool first) { result.append("\""); if (!parent()) result.append(", shape=box"); -#if defined(COMPOSITOR_2) if (texture_.get()) -#else - if (canvas_.get()) -#endif result.append(", color=green"); result.append("]\n"); diff --git a/views/view.h b/views/view.h index 84fd459efdef..d5df2b98017d 100644 --- a/views/view.h +++ b/views/view.h @@ -1002,12 +1002,6 @@ class View : public AcceleratorTarget { // Accelerated painting ------------------------------------------------------ -#if !defined(COMPOSITOR_2) - - // Performs accelerated painting using the compositor. - virtual void PaintComposite(ui::Compositor* compositor); -#else - // Invoked from SchedulePaintInRect. Invokes SchedulePaintInternal on the // parent. This does not mark the texture as dirty. It's assumed the caller // has done this. You should not need to invoke this, use SchedulePaint or @@ -1030,7 +1024,6 @@ class View : public AcceleratorTarget { // Invoked from |PaintComposite| if this view has a texture and before the // texture is rendered by the compositor. virtual void OnWillCompositeTexture(); -#endif // Returns true if this view should paint using a texture. virtual bool ShouldPaintToTexture() const; @@ -1229,10 +1222,8 @@ class View : public AcceleratorTarget { // Accelerated painting ------------------------------------------------------ -#if defined(COMPOSITOR_2) // Marks the texture this view draws into as dirty. void MarkTextureDirty(); -#endif // Releases the texture of this and recurses through all children. void ResetTexture(); @@ -1384,22 +1375,12 @@ class View : public AcceleratorTarget { // Accelerated painting ------------------------------------------------------ -#if !defined(COMPOSITOR_2) - // Each transformed view will maintain its own canvas. - scoped_ptr canvas_; - - // Texture ID used for accelerated painting. - // TODO(sadrul): This will eventually be replaced by an abstract texture - // object. - ui::TextureID texture_id_; -#else scoped_ptr texture_; // If not empty and Paint() is invoked, the canvas is created with the // specified size. // TODO(sky): this should be passed in. gfx::Rect texture_clip_rect_; -#endif // Is the texture out of date? bool texture_needs_updating_; diff --git a/views/view_unittest.cc b/views/view_unittest.cc index d8800808ba73..7cb8266ff41d 100644 --- a/views/view_unittest.cc +++ b/views/view_unittest.cc @@ -1585,7 +1585,7 @@ class TransformPaintView : public TestView { gfx::Rect scheduled_paint_rect() const { return scheduled_paint_rect_; } // Overridden from View: - virtual void SchedulePaintInRect(const gfx::Rect& rect) { + virtual void SchedulePaintInternal(const gfx::Rect& rect) { gfx::Rect xrect = ConvertRectToParent(rect); scheduled_paint_rect_ = scheduled_paint_rect_.Union(xrect); } diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc index cdc44a89e0bb..ce9cc7a4eb33 100644 --- a/views/widget/root_view.cc +++ b/views/widget/root_view.cc @@ -157,13 +157,11 @@ std::string RootView::GetClassName() const { } void RootView::SchedulePaintInRect(const gfx::Rect& rect) { -#if defined(COMPOSITOR_2) MarkTextureDirty(); SchedulePaintInternal(rect); } void RootView::SchedulePaintInternal(const gfx::Rect& rect) { -#endif gfx::Rect xrect = ConvertRectToParent(rect); gfx::Rect invalid_rect = GetLocalBounds().Intersect(xrect); if (!invalid_rect.IsEmpty()) diff --git a/views/widget/root_view.h b/views/widget/root_view.h index 6bb97952f472..67c9e4016745 100644 --- a/views/widget/root_view.h +++ b/views/widget/root_view.h @@ -102,9 +102,7 @@ class RootView : public View, virtual bool IsVisibleInRootView() const OVERRIDE; virtual std::string GetClassName() const OVERRIDE; virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; -#if defined(COMPOSITOR_2) virtual void SchedulePaintInternal(const gfx::Rect& rect) OVERRIDE; -#endif virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; diff --git a/views/widget/widget.cc b/views/widget/widget.cc index 94eabd565821..8638f7d9d6c2 100644 --- a/views/widget/widget.cc +++ b/views/widget/widget.cc @@ -651,9 +651,6 @@ bool Widget::HasFocusManager() const { } bool Widget::OnNativeWidgetPaintAccelerated(const gfx::Rect& dirty_region) { -#if !defined(COMPOSITOR_2) - return false; -#else if (!compositor_.get()) return false; @@ -662,18 +659,10 @@ bool Widget::OnNativeWidgetPaintAccelerated(const gfx::Rect& dirty_region) { GetRootView()->PaintComposite(); compositor_->NotifyEnd(); return true; -#endif } void Widget::OnNativeWidgetPaint(gfx::Canvas* canvas) { GetRootView()->Paint(canvas); -#if !defined(COMPOSITOR_2) - if (compositor_.get()) { - compositor_->NotifyStart(); - root_view_->PaintComposite(compositor_.get()); - compositor_->NotifyEnd(); - } -#endif } int Widget::GetNonClientComponent(const gfx::Point& point) { -- 2.11.4.GIT