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

Unified Diff: ui/display/fake_display_snapshot.h

Issue 2340383002: Add FakeDisplaySnapshot builder and related changes. (Closed)
Patch Set: Fixes for comments. Created 4 years, 3 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
« no previous file with comments | « ui/display/fake_display_delegate.cc ('k') | ui/display/fake_display_snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/display/fake_display_snapshot.h
diff --git a/ui/display/fake_display_snapshot.h b/ui/display/fake_display_snapshot.h
index f1ed1d6daa43ba1c0be3dda070543a4d1a60629f..1f17bf85e91cd60e01030853588bfccdc4052124 100644
--- a/ui/display/fake_display_snapshot.h
+++ b/ui/display/fake_display_snapshot.h
@@ -9,25 +9,88 @@
#include <memory>
#include <string>
+#include <vector>
#include "base/macros.h"
+#include "ui/display/display.h"
#include "ui/display/display_export.h"
#include "ui/display/types/display_mode.h"
#include "ui/display/types/display_snapshot.h"
+#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/size.h"
namespace display {
// A display snapshot that doesn't correspond to a physical display, used when
// running off device.
-class FakeDisplaySnapshot : public ui::DisplaySnapshot {
+class DISPLAY_EXPORT FakeDisplaySnapshot : public ui::DisplaySnapshot {
public:
- // TODO(kylechar): Add a builder.
+ class Builder {
+ public:
+ Builder();
+ ~Builder();
+
+ // Builds new FakeDisplaySnapshot. At the very minimum you must set id and
+ // native display mode before building or it will fail.
+ std::unique_ptr<FakeDisplaySnapshot> Build();
+
+ Builder& SetId(int64_t id);
+ // Adds display mode with |size| and set as native mode. If a display mode
+ // with |size| already exists then it will be reused.
+ Builder& SetNativeMode(const gfx::Size& size);
+ // Adds display mode with |size| and set as current mode. If a display mode
+ // with |size| already exists then it will be reused.
+ Builder& SetCurrentMode(const gfx::Size& size);
+ // Adds display mode with |size| if it doesn't exist.
+ Builder& AddMode(const gfx::Size& size);
+ Builder& SetOrigin(const gfx::Point& origin);
+ Builder& SetType(ui::DisplayConnectionType type);
+ Builder& SetIsAspectPerservingScaling(bool is_aspect_preserving_scaling);
+ Builder& SetHasOverscan(bool has_overscan);
+ Builder& SetHasColorCorrectionMatrix(bool val);
+ Builder& SetName(const std::string& name);
+ Builder& SetProductId(int64_t product_id);
+ // Sets physical_size so that the screen has the specified DPI using the
+ // native resolution.
+ Builder& SetDPI(int dpi);
+ // Sets physical_size for low DPI display.
+ Builder& SetLowDPI();
+ // Sets physical_size for high DPI display.
+ Builder& SetHighDPI();
+
+ private:
+ // Returns a display mode with |size|. If there is no existing mode, insert
+ // a display mode with |size|.
+ const ui::DisplayMode* AddOrFindDisplayMode(const gfx::Size& size);
+
+ int64_t id_ = Display::kInvalidDisplayID;
+ gfx::Point origin_;
+ float dpi_ = 96.0;
+ ui::DisplayConnectionType type_ = ui::DISPLAY_CONNECTION_TYPE_UNKNOWN;
+ bool is_aspect_preserving_scaling_ = false;
+ bool has_overscan_ = false;
+ bool has_color_correction_matrix_ = false;
+ std::string name_ = "Fake Display";
+ int64_t product_id_ = DisplaySnapshot::kInvalidProductID;
+ std::vector<std::unique_ptr<const ui::DisplayMode>> modes_;
+ const ui::DisplayMode* current_mode_ = nullptr;
+ const ui::DisplayMode* native_mode_ = nullptr;
+
+ DISALLOW_COPY_AND_ASSIGN(Builder);
+ };
FakeDisplaySnapshot(int64_t display_id,
- const gfx::Size& display_size,
+ const gfx::Point& origin,
+ const gfx::Size& physical_size,
ui::DisplayConnectionType type,
- std::string name);
+ bool is_aspect_preserving_scaling,
+ bool has_overscan,
+ bool has_color_correction_matrix,
+ std::string display_name,
+ int64_t product_id,
+ std::vector<std::unique_ptr<const ui::DisplayMode>> modes,
+ const ui::DisplayMode* current_mode,
+ const ui::DisplayMode* native_mode);
~FakeDisplaySnapshot() override;
// DisplaySnapshot:
« no previous file with comments | « ui/display/fake_display_delegate.cc ('k') | ui/display/fake_display_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698