Move DIP translation from ui/aura to ui/compositor.
Layer's coordinate system is now in DIP.
Added support of dynamic density switching.
Removed ENABLE_DIP gyp/macro and added runtime flag "--ui-enable-dip"
BUG=105165, 114666
TEST=enabled monitor test. added new tests to compositor_unittests
Review URL: https://chromiumcodereview.appspot.com/10221028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135888 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h
index e74d553..e523fdc 100644
--- a/ui/compositor/layer.h
+++ b/ui/compositor/layer.h
@@ -36,6 +36,8 @@
// has enabled layers ends up creating a Layer to manage the texture.
// A Layer can also be created without a texture, in which case it renders
// nothing and is simply used as a node in a hierarchy of layers.
+// Coordinate system used in layers is DIP (Density Independent Pixel)
+// coordinates unless explicitly mentioned as pixel coordinates.
//
// NOTE: unlike Views, each Layer does *not* own its children views. If you
// delete a Layer and it has children, the parent of each child layer is set to
@@ -193,6 +195,14 @@
// new paint requests.
void SuppressPaint();
+ // Notifies the layer that the device scale factor has changed.
+ void OnDeviceScaleFactorChanged(float device_scale_factor);
+
+ // Sets if the layer should scale the canvas before passing to
+ // |LayerDelegate::OnLayerPaint|. Set to false if the delegate
+ // handles scaling.
+ void set_scale_canvas(bool scale_canvas) { scale_canvas_ = scale_canvas; }
+
// Sometimes the Layer is being updated by something other than SetCanvas
// (e.g. the GPU process on UI_COMPOSITOR_IMAGE_TRANSPORT).
bool layer_updated_externally() const { return layer_updated_externally_; }
@@ -202,6 +212,8 @@
WebKit::WebLayer web_layer() { return web_layer_; }
+ float device_scale_factor() const { return device_scale_factor_; }
+
private:
struct LayerProperties {
public:
@@ -276,8 +288,8 @@
// If true the layer is always up to date.
bool layer_updated_externally_;
- // Union of damaged rects to be used when compositor is ready to
- // paint the content.
+ // Union of damaged rects, in pixel coordinates, to be used when
+ // compositor is ready to paint the content.
SkRegion damaged_region_;
float opacity_;
@@ -293,6 +305,13 @@
bool web_layer_is_accelerated_;
bool show_debug_borders_;
+ // If true, the layer scales the canvas using device scale factor
+ // before passing to LayerDelegate::OnLayerPaint.
+ bool scale_canvas_;
+
+ // A cached copy of |Compositor::device_scale_factor()|.
+ float device_scale_factor_;
+
DISALLOW_COPY_AND_ASSIGN(Layer);
};