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

Unified Diff: ui/display/chromeos/x11/native_display_delegate_x11.h

Issue 187073002: Refactoring display configuration state to allow generic state objects (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ordering Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ui/display/chromeos/x11/native_display_delegate_x11.h
diff --git a/chromeos/display/native_display_delegate_x11.h b/ui/display/chromeos/x11/native_display_delegate_x11.h
similarity index 60%
rename from chromeos/display/native_display_delegate_x11.h
rename to ui/display/chromeos/x11/native_display_delegate_x11.h
index 9e7393b34587117d3891ca913c7518b585c56338..38e9328e52c383f13f26c90d415c5dae2d7f6e25 100644
--- a/chromeos/display/native_display_delegate_x11.h
+++ b/ui/display/chromeos/x11/native_display_delegate_x11.h
@@ -2,15 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROMEOS_DISPLAY_NATIVE_DISPLAY_DELEGATE_X11_H_
-#define CHROMEOS_DISPLAY_NATIVE_DISPLAY_DELEGATE_X11_H_
+#ifndef UI_DISPLAY_CHROMEOS_NATIVE_DISPLAY_DELEGATE_X11_H_
+#define UI_DISPLAY_CHROMEOS_NATIVE_DISPLAY_DELEGATE_X11_H_
+#include <map>
#include <vector>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "chromeos/display/native_display_delegate.h"
-
+#include "base/event_types.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
+#include "base/observer_list.h"
+#include "ui/display/chromeos/native_display_delegate.h"
+#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/geometry/size.h"
+
+// Forward declarations for Xlib and Xrandr.
+// This is so unused X definitions don't pollute the namespace.
+typedef unsigned long XID;
+typedef XID RROutput;
+typedef XID RRCrtc;
+typedef XID RRMode;
typedef XID Window;
struct _XDisplay;
@@ -20,11 +33,12 @@ typedef _XRROutputInfo XRROutputInfo;
struct _XRRScreenResources;
typedef _XRRScreenResources XRRScreenResources;
-namespace chromeos {
-
+namespace ui {
+class DisplayModeX11;
+class DisplaySnapshotX11;
class NativeDisplayEventDispatcherX11;
-class NativeDisplayDelegateX11 : public NativeDisplayDelegate {
+class DISPLAY_EXPORT NativeDisplayDelegateX11 : public NativeDisplayDelegate {
public:
// Helper class that allows NativeDisplayEventDispatcherX11 and
// NativeDisplayDelegateX11::MessagePumpObserverX11 to interact with this
@@ -39,8 +53,7 @@ class NativeDisplayDelegateX11 : public NativeDisplayDelegate {
// Returns the list of current outputs. This is used to discard duplicate
// events.
- virtual const std::vector<OutputConfigurator::OutputSnapshot>&
- GetCachedOutputs() const = 0;
+ virtual const std::vector<DisplaySnapshot*>& GetCachedOutputs() const = 0;
// Notify |observers_| that a change in configuration has occurred.
virtual void NotifyDisplayObservers() = 0;
@@ -56,21 +69,17 @@ class NativeDisplayDelegateX11 : public NativeDisplayDelegate {
virtual void SyncWithServer() OVERRIDE;
virtual void SetBackgroundColor(uint32 color_argb) OVERRIDE;
virtual void ForceDPMSOn() OVERRIDE;
- virtual std::vector<OutputConfigurator::OutputSnapshot> GetOutputs() OVERRIDE;
- virtual void AddMode(const OutputConfigurator::OutputSnapshot& output,
- RRMode mode) OVERRIDE;
- virtual bool Configure(const OutputConfigurator::OutputSnapshot& output,
- RRMode mode,
- int x,
- int y) OVERRIDE;
- virtual void CreateFrameBuffer(
- int width,
- int height,
- const std::vector<OutputConfigurator::OutputSnapshot>& outputs) OVERRIDE;
- virtual bool GetHDCPState(const OutputConfigurator::OutputSnapshot& output,
- ui::HDCPState* state) OVERRIDE;
- virtual bool SetHDCPState(const OutputConfigurator::OutputSnapshot& output,
- ui::HDCPState state) OVERRIDE;
+ virtual std::vector<DisplaySnapshot*> GetOutputs() OVERRIDE;
+ virtual void AddMode(const DisplaySnapshot& output,
+ const DisplayMode* mode) OVERRIDE;
+ virtual bool Configure(const DisplaySnapshot& output,
+ const DisplayMode* mode,
+ const gfx::Point& origin) OVERRIDE;
+ virtual void CreateFrameBuffer(const gfx::Size& size) OVERRIDE;
+ virtual bool GetHDCPState(const DisplaySnapshot& output,
+ HDCPState* state) OVERRIDE;
+ virtual bool SetHDCPState(const DisplaySnapshot& output,
+ HDCPState state) OVERRIDE;
virtual void AddObserver(NativeDisplayObserver* observer) OVERRIDE;
virtual void RemoveObserver(NativeDisplayObserver* observer) OVERRIDE;
@@ -79,23 +88,20 @@ class NativeDisplayDelegateX11 : public NativeDisplayDelegate {
class HelperDelegateX11;
class MessagePumpObserverX11;
- // Initializes |mode_info| to contain details corresponding to |mode|. Returns
- // true on success.
- bool InitModeInfo(RRMode mode, OutputConfigurator::ModeInfo* mode_info);
+ // Parses all the modes made available by |screen_|.
+ void InitModes();
// Helper method for GetOutputs() that returns an OutputSnapshot struct based
- // on the passed-in information. Further initialization is required (e.g.
- // |selected_mode|, |mirror_mode|, and |touch_device_id|).
- OutputConfigurator::OutputSnapshot InitOutputSnapshot(RROutput id,
- XRROutputInfo* info,
- RRCrtc* last_used_crtc,
- int index);
+ // on the passed-in information.
+ DisplaySnapshotX11* InitDisplaySnapshot(RROutput id,
+ XRROutputInfo* info,
+ RRCrtc* last_used_crtc,
+ int index);
// Destroys unused CRTCs and parks used CRTCs in a way which allows a
// framebuffer resize. This is faster than turning them off, resizing,
// then turning them back on.
- void DestroyUnusedCrtcs(
- const std::vector<OutputConfigurator::OutputSnapshot>& outputs);
+ void DestroyUnusedCrtcs();
bool ConfigureCrtc(RRCrtc crtc, RRMode mode, RROutput output, int x, int y);
@@ -108,10 +114,12 @@ class NativeDisplayDelegateX11 : public NativeDisplayDelegate {
// Initialized when the server is grabbed and freed when it's ungrabbed.
XRRScreenResources* screen_;
+ std::map<RRMode, DisplayModeX11*> modes_;
+
// Every time GetOutputs() is called we cache the updated list of outputs in
// |cached_outputs_| so that we can check for duplicate events rather than
// propagate them.
- std::vector<OutputConfigurator::OutputSnapshot> cached_outputs_;
+ ScopedVector<DisplaySnapshot> cached_outputs_;
scoped_ptr<HelperDelegate> helper_delegate_;
@@ -128,6 +136,6 @@ class NativeDisplayDelegateX11 : public NativeDisplayDelegate {
DISALLOW_COPY_AND_ASSIGN(NativeDisplayDelegateX11);
};
-} // namespace chromeos
+} // namespace ui
-#endif // CHROMEOS_DISPLAY_NATIVE_DISPLAY_DELEGATE_X11_H_
+#endif // UI_DISPLAY_CHROMEOS_NATIVE_DISPLAY_DELEGATE_X11_H_

Powered by Google App Engine
This is Rietveld 408576698