Migrate ui::Transform to gfx::Transform
It is more appropriate for Transform class to belong with its fellow geometry classes in the gfx namespace. Review URL: https://chromiumcodereview.appspot.com/11145005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161809 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
ash
launcher
magnifier
rotator
system
wm
chrome/browser
ui
aura
base
compositor
layer.cclayer.hlayer_animation_delegate.hlayer_animation_element.cclayer_animation_element.hlayer_animation_element_unittest.cclayer_animation_sequence_unittest.cclayer_animator.cclayer_animator.hlayer_unittest.cc
test
gfx
canvas.cccanvas.hinterpolated_transform.ccinterpolated_transform.hinterpolated_transform_unittest.cctransform.cctransform.htransform_unittest.cctransform_util.cctransform_util.htransform_util_unittest.cc
views
@ -86,7 +86,7 @@ void AppListButton::StopLoadingAnimation() {
|
||||
settings.SetTransitionDuration(
|
||||
base::TimeDelta::FromMilliseconds(kAnimationDurationInMs));
|
||||
layer()->SetOpacity(1.0f);
|
||||
layer()->SetTransform(ui::Transform());
|
||||
layer()->SetTransform(gfx::Transform());
|
||||
}
|
||||
|
||||
bool AppListButton::OnMousePressed(const ui::MouseEvent& event) {
|
||||
|
@ -28,13 +28,13 @@ const int kButtonHoverSize = 28;
|
||||
|
||||
const int kBackgroundOffset = (48 - kButtonHoverSize) / 2;
|
||||
|
||||
void RotateCounterclockwise(ui::Transform* transform) {
|
||||
void RotateCounterclockwise(gfx::Transform* transform) {
|
||||
transform->matrix().set3x3(0, -1, 0,
|
||||
1, 0, 0,
|
||||
0, 0, 1);
|
||||
}
|
||||
|
||||
void RotateClockwise(ui::Transform* transform) {
|
||||
void RotateClockwise(gfx::Transform* transform) {
|
||||
transform->matrix().set3x3( 0, 1, 0,
|
||||
-1, 0, 0,
|
||||
0, 0, 1);
|
||||
@ -107,7 +107,7 @@ void OverflowButton::OnPaint(gfx::Canvas* canvas) {
|
||||
if (height() < kButtonHoverSize)
|
||||
return;
|
||||
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
|
||||
switch (alignment_) {
|
||||
case SHELF_ALIGNMENT_BOTTOM:
|
||||
|
@ -196,7 +196,7 @@ bool MagnificationControllerImpl::RedrawDIP(const gfx::Point& position_in_dip,
|
||||
scale_ = scale;
|
||||
|
||||
// Creates transform matrix.
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
// Flips the signs intentionally to convert them from the position of the
|
||||
// magnification window.
|
||||
transform.ConcatTranslate(-origin_.x(), -origin_.y());
|
||||
|
@ -45,7 +45,7 @@ void ScreenRotation::OnStart(ui::LayerAnimationDelegate* delegate) {
|
||||
if (degrees_ == 0)
|
||||
return;
|
||||
|
||||
const ui::Transform& current_transform =
|
||||
const gfx::Transform& current_transform =
|
||||
delegate->GetTransformForAnimation();
|
||||
const gfx::Rect& bounds = delegate->GetBoundsForAnimation();
|
||||
|
||||
|
@ -167,7 +167,7 @@ void SystemTrayBubble::UpdateView(
|
||||
settings.AddObserver(new AnimationObserverDeleteLayer(layer));
|
||||
settings.SetTransitionDuration(swipe_duration);
|
||||
settings.SetTweenType(ui::Tween::EASE_OUT);
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetTranslateX(layer->bounds().width());
|
||||
layer->SetTransform(transform);
|
||||
}
|
||||
@ -220,7 +220,7 @@ void SystemTrayBubble::UpdateView(
|
||||
if (bubble_type == BUBBLE_TYPE_DETAILED) {
|
||||
ui::Layer* new_layer = bubble_view_->layer();
|
||||
gfx::Rect bounds = new_layer->bounds();
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetTranslateX(bounds.width());
|
||||
new_layer->SetTransform(transform);
|
||||
{
|
||||
@ -228,7 +228,7 @@ void SystemTrayBubble::UpdateView(
|
||||
settings.AddObserver(new AnimationObserverDeleteLayer(layer));
|
||||
settings.SetTransitionDuration(swipe_duration);
|
||||
settings.SetTweenType(ui::Tween::EASE_OUT);
|
||||
new_layer->SetTransform(ui::Transform());
|
||||
new_layer->SetTransform(gfx::Transform());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ void TrayItemView::ChildPreferredSizeChanged(views::View* child) {
|
||||
}
|
||||
|
||||
void TrayItemView::AnimationProgressed(const ui::Animation* animation) {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetScale(animation->GetCurrentValue(),
|
||||
animation->GetCurrentValue());
|
||||
transform.ConcatTranslate(0, animation->CurrentValueBetween(
|
||||
|
@ -245,7 +245,7 @@ ui::EventResult WebNotificationView::OnGestureEvent(
|
||||
// The scroll-update events include the incremental scroll amount.
|
||||
gesture_scroll_amount_ += event.details().scroll_x();
|
||||
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetTranslateX(gesture_scroll_amount_);
|
||||
layer()->SetTransform(transform);
|
||||
layer()->SetOpacity(
|
||||
@ -298,7 +298,7 @@ void WebNotificationView::RestoreVisualState() {
|
||||
ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator());
|
||||
settings.SetTransitionDuration(
|
||||
base::TimeDelta::FromMilliseconds(kSwipeRestoreDurationMS));
|
||||
layer()->SetTransform(ui::Transform());
|
||||
layer()->SetTransform(gfx::Transform());
|
||||
layer()->SetOpacity(1.f);
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ void WebNotificationView::SlideOutAndClose(SlideDirection direction) {
|
||||
base::TimeDelta::FromMilliseconds(swipe_out_duration));
|
||||
settings.AddObserver(this);
|
||||
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetTranslateX(direction == SLIDE_LEFT ? -width() : width());
|
||||
layer()->SetTransform(transform);
|
||||
layer()->SetOpacity(0.f);
|
||||
|
@ -200,7 +200,7 @@ class LongPressAffordanceHandler::LongPressAffordanceView
|
||||
GetPreferredSize().height() / 2);
|
||||
canvas->Save();
|
||||
|
||||
ui::Transform scale;
|
||||
gfx::Transform scale;
|
||||
scale.SetScale(current_scale_, current_scale_);
|
||||
// We want to scale from the center.
|
||||
canvas->Translate(gfx::Point(center.x(), center.y()));
|
||||
|
@ -105,7 +105,7 @@ void ImageGrid::SetSize(const gfx::Size& size) {
|
||||
|
||||
if (top_layer_.get()) {
|
||||
if (center_width > 0) {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetScaleX(
|
||||
static_cast<float>(center_width) / top_layer_->bounds().width());
|
||||
transform.ConcatTranslate(left, 0);
|
||||
@ -115,7 +115,7 @@ void ImageGrid::SetSize(const gfx::Size& size) {
|
||||
}
|
||||
if (bottom_layer_.get()) {
|
||||
if (center_width > 0) {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetScaleX(
|
||||
static_cast<float>(center_width) / bottom_layer_->bounds().width());
|
||||
transform.ConcatTranslate(
|
||||
@ -126,7 +126,7 @@ void ImageGrid::SetSize(const gfx::Size& size) {
|
||||
}
|
||||
if (left_layer_.get()) {
|
||||
if (center_height > 0) {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetScaleY(
|
||||
(static_cast<float>(center_height) / left_layer_->bounds().height()));
|
||||
transform.ConcatTranslate(0, top);
|
||||
@ -136,7 +136,7 @@ void ImageGrid::SetSize(const gfx::Size& size) {
|
||||
}
|
||||
if (right_layer_.get()) {
|
||||
if (center_height > 0) {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetScaleY(
|
||||
static_cast<float>(center_height) / right_layer_->bounds().height());
|
||||
transform.ConcatTranslate(
|
||||
@ -155,7 +155,7 @@ void ImageGrid::SetSize(const gfx::Size& size) {
|
||||
top_left_layer_.get());
|
||||
}
|
||||
if (top_right_layer_.get()) {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetTranslateX(size.width() - top_right_layer_->bounds().width());
|
||||
top_right_layer_->SetTransform(transform);
|
||||
top_right_painter_->SetClipRect(
|
||||
@ -166,7 +166,7 @@ void ImageGrid::SetSize(const gfx::Size& size) {
|
||||
top_right_layer_.get());
|
||||
}
|
||||
if (bottom_left_layer_.get()) {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetTranslateY(
|
||||
size.height() - bottom_left_layer_->bounds().height());
|
||||
bottom_left_layer_->SetTransform(transform);
|
||||
@ -178,7 +178,7 @@ void ImageGrid::SetSize(const gfx::Size& size) {
|
||||
bottom_left_layer_.get());
|
||||
}
|
||||
if (bottom_right_layer_.get()) {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetTranslate(
|
||||
size.width() - bottom_right_layer_->bounds().width(),
|
||||
size.height() - bottom_right_layer_->bounds().height());
|
||||
@ -194,7 +194,7 @@ void ImageGrid::SetSize(const gfx::Size& size) {
|
||||
|
||||
if (center_layer_.get()) {
|
||||
if (center_width > 0 && center_height > 0) {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetScale(center_width / center_layer_->bounds().width(),
|
||||
center_height / center_layer_->bounds().height());
|
||||
transform.ConcatTranslate(left, top);
|
||||
|
@ -38,9 +38,9 @@ const float kSlowCloseSizeRatio = 0.95f;
|
||||
|
||||
// Returns the transform that should be applied to containers for the slow-close
|
||||
// animation.
|
||||
ui::Transform GetSlowCloseTransform() {
|
||||
gfx::Transform GetSlowCloseTransform() {
|
||||
gfx::Size root_size = Shell::GetPrimaryRootWindow()->bounds().size();
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetScale(kSlowCloseSizeRatio, kSlowCloseSizeRatio);
|
||||
transform.ConcatTranslate(
|
||||
floor(0.5 * (1.0 - kSlowCloseSizeRatio) * root_size.width() + 0.5),
|
||||
@ -50,9 +50,9 @@ ui::Transform GetSlowCloseTransform() {
|
||||
|
||||
// Returns the transform that should be applied to containers for the fast-close
|
||||
// animation.
|
||||
ui::Transform GetFastCloseTransform() {
|
||||
gfx::Transform GetFastCloseTransform() {
|
||||
gfx::Size root_size = Shell::GetPrimaryRootWindow()->bounds().size();
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetScale(0.0, 0.0);
|
||||
transform.ConcatTranslate(floor(0.5 * root_size.width() + 0.5),
|
||||
floor(0.5 * root_size.height() + 0.5));
|
||||
@ -79,7 +79,7 @@ void StartUndoSlowCloseAnimationForWindow(aura::Window* window) {
|
||||
animator->StartAnimation(
|
||||
new ui::LayerAnimationSequence(
|
||||
ui::LayerAnimationElement::CreateTransformElement(
|
||||
ui::Transform(),
|
||||
gfx::Transform(),
|
||||
base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs))));
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ void HideWindow(aura::Window* window) {
|
||||
// Restores |window| to its original position and scale and full opacity
|
||||
// instantaneously.
|
||||
void RestoreWindow(aura::Window* window) {
|
||||
window->layer()->SetTransform(ui::Transform());
|
||||
window->layer()->SetTransform(gfx::Transform());
|
||||
window->layer()->SetOpacity(1.0);
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ bool SessionStateAnimator::TestApi::ContainersAreAnimated(
|
||||
return false;
|
||||
break;
|
||||
case ANIMATION_UNDO_SLOW_CLOSE:
|
||||
if (layer->GetTargetTransform() != ui::Transform())
|
||||
if (layer->GetTargetTransform() != gfx::Transform())
|
||||
return false;
|
||||
break;
|
||||
case ANIMATION_FAST_CLOSE:
|
||||
@ -162,7 +162,7 @@ bool SessionStateAnimator::TestApi::ContainersAreAnimated(
|
||||
return false;
|
||||
break;
|
||||
case ANIMATION_RESTORE:
|
||||
if (layer->opacity() < 0.9999 || layer->transform() != ui::Transform())
|
||||
if (layer->opacity() < 0.9999 || layer->transform() != gfx::Transform())
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
|
@ -236,8 +236,8 @@ class WorkspaceHidingWindowAnimationObserver
|
||||
// its visibility to true, and its transform from |start_transform| to
|
||||
// |end_transform|.
|
||||
void AnimateShowWindowCommon(aura::Window* window,
|
||||
const ui::Transform& start_transform,
|
||||
const ui::Transform& end_transform) {
|
||||
const gfx::Transform& start_transform,
|
||||
const gfx::Transform& end_transform) {
|
||||
window->layer()->set_delegate(window);
|
||||
window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
|
||||
window->layer()->SetTransform(start_transform);
|
||||
@ -258,7 +258,7 @@ void AnimateShowWindowCommon(aura::Window* window,
|
||||
// Hides a window using an animation, animating its opacity from 1.f to 0.f,
|
||||
// its visibility to false, and its transform to |end_transform|.
|
||||
void AnimateHideWindowCommon(aura::Window* window,
|
||||
const ui::Transform& end_transform) {
|
||||
const gfx::Transform& end_transform) {
|
||||
window->layer()->set_delegate(NULL);
|
||||
|
||||
// Property sets within this scope will be implicitly animated.
|
||||
@ -276,18 +276,18 @@ void AnimateHideWindowCommon(aura::Window* window,
|
||||
|
||||
// Show/Hide windows using a shrink animation.
|
||||
void AnimateShowWindow_Drop(aura::Window* window) {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.ConcatScale(kWindowAnimation_ScaleFactor,
|
||||
kWindowAnimation_ScaleFactor);
|
||||
gfx::Rect bounds = window->bounds();
|
||||
transform.ConcatTranslate(
|
||||
kWindowAnimation_TranslateFactor * bounds.width(),
|
||||
kWindowAnimation_TranslateFactor * bounds.height());
|
||||
AnimateShowWindowCommon(window, transform, ui::Transform());
|
||||
AnimateShowWindowCommon(window, transform, gfx::Transform());
|
||||
}
|
||||
|
||||
void AnimateHideWindow_Drop(aura::Window* window) {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.ConcatScale(kWindowAnimation_ScaleFactor,
|
||||
kWindowAnimation_ScaleFactor);
|
||||
gfx::Rect bounds = window->bounds();
|
||||
@ -299,14 +299,14 @@ void AnimateHideWindow_Drop(aura::Window* window) {
|
||||
|
||||
// Show/Hide windows using a vertical Glenimation.
|
||||
void AnimateShowWindow_Vertical(aura::Window* window) {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.ConcatTranslate(0, window->GetProperty(
|
||||
kWindowVisibilityAnimationVerticalPositionKey));
|
||||
AnimateShowWindowCommon(window, transform, ui::Transform());
|
||||
AnimateShowWindowCommon(window, transform, gfx::Transform());
|
||||
}
|
||||
|
||||
void AnimateHideWindow_Vertical(aura::Window* window) {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.ConcatTranslate(0, window->GetProperty(
|
||||
kWindowVisibilityAnimationVerticalPositionKey));
|
||||
AnimateHideWindowCommon(window, transform);
|
||||
@ -314,16 +314,17 @@ void AnimateHideWindow_Vertical(aura::Window* window) {
|
||||
|
||||
// Show/Hide windows using a fade.
|
||||
void AnimateShowWindow_Fade(aura::Window* window) {
|
||||
AnimateShowWindowCommon(window, ui::Transform(), ui::Transform());
|
||||
AnimateShowWindowCommon(window, gfx::Transform(), gfx::Transform());
|
||||
}
|
||||
|
||||
void AnimateHideWindow_Fade(aura::Window* window) {
|
||||
AnimateHideWindowCommon(window, ui::Transform());
|
||||
AnimateHideWindowCommon(window, gfx::Transform());
|
||||
}
|
||||
|
||||
// Builds the transform used when switching workspaces for the specified
|
||||
// window.
|
||||
ui::Transform BuildWorkspaceSwitchTransform(aura::Window* window, float scale) {
|
||||
gfx::Transform BuildWorkspaceSwitchTransform(aura::Window* window,
|
||||
float scale) {
|
||||
// Animations for transitioning workspaces scale all windows. To give the
|
||||
// effect of scaling from the center of the screen the windows are translated.
|
||||
gfx::Rect bounds = window->bounds();
|
||||
@ -336,7 +337,7 @@ ui::Transform BuildWorkspaceSwitchTransform(aura::Window* window, float scale) {
|
||||
float initial_y =
|
||||
(static_cast<float>(bounds.y()) - mid_y) * scale + mid_y;
|
||||
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.ConcatTranslate(
|
||||
initial_x - static_cast<float>(bounds.x()),
|
||||
initial_y - static_cast<float>(bounds.y()));
|
||||
@ -345,7 +346,7 @@ ui::Transform BuildWorkspaceSwitchTransform(aura::Window* window, float scale) {
|
||||
}
|
||||
|
||||
void AnimateShowWindow_Workspace(aura::Window* window) {
|
||||
ui::Transform transform(
|
||||
gfx::Transform transform(
|
||||
BuildWorkspaceSwitchTransform(window, kWorkspaceScale));
|
||||
// When we call SetOpacity here, if a hide sequence is already running,
|
||||
// the default animation preemption strategy fast forwards the hide sequence
|
||||
@ -360,7 +361,7 @@ void AnimateShowWindow_Workspace(aura::Window* window) {
|
||||
// Property sets within this scope will be implicitly animated.
|
||||
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
|
||||
|
||||
window->layer()->SetTransform(ui::Transform());
|
||||
window->layer()->SetTransform(gfx::Transform());
|
||||
// Opacity animates only during the first half of the animation.
|
||||
settings.SetTransitionDuration(settings.GetTransitionDuration() / 2);
|
||||
window->layer()->SetOpacity(1.0f);
|
||||
@ -368,10 +369,10 @@ void AnimateShowWindow_Workspace(aura::Window* window) {
|
||||
}
|
||||
|
||||
void AnimateHideWindow_Workspace(aura::Window* window) {
|
||||
ui::Transform transform(
|
||||
gfx::Transform transform(
|
||||
BuildWorkspaceSwitchTransform(window, kWorkspaceScale));
|
||||
window->layer()->SetOpacity(1.0f);
|
||||
window->layer()->SetTransform(ui::Transform());
|
||||
window->layer()->SetTransform(gfx::Transform());
|
||||
|
||||
// Opacity animates from 1 to 0 only over the second half of the animation. To
|
||||
// get this functionality two animations are schedule for opacity, the first
|
||||
@ -710,7 +711,7 @@ TimeDelta CrossFadeImpl(aura::Window* window,
|
||||
settings.AddObserver(new internal::CrossFadeObserver(window, old_layer));
|
||||
settings.SetTransitionDuration(duration);
|
||||
settings.SetTweenType(tween_type);
|
||||
ui::Transform out_transform;
|
||||
gfx::Transform out_transform;
|
||||
float scale_x = static_cast<float>(new_bounds.width()) /
|
||||
static_cast<float>(old_bounds.width());
|
||||
float scale_y = static_cast<float>(new_bounds.height()) /
|
||||
@ -730,7 +731,7 @@ TimeDelta CrossFadeImpl(aura::Window* window,
|
||||
|
||||
// Set the new layer's current transform, such that the user sees a scaled
|
||||
// version of the window with the original bounds at the original position.
|
||||
ui::Transform in_transform;
|
||||
gfx::Transform in_transform;
|
||||
const float scale_x = static_cast<float>(old_bounds.width()) /
|
||||
static_cast<float>(new_bounds.width());
|
||||
const float scale_y = static_cast<float>(old_bounds.height()) /
|
||||
@ -750,7 +751,7 @@ TimeDelta CrossFadeImpl(aura::Window* window,
|
||||
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
|
||||
settings.SetTransitionDuration(duration);
|
||||
settings.SetTweenType(tween_type);
|
||||
window->layer()->SetTransform(ui::Transform());
|
||||
window->layer()->SetTransform(gfx::Transform());
|
||||
if (!old_on_top) {
|
||||
// New layer is on top, fade it in.
|
||||
window->layer()->SetOpacity(1.f);
|
||||
|
@ -169,13 +169,13 @@ TEST_F(WindowAnimationsTest, CrossFadeToBounds) {
|
||||
// Original layer stays opaque and stretches to new size.
|
||||
EXPECT_EQ(1.0f, old_layer->GetTargetOpacity());
|
||||
EXPECT_EQ("5,10 320x240", old_layer->bounds().ToString());
|
||||
ui::Transform grow_transform;
|
||||
gfx::Transform grow_transform;
|
||||
grow_transform.ConcatScale(640.f / 320.f, 480.f / 240.f);
|
||||
grow_transform.ConcatTranslate(-5.f, -10.f);
|
||||
EXPECT_EQ(grow_transform, old_layer->GetTargetTransform());
|
||||
// New layer animates in to the identity transform.
|
||||
EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
|
||||
EXPECT_EQ(ui::Transform(), window->layer()->GetTargetTransform());
|
||||
EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform());
|
||||
|
||||
// Run the animations to completion.
|
||||
static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step(
|
||||
@ -191,13 +191,13 @@ TEST_F(WindowAnimationsTest, CrossFadeToBounds) {
|
||||
// Original layer fades out and stretches down to new size.
|
||||
EXPECT_EQ(0.0f, old_layer->GetTargetOpacity());
|
||||
EXPECT_EQ("0,0 640x480", old_layer->bounds().ToString());
|
||||
ui::Transform shrink_transform;
|
||||
gfx::Transform shrink_transform;
|
||||
shrink_transform.ConcatScale(320.f / 640.f, 240.f / 480.f);
|
||||
shrink_transform.ConcatTranslate(5.f, 10.f);
|
||||
EXPECT_EQ(shrink_transform, old_layer->GetTargetTransform());
|
||||
// New layer animates in to the identity transform.
|
||||
EXPECT_EQ(1.0f, window->layer()->GetTargetOpacity());
|
||||
EXPECT_EQ(ui::Transform(), window->layer()->GetTargetTransform());
|
||||
EXPECT_EQ(gfx::Transform(), window->layer()->GetTargetTransform());
|
||||
|
||||
static_cast<ui::AnimationContainerElement*>(old_layer->GetAnimator())->Step(
|
||||
base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
|
||||
|
@ -469,7 +469,7 @@ TEST_F(WindowManagerTest, MAYBE_TransformActivate) {
|
||||
gfx::Point()).bounds().ToString());
|
||||
|
||||
// Rotate it clock-wise 90 degrees.
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetRotate(90.0f);
|
||||
transform.ConcatTranslate(size.width(), 0);
|
||||
root_window->SetTransform(transform);
|
||||
|
@ -33,7 +33,7 @@ enum WorkspaceScaleType {
|
||||
void ApplyWorkspaceScale(ui::Layer* layer, WorkspaceScaleType type) {
|
||||
const float scale = type == WORKSPACE_SCALE_ABOVE ? kWorkspaceScaleAbove :
|
||||
kWorkspaceScaleBelow;
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.ConcatScale(scale, scale);
|
||||
transform.ConcatTranslate(
|
||||
-layer->bounds().width() * (scale - 1.0f) / 2,
|
||||
@ -70,7 +70,7 @@ void ShowWorkspace(aura::Window* window,
|
||||
if (!details.animate || CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
ash::switches::kAshWindowAnimationsDisabled)) {
|
||||
window->layer()->SetOpacity(1.0f);
|
||||
window->layer()->SetTransform(ui::Transform());
|
||||
window->layer()->SetTransform(gfx::Transform());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ void ShowWorkspace(aura::Window* window,
|
||||
details.direction == WORKSPACE_ANIMATE_UP ?
|
||||
WORKSPACE_SCALE_BELOW : WORKSPACE_SCALE_ABOVE);
|
||||
} else {
|
||||
window->layer()->SetTransform(ui::Transform());
|
||||
window->layer()->SetTransform(gfx::Transform());
|
||||
}
|
||||
|
||||
// In order for pause to work we need to stop animations.
|
||||
@ -102,14 +102,14 @@ void ShowWorkspace(aura::Window* window,
|
||||
|
||||
settings.SetTweenType(kWorkspaceTweenType);
|
||||
settings.SetTransitionDuration(DurationForWorkspaceShowOrHide(details));
|
||||
window->layer()->SetTransform(ui::Transform());
|
||||
window->layer()->SetTransform(gfx::Transform());
|
||||
window->layer()->SetOpacity(1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void HideWorkspace(aura::Window* window,
|
||||
const WorkspaceAnimationDetails& details) {
|
||||
window->layer()->SetTransform(ui::Transform());
|
||||
window->layer()->SetTransform(gfx::Transform());
|
||||
window->layer()->SetOpacity(1.0f);
|
||||
window->layer()->GetAnimator()->StopAnimating();
|
||||
|
||||
@ -138,7 +138,7 @@ void HideWorkspace(aura::Window* window,
|
||||
details.direction == WORKSPACE_ANIMATE_UP ?
|
||||
WORKSPACE_SCALE_ABOVE : WORKSPACE_SCALE_BELOW);
|
||||
} else {
|
||||
window->layer()->SetTransform(ui::Transform());
|
||||
window->layer()->SetTransform(gfx::Transform());
|
||||
}
|
||||
|
||||
// NOTE: Hide() must be before SetOpacity(), else
|
||||
@ -154,7 +154,7 @@ void HideWorkspace(aura::Window* window,
|
||||
// version.
|
||||
settings.SetPreemptionStrategy(ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
|
||||
settings.SetTransitionDuration(base::TimeDelta());
|
||||
window->layer()->SetTransform(ui::Transform());
|
||||
window->layer()->SetTransform(gfx::Transform());
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@ -348,7 +348,7 @@ void BaseLoginDisplayHost::StartAnimation() {
|
||||
ash::internal::kShellWindowId_DesktopBackgroundContainer)->
|
||||
layer();
|
||||
|
||||
ui::Transform background_transform;
|
||||
gfx::Transform background_transform;
|
||||
background_transform.SetScale(kBackgroundScale, kBackgroundScale);
|
||||
background_transform.SetTranslateX(kBackgroundTranslate);
|
||||
background_transform.SetTranslateY(kBackgroundTranslate);
|
||||
@ -369,7 +369,7 @@ void BaseLoginDisplayHost::StartAnimation() {
|
||||
settings.SetTransitionDuration(
|
||||
base::TimeDelta::FromMilliseconds(kBackgroundTransitionDurationMs));
|
||||
settings.SetTweenType(ui::Tween::EASE_OUT);
|
||||
background_layer->SetTransform(ui::Transform());
|
||||
background_layer->SetTransform(gfx::Transform());
|
||||
}
|
||||
|
||||
// Browser windows layer opacity and transform animation.
|
||||
@ -385,7 +385,7 @@ void BaseLoginDisplayHost::StartAnimation() {
|
||||
|
||||
// Set the initial opacity and transform.
|
||||
if (do_browser_transform_animation) {
|
||||
ui::Transform browser_transform;
|
||||
gfx::Transform browser_transform;
|
||||
browser_transform.SetScale(kBrowserScale, kBrowserScale);
|
||||
browser_transform.SetTranslateX(kBrowserTranslate);
|
||||
browser_transform.SetTranslateY(kBrowserTranslate);
|
||||
@ -419,7 +419,7 @@ void BaseLoginDisplayHost::StartAnimation() {
|
||||
|
||||
if (do_browser_transform_animation) {
|
||||
settings.SetTweenType(ui::Tween::EASE_OUT);
|
||||
default_container_layer->SetTransform(ui::Transform());
|
||||
default_container_layer->SetTransform(gfx::Transform());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ void IssueAdviceView::AnimationProgressed(const ui::Animation* animation) {
|
||||
details_view_->AnimateToState(animation->GetCurrentValue());
|
||||
|
||||
if (arrow_view_) {
|
||||
ui::Transform rotate;
|
||||
gfx::Transform rotate;
|
||||
if (animation->GetCurrentValue() != 0.0) {
|
||||
rotate.SetTranslate(-arrow_view_->width() / 2.0,
|
||||
-arrow_view_->height() / 2.0);
|
||||
|
@ -469,7 +469,7 @@ const RootWindow* RootWindow::GetRootWindow() const {
|
||||
return this;
|
||||
}
|
||||
|
||||
void RootWindow::SetTransform(const ui::Transform& transform) {
|
||||
void RootWindow::SetTransform(const gfx::Transform& transform) {
|
||||
Window::SetTransform(transform);
|
||||
|
||||
// If the layer is not animating, then we need to update the host size
|
||||
@ -835,7 +835,7 @@ bool RootWindow::OnHostMouseEvent(ui::MouseEvent* event) {
|
||||
bool RootWindow::OnHostScrollEvent(ui::ScrollEvent* event) {
|
||||
DispatchHeldMouseMove();
|
||||
float scale = ui::GetDeviceScaleFactor(layer());
|
||||
ui::Transform transform = layer()->transform();
|
||||
gfx::Transform transform = layer()->transform();
|
||||
transform.ConcatScale(scale, scale);
|
||||
event->UpdateForRootTransform(transform);
|
||||
|
||||
@ -879,7 +879,7 @@ bool RootWindow::OnHostTouchEvent(ui::TouchEvent* event) {
|
||||
break;
|
||||
}
|
||||
float scale = ui::GetDeviceScaleFactor(layer());
|
||||
ui::Transform transform = layer()->transform();
|
||||
gfx::Transform transform = layer()->transform();
|
||||
transform.ConcatScale(scale, scale);
|
||||
event->UpdateForRootTransform(transform);
|
||||
bool handled = false;
|
||||
@ -970,7 +970,7 @@ RootWindow* RootWindow::AsRootWindow() {
|
||||
|
||||
bool RootWindow::DispatchMouseEventImpl(ui::MouseEvent* event) {
|
||||
float scale = ui::GetDeviceScaleFactor(layer());
|
||||
ui::Transform transform = layer()->transform();
|
||||
gfx::Transform transform = layer()->transform();
|
||||
transform.ConcatScale(scale, scale);
|
||||
event->UpdateForRootTransform(transform);
|
||||
Window* target = mouse_pressed_handler_ ?
|
||||
@ -1047,7 +1047,7 @@ void RootWindow::SynthesizeMouseMoveEvent() {
|
||||
#if !defined(OS_WIN)
|
||||
// Temporarily disabled for windows. See crbug.com/112222.
|
||||
gfx::Point3f point(GetLastMouseLocationInRoot());
|
||||
ui::Transform transform = layer()->transform();
|
||||
gfx::Transform transform = layer()->transform();
|
||||
float scale = ui::GetDeviceScaleFactor(layer());
|
||||
transform.ConcatScale(scale, scale);
|
||||
transform.TransformPoint(point);
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
namespace gfx {
|
||||
class Size;
|
||||
class Transform;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
@ -39,7 +40,6 @@ class LayerAnimationSequence;
|
||||
class MouseEvent;
|
||||
class ScrollEvent;
|
||||
class TouchEvent;
|
||||
class Transform;
|
||||
class ViewProp;
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
|
||||
// Overridden from Window:
|
||||
virtual RootWindow* GetRootWindow() OVERRIDE;
|
||||
virtual const RootWindow* GetRootWindow() const OVERRIDE;
|
||||
virtual void SetTransform(const ui::Transform& transform) OVERRIDE;
|
||||
virtual void SetTransform(const gfx::Transform& transform) OVERRIDE;
|
||||
|
||||
// Overridden from ui::EventTarget:
|
||||
virtual ui::EventTarget* GetParentTarget() OVERRIDE;
|
||||
|
@ -268,7 +268,7 @@ gfx::Rect Window::GetBoundsInScreen() const {
|
||||
return bounds;
|
||||
}
|
||||
|
||||
void Window::SetTransform(const ui::Transform& transform) {
|
||||
void Window::SetTransform(const gfx::Transform& transform) {
|
||||
RootWindow* root_window = GetRootWindow();
|
||||
bool contained_mouse = IsVisible() && root_window &&
|
||||
ContainsPointInRoot(root_window->GetLastMouseLocationInRoot());
|
||||
|
@ -29,12 +29,12 @@
|
||||
|
||||
namespace gfx {
|
||||
class Display;
|
||||
class Transform;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
class Layer;
|
||||
class Texture;
|
||||
class Transform;
|
||||
}
|
||||
|
||||
namespace aura {
|
||||
@ -145,7 +145,7 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
|
||||
// |aura::client::ScreenPositionClient| interface.
|
||||
gfx::Rect GetBoundsInScreen() const;
|
||||
|
||||
virtual void SetTransform(const ui::Transform& transform);
|
||||
virtual void SetTransform(const gfx::Transform& transform);
|
||||
|
||||
// Assigns a LayoutManager to size and place child windows.
|
||||
// The Window takes ownership of the LayoutManager.
|
||||
|
@ -358,7 +358,7 @@ TEST_F(WindowTest, ContainsMouse) {
|
||||
// Test Window::ConvertPointToWindow() with transform to root_window.
|
||||
TEST_F(WindowTest, MoveCursorToWithTransformRootWindow) {
|
||||
RootWindow* root = root_window();
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.ConcatScale(2, 5);
|
||||
transform.ConcatRotate(90.0f);
|
||||
transform.ConcatTranslate(100, 100);
|
||||
@ -377,28 +377,28 @@ TEST_F(WindowTest, MoveCursorToWithTransformWindow) {
|
||||
scoped_ptr<Window> w1(
|
||||
CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), NULL));
|
||||
|
||||
ui::Transform transform1;
|
||||
gfx::Transform transform1;
|
||||
transform1.ConcatScale(2, 2);
|
||||
w1->SetTransform(transform1);
|
||||
w1->MoveCursorTo(gfx::Point(10, 10));
|
||||
EXPECT_EQ("30,30",
|
||||
gfx::Screen::GetScreenFor(w1.get())->GetCursorScreenPoint().ToString());
|
||||
|
||||
ui::Transform transform2;
|
||||
gfx::Transform transform2;
|
||||
transform2.ConcatTranslate(-10, 20);
|
||||
w1->SetTransform(transform2);
|
||||
w1->MoveCursorTo(gfx::Point(10, 10));
|
||||
EXPECT_EQ("10,40",
|
||||
gfx::Screen::GetScreenFor(w1.get())->GetCursorScreenPoint().ToString());
|
||||
|
||||
ui::Transform transform3;
|
||||
gfx::Transform transform3;
|
||||
transform3.ConcatRotate(90.0f);
|
||||
w1->SetTransform(transform3);
|
||||
w1->MoveCursorTo(gfx::Point(5, 5));
|
||||
EXPECT_EQ("5,15",
|
||||
gfx::Screen::GetScreenFor(w1.get())->GetCursorScreenPoint().ToString());
|
||||
|
||||
ui::Transform transform4;
|
||||
gfx::Transform transform4;
|
||||
transform4.ConcatScale(2, 5);
|
||||
transform4.ConcatRotate(90.0f);
|
||||
transform4.ConcatTranslate(100, 100);
|
||||
@ -421,7 +421,7 @@ TEST_F(WindowTest, MoveCursorToWithComplexTransform) {
|
||||
CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get()));
|
||||
|
||||
RootWindow* root = root_window();
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.ConcatScale(0.3f, 0.5f);
|
||||
transform.ConcatRotate(10.0f);
|
||||
transform.ConcatTranslate(10, 20);
|
||||
@ -1338,7 +1338,7 @@ TEST_F(WindowTest, Transform) {
|
||||
gfx::Point()).bounds());
|
||||
|
||||
// Rotate it clock-wise 90 degrees.
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetRotate(90.0f);
|
||||
transform.ConcatTranslate(size.height(), 0);
|
||||
root_window()->SetTransform(transform);
|
||||
@ -1366,7 +1366,7 @@ TEST_F(WindowTest, TransformGesture) {
|
||||
gfx::Rect(0, 0, 20, 20), NULL));
|
||||
|
||||
// Rotate the root-window clock-wise 90 degrees.
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetRotate(90.0f);
|
||||
transform.ConcatTranslate(size.height(), 0);
|
||||
root_window()->SetTransform(transform);
|
||||
@ -1997,14 +1997,14 @@ TEST_F(WindowTest, MouseEventsOnWindowChange) {
|
||||
EXPECT_EQ("1 1 0", d11.GetMouseMotionCountsAndReset());
|
||||
|
||||
// Transform: move d11 by 100 100.
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.ConcatTranslate(100, 100);
|
||||
w11->SetTransform(transform);
|
||||
RunAllPendingInMessageLoop();
|
||||
EXPECT_EQ("1 1 0", d1.GetMouseMotionCountsAndReset());
|
||||
EXPECT_EQ("0 0 1", d11.GetMouseMotionCountsAndReset());
|
||||
|
||||
w11->SetTransform(ui::Transform());
|
||||
w11->SetTransform(gfx::Transform());
|
||||
RunAllPendingInMessageLoop();
|
||||
EXPECT_EQ("0 0 1", d1.GetMouseMotionCountsAndReset());
|
||||
EXPECT_EQ("1 1 0", d11.GetMouseMotionCountsAndReset());
|
||||
|
@ -96,15 +96,15 @@ gfx::Rect Tween::ValueBetween(double value,
|
||||
}
|
||||
|
||||
// static
|
||||
Transform Tween::ValueBetween(double value,
|
||||
const Transform& start_transform,
|
||||
const Transform& end_transform) {
|
||||
gfx::Transform Tween::ValueBetween(double value,
|
||||
const gfx::Transform& start_transform,
|
||||
const gfx::Transform& end_transform) {
|
||||
if (value >= 1.0)
|
||||
return end_transform;
|
||||
if (value <= 0.0)
|
||||
return start_transform;
|
||||
|
||||
Transform to_return;
|
||||
gfx::Transform to_return;
|
||||
gfx::Point start_translation, end_translation;
|
||||
float start_rotation, end_rotation;
|
||||
gfx::Point3f start_scale, end_scale;
|
||||
|
@ -37,9 +37,9 @@ class UI_EXPORT Tween {
|
||||
static gfx::Rect ValueBetween(double value,
|
||||
const gfx::Rect& start_bounds,
|
||||
const gfx::Rect& target_bounds);
|
||||
static Transform ValueBetween(double value,
|
||||
const Transform& start_transform,
|
||||
const Transform& target_transform);
|
||||
static gfx::Transform ValueBetween(double value,
|
||||
const gfx::Transform& start_transform,
|
||||
const gfx::Transform& target_transform);
|
||||
|
||||
private:
|
||||
Tween();
|
||||
|
@ -143,7 +143,8 @@ LocatedEvent::LocatedEvent(EventType type,
|
||||
system_location_(0, 0) {
|
||||
}
|
||||
|
||||
void LocatedEvent::UpdateForRootTransform(const Transform& root_transform) {
|
||||
void LocatedEvent::UpdateForRootTransform(
|
||||
const gfx::Transform& root_transform) {
|
||||
// Transform has to be done at root level.
|
||||
DCHECK_EQ(root_location_.x(), location_.x());
|
||||
DCHECK_EQ(root_location_.y(), location_.y());
|
||||
@ -314,7 +315,7 @@ void TouchEvent::CalibrateLocation(const gfx::Size& from, const gfx::Size& to) {
|
||||
root_location_ = CalibratePoint(root_location_, from, to);
|
||||
}
|
||||
|
||||
void TouchEvent::UpdateForRootTransform(const Transform& root_transform) {
|
||||
void TouchEvent::UpdateForRootTransform(const gfx::Transform& root_transform) {
|
||||
LocatedEvent::UpdateForRootTransform(root_transform);
|
||||
gfx::Point3f scale;
|
||||
InterpolatedTransform::FactorTRS(root_transform, NULL, NULL, &scale);
|
||||
|
@ -17,8 +17,11 @@
|
||||
#include "ui/base/ui_export.h"
|
||||
#include "ui/gfx/point.h"
|
||||
|
||||
namespace ui {
|
||||
namespace gfx {
|
||||
class Transform;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
class EventTarget;
|
||||
|
||||
class UI_EXPORT Event {
|
||||
@ -220,7 +223,7 @@ class UI_EXPORT LocatedEvent : public Event {
|
||||
|
||||
// Applies |root_transform| to the event.
|
||||
// This is applied to both |location_| and |root_location_|.
|
||||
virtual void UpdateForRootTransform(const Transform& root_transform);
|
||||
virtual void UpdateForRootTransform(const gfx::Transform& root_transform);
|
||||
|
||||
template <class T> void ConvertLocationToTarget(T* source, T* target) {
|
||||
if (target && target != source)
|
||||
@ -426,7 +429,8 @@ class UI_EXPORT TouchEvent : public LocatedEvent {
|
||||
void set_radius_y(const float r) { radius_y_ = r; }
|
||||
|
||||
// Overridden from LocatedEvent.
|
||||
virtual void UpdateForRootTransform(const Transform& root_transform) OVERRIDE;
|
||||
virtual void UpdateForRootTransform(
|
||||
const gfx::Transform& root_transform) OVERRIDE;
|
||||
|
||||
protected:
|
||||
void set_radius(float radius_x, float radius_y) {
|
||||
|
@ -185,11 +185,11 @@ LayerAnimator* Layer::GetAnimator() {
|
||||
return animator_.get();
|
||||
}
|
||||
|
||||
void Layer::SetTransform(const ui::Transform& transform) {
|
||||
void Layer::SetTransform(const gfx::Transform& transform) {
|
||||
GetAnimator()->SetTransform(transform);
|
||||
}
|
||||
|
||||
Transform Layer::GetTargetTransform() const {
|
||||
gfx::Transform Layer::GetTargetTransform() const {
|
||||
if (animator_.get() && animator_->IsAnimatingProperty(
|
||||
LayerAnimationElement::TRANSFORM)) {
|
||||
return animator_->GetTargetTransform();
|
||||
@ -559,7 +559,7 @@ void Layer::StackRelativeTo(Layer* child, Layer* other, bool above) {
|
||||
|
||||
bool Layer::ConvertPointForAncestor(const Layer* ancestor,
|
||||
gfx::Point* point) const {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
bool result = GetTransformRelativeTo(ancestor, &transform);
|
||||
gfx::Point3f p(*point);
|
||||
transform.TransformPoint(p);
|
||||
@ -569,7 +569,7 @@ bool Layer::ConvertPointForAncestor(const Layer* ancestor,
|
||||
|
||||
bool Layer::ConvertPointFromAncestor(const Layer* ancestor,
|
||||
gfx::Point* point) const {
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
bool result = GetTransformRelativeTo(ancestor, &transform);
|
||||
gfx::Point3f p(*point);
|
||||
transform.TransformPointReverse(p);
|
||||
@ -578,7 +578,7 @@ bool Layer::ConvertPointFromAncestor(const Layer* ancestor,
|
||||
}
|
||||
|
||||
bool Layer::GetTransformRelativeTo(const Layer* ancestor,
|
||||
ui::Transform* transform) const {
|
||||
gfx::Transform* transform) const {
|
||||
const Layer* p = this;
|
||||
for (; p && p != ancestor; p = p->parent()) {
|
||||
if (p->transform().HasChange())
|
||||
@ -615,7 +615,7 @@ void Layer::SetBoundsImmediately(const gfx::Rect& bounds) {
|
||||
}
|
||||
}
|
||||
|
||||
void Layer::SetTransformImmediately(const ui::Transform& transform) {
|
||||
void Layer::SetTransformImmediately(const gfx::Transform& transform) {
|
||||
transform_ = transform;
|
||||
|
||||
RecomputeTransform();
|
||||
@ -662,7 +662,7 @@ void Layer::SetBoundsFromAnimation(const gfx::Rect& bounds) {
|
||||
SetBoundsImmediately(bounds);
|
||||
}
|
||||
|
||||
void Layer::SetTransformFromAnimation(const Transform& transform) {
|
||||
void Layer::SetTransformFromAnimation(const gfx::Transform& transform) {
|
||||
SetTransformImmediately(transform);
|
||||
}
|
||||
|
||||
@ -694,7 +694,7 @@ const gfx::Rect& Layer::GetBoundsForAnimation() const {
|
||||
return bounds();
|
||||
}
|
||||
|
||||
const Transform& Layer::GetTransformForAnimation() const {
|
||||
const gfx::Transform& Layer::GetTransformForAnimation() const {
|
||||
return transform();
|
||||
}
|
||||
|
||||
@ -741,12 +741,12 @@ void Layer::CreateWebLayer() {
|
||||
}
|
||||
|
||||
void Layer::RecomputeTransform() {
|
||||
ui::Transform scale_translate;
|
||||
gfx::Transform scale_translate;
|
||||
scale_translate.matrix().set3x3(device_scale_factor_, 0, 0,
|
||||
0, device_scale_factor_, 0,
|
||||
0, 0, 1);
|
||||
// Start with the inverse matrix of above.
|
||||
Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0,
|
||||
0, 1.0f / device_scale_factor_, 0,
|
||||
0, 0, 1);
|
||||
|
@ -108,12 +108,12 @@ class COMPOSITOR_EXPORT Layer
|
||||
LayerAnimator* GetAnimator();
|
||||
|
||||
// The transform, relative to the parent.
|
||||
void SetTransform(const Transform& transform);
|
||||
const Transform& transform() const { return transform_; }
|
||||
void SetTransform(const gfx::Transform& transform);
|
||||
const gfx::Transform& transform() const { return transform_; }
|
||||
|
||||
// Return the target transform if animator is running, or the current
|
||||
// transform otherwise.
|
||||
Transform GetTargetTransform() const;
|
||||
gfx::Transform GetTargetTransform() const;
|
||||
|
||||
// The bounds, relative to the parent.
|
||||
void SetBounds(const gfx::Rect& bounds);
|
||||
@ -287,7 +287,7 @@ class COMPOSITOR_EXPORT Layer
|
||||
bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const;
|
||||
|
||||
bool GetTransformRelativeTo(const Layer* ancestor,
|
||||
Transform* transform) const;
|
||||
gfx::Transform* transform) const;
|
||||
|
||||
// The only externally updated layers are ones that get their pixels from
|
||||
// WebKit and WebKit does not produce valid alpha values. All other layers
|
||||
@ -297,7 +297,7 @@ class COMPOSITOR_EXPORT Layer
|
||||
// Following are invoked from the animation or if no animation exists to
|
||||
// update the values immediately.
|
||||
void SetBoundsImmediately(const gfx::Rect& bounds);
|
||||
void SetTransformImmediately(const ui::Transform& transform);
|
||||
void SetTransformImmediately(const gfx::Transform& transform);
|
||||
void SetOpacityImmediately(float opacity);
|
||||
void SetVisibilityImmediately(bool visibility);
|
||||
void SetBrightnessImmediately(float brightness);
|
||||
@ -306,7 +306,8 @@ class COMPOSITOR_EXPORT Layer
|
||||
|
||||
// Implementation of LayerAnimatorDelegate
|
||||
virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) OVERRIDE;
|
||||
virtual void SetTransformFromAnimation(const Transform& transform) OVERRIDE;
|
||||
virtual void SetTransformFromAnimation(
|
||||
const gfx::Transform& transform) OVERRIDE;
|
||||
virtual void SetOpacityFromAnimation(float opacity) OVERRIDE;
|
||||
virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE;
|
||||
virtual void SetBrightnessFromAnimation(float brightness) OVERRIDE;
|
||||
@ -314,7 +315,7 @@ class COMPOSITOR_EXPORT Layer
|
||||
virtual void SetColorFromAnimation(SkColor color) OVERRIDE;
|
||||
virtual void ScheduleDrawForAnimation() OVERRIDE;
|
||||
virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE;
|
||||
virtual const Transform& GetTransformForAnimation() const OVERRIDE;
|
||||
virtual const gfx::Transform& GetTransformForAnimation() const OVERRIDE;
|
||||
virtual float GetOpacityForAnimation() const OVERRIDE;
|
||||
virtual bool GetVisibilityForAnimation() const OVERRIDE;
|
||||
virtual float GetBrightnessForAnimation() const OVERRIDE;
|
||||
@ -340,7 +341,7 @@ class COMPOSITOR_EXPORT Layer
|
||||
// This layer's children, in bottom-to-top stacking order.
|
||||
std::vector<Layer*> children_;
|
||||
|
||||
ui::Transform transform_;
|
||||
gfx::Transform transform_;
|
||||
|
||||
gfx::Rect bounds_;
|
||||
|
||||
|
@ -16,7 +16,7 @@ namespace ui {
|
||||
class COMPOSITOR_EXPORT LayerAnimationDelegate {
|
||||
public:
|
||||
virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) = 0;
|
||||
virtual void SetTransformFromAnimation(const Transform& transform) = 0;
|
||||
virtual void SetTransformFromAnimation(const gfx::Transform& transform) = 0;
|
||||
virtual void SetOpacityFromAnimation(float opacity) = 0;
|
||||
virtual void SetVisibilityFromAnimation(bool visibility) = 0;
|
||||
virtual void SetBrightnessFromAnimation(float brightness) = 0;
|
||||
@ -24,7 +24,7 @@ class COMPOSITOR_EXPORT LayerAnimationDelegate {
|
||||
virtual void SetColorFromAnimation(SkColor color) = 0;
|
||||
virtual void ScheduleDrawForAnimation() = 0;
|
||||
virtual const gfx::Rect& GetBoundsForAnimation() const = 0;
|
||||
virtual const Transform& GetTransformForAnimation() const = 0;
|
||||
virtual const gfx::Transform& GetTransformForAnimation() const = 0;
|
||||
virtual float GetOpacityForAnimation() const = 0;
|
||||
virtual bool GetVisibilityForAnimation() const = 0;
|
||||
virtual float GetBrightnessForAnimation() const = 0;
|
||||
|
@ -38,7 +38,7 @@ class Pause : public LayerAnimationElement {
|
||||
|
||||
class TransformTransition : public LayerAnimationElement {
|
||||
public:
|
||||
TransformTransition(const Transform& target, base::TimeDelta duration)
|
||||
TransformTransition(const gfx::Transform& target, base::TimeDelta duration)
|
||||
: LayerAnimationElement(GetProperties(), duration),
|
||||
target_(target) {
|
||||
}
|
||||
@ -68,8 +68,8 @@ class TransformTransition : public LayerAnimationElement {
|
||||
return properties;
|
||||
}
|
||||
|
||||
Transform start_;
|
||||
const Transform target_;
|
||||
gfx::Transform start_;
|
||||
const gfx::Transform target_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TransformTransition);
|
||||
};
|
||||
@ -382,7 +382,8 @@ LayerAnimationElement::TargetValue::TargetValue()
|
||||
LayerAnimationElement::TargetValue::TargetValue(
|
||||
const LayerAnimationDelegate* delegate)
|
||||
: bounds(delegate ? delegate->GetBoundsForAnimation() : gfx::Rect()),
|
||||
transform(delegate ? delegate->GetTransformForAnimation() : Transform()),
|
||||
transform(delegate ?
|
||||
delegate->GetTransformForAnimation() : gfx::Transform()),
|
||||
opacity(delegate ? delegate->GetOpacityForAnimation() : 0.0f),
|
||||
visibility(delegate ? delegate->GetVisibilityForAnimation() : false),
|
||||
brightness(delegate ? delegate->GetBrightnessForAnimation() : 0.0f),
|
||||
@ -436,7 +437,7 @@ base::TimeDelta LayerAnimationElement::GetEffectiveDuration(
|
||||
|
||||
// static
|
||||
LayerAnimationElement* LayerAnimationElement::CreateTransformElement(
|
||||
const Transform& transform,
|
||||
const gfx::Transform& transform,
|
||||
base::TimeDelta duration) {
|
||||
return new TransformTransition(transform, duration);
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ namespace ui {
|
||||
|
||||
class InterpolatedTransform;
|
||||
class LayerAnimationDelegate;
|
||||
class Transform;
|
||||
|
||||
// LayerAnimationElements represent one segment of an animation between two
|
||||
// keyframes. They know how to update a LayerAnimationDelegate given a value
|
||||
@ -41,7 +40,7 @@ class COMPOSITOR_EXPORT LayerAnimationElement {
|
||||
explicit TargetValue(const LayerAnimationDelegate* delegate);
|
||||
|
||||
gfx::Rect bounds;
|
||||
Transform transform;
|
||||
gfx::Transform transform;
|
||||
float opacity;
|
||||
bool visibility;
|
||||
float brightness;
|
||||
@ -58,7 +57,7 @@ class COMPOSITOR_EXPORT LayerAnimationElement {
|
||||
// Creates an element that transitions to the given transform. The caller owns
|
||||
// the return value.
|
||||
static LayerAnimationElement* CreateTransformElement(
|
||||
const Transform& transform,
|
||||
const gfx::Transform& transform,
|
||||
base::TimeDelta duration);
|
||||
|
||||
// Creates an element that transitions to another in a way determined by an
|
||||
|
@ -23,7 +23,7 @@ namespace {
|
||||
// that the element can be reused after it completes.
|
||||
TEST(LayerAnimationElementTest, TransformElement) {
|
||||
TestLayerAnimationDelegate delegate;
|
||||
Transform start_transform, target_transform, middle_transform;
|
||||
gfx::Transform start_transform, target_transform, middle_transform;
|
||||
start_transform.SetRotate(-90);
|
||||
target_transform.SetRotate(90);
|
||||
base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
|
||||
|
@ -77,7 +77,7 @@ TEST(LayerAnimationSequenceTest, MultipleElement) {
|
||||
sequence.AddElement(
|
||||
LayerAnimationElement::CreatePauseElement(properties, delta));
|
||||
|
||||
Transform start_transform, target_transform, middle_transform;
|
||||
gfx::Transform start_transform, target_transform, middle_transform;
|
||||
start_transform.SetRotate(-90);
|
||||
target_transform.SetRotate(90);
|
||||
|
||||
|
@ -73,7 +73,7 @@ LayerAnimator* LayerAnimator::CreateImplicitAnimator() {
|
||||
return new LayerAnimator(kDefaultTransitionDuration);
|
||||
}
|
||||
|
||||
void LayerAnimator::SetTransform(const Transform& transform) {
|
||||
void LayerAnimator::SetTransform(const gfx::Transform& transform) {
|
||||
base::TimeDelta duration = GetTransitionDuration();
|
||||
scoped_ptr<LayerAnimationElement> element(
|
||||
LayerAnimationElement::CreateTransformElement(transform, duration));
|
||||
@ -81,7 +81,7 @@ void LayerAnimator::SetTransform(const Transform& transform) {
|
||||
StartAnimation(new LayerAnimationSequence(element.release()));
|
||||
}
|
||||
|
||||
Transform LayerAnimator::GetTargetTransform() const {
|
||||
gfx::Transform LayerAnimator::GetTargetTransform() const {
|
||||
LayerAnimationElement::TargetValue target(delegate());
|
||||
GetTargetValue(&target);
|
||||
return target.transform;
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
namespace gfx {
|
||||
class Rect;
|
||||
class Transform;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
@ -29,7 +30,6 @@ class LayerAnimationSequence;
|
||||
class LayerAnimationDelegate;
|
||||
class LayerAnimationObserver;
|
||||
class ScopedLayerAnimationSettings;
|
||||
class Transform;
|
||||
|
||||
// When a property of layer needs to be changed it is set by way of
|
||||
// LayerAnimator. This enables LayerAnimator to animate property changes.
|
||||
@ -60,8 +60,8 @@ class COMPOSITOR_EXPORT LayerAnimator
|
||||
static LayerAnimator* CreateImplicitAnimator();
|
||||
|
||||
// Sets the transform on the delegate. May cause an implicit animation.
|
||||
virtual void SetTransform(const Transform& transform);
|
||||
Transform GetTargetTransform() const;
|
||||
virtual void SetTransform(const gfx::Transform& transform);
|
||||
gfx::Transform GetTargetTransform() const;
|
||||
|
||||
// Sets the bounds on the delegate. May cause an implicit animation.
|
||||
virtual void SetBounds(const gfx::Rect& bounds);
|
||||
|
@ -909,7 +909,7 @@ TEST_F(LayerWithRealCompositorTest, MAYBE_CompositorObservers) {
|
||||
|
||||
// Setting the transform of a layer should alert the observers.
|
||||
observer.Reset();
|
||||
Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.ConcatTranslate(-200, -200);
|
||||
transform.ConcatRotate(90.0f);
|
||||
transform.ConcatTranslate(200, 200);
|
||||
|
@ -32,7 +32,7 @@ void TestLayerAnimationDelegate::SetBoundsFromAnimation(
|
||||
}
|
||||
|
||||
void TestLayerAnimationDelegate::SetTransformFromAnimation(
|
||||
const Transform& transform) {
|
||||
const gfx::Transform& transform) {
|
||||
transform_ = transform;
|
||||
}
|
||||
|
||||
@ -63,7 +63,8 @@ const gfx::Rect& TestLayerAnimationDelegate::GetBoundsForAnimation() const {
|
||||
return bounds_;
|
||||
}
|
||||
|
||||
const Transform& TestLayerAnimationDelegate::GetTransformForAnimation() const {
|
||||
const gfx::Transform&
|
||||
TestLayerAnimationDelegate::GetTransformForAnimation() const {
|
||||
return transform_;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,8 @@ class TestLayerAnimationDelegate : public LayerAnimationDelegate {
|
||||
|
||||
// Implementation of LayerAnimationDelegate
|
||||
virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) OVERRIDE;
|
||||
virtual void SetTransformFromAnimation(const Transform& transform) OVERRIDE;
|
||||
virtual void SetTransformFromAnimation(
|
||||
const gfx::Transform& transform) OVERRIDE;
|
||||
virtual void SetOpacityFromAnimation(float opacity) OVERRIDE;
|
||||
virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE;
|
||||
virtual void SetBrightnessFromAnimation(float brightness) OVERRIDE;
|
||||
@ -28,7 +29,7 @@ class TestLayerAnimationDelegate : public LayerAnimationDelegate {
|
||||
virtual void SetColorFromAnimation(SkColor color) OVERRIDE;
|
||||
virtual void ScheduleDrawForAnimation() OVERRIDE;
|
||||
virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE;
|
||||
virtual const Transform& GetTransformForAnimation() const OVERRIDE;
|
||||
virtual const gfx::Transform& GetTransformForAnimation() const OVERRIDE;
|
||||
virtual float GetOpacityForAnimation() const OVERRIDE;
|
||||
virtual bool GetVisibilityForAnimation() const OVERRIDE;
|
||||
virtual float GetBrightnessForAnimation() const OVERRIDE;
|
||||
@ -37,7 +38,7 @@ class TestLayerAnimationDelegate : public LayerAnimationDelegate {
|
||||
|
||||
private:
|
||||
gfx::Rect bounds_;
|
||||
Transform transform_;
|
||||
gfx::Transform transform_;
|
||||
float opacity_;
|
||||
bool visibility_;
|
||||
float brightness_;
|
||||
|
@ -10,7 +10,8 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
void CheckApproximatelyEqual(const Transform& lhs, const Transform& rhs) {
|
||||
void CheckApproximatelyEqual(const gfx::Transform& lhs,
|
||||
const gfx::Transform& rhs) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
EXPECT_FLOAT_EQ(lhs.matrix().get(i, j), rhs.matrix().get(i, j));
|
||||
|
@ -7,13 +7,13 @@
|
||||
|
||||
namespace gfx {
|
||||
class Rect;
|
||||
class Transform;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
|
||||
class Transform;
|
||||
|
||||
void CheckApproximatelyEqual(const Transform& lhs, const Transform& rhs);
|
||||
void CheckApproximatelyEqual(const gfx::Transform& lhs,
|
||||
const gfx::Transform& rhs);
|
||||
void CheckApproximatelyEqual(const gfx::Rect& lhs, const gfx::Rect& rhs);
|
||||
|
||||
} // namespace ui
|
||||
|
@ -489,7 +489,7 @@ void Canvas::EndPlatformPaint() {
|
||||
skia::EndPlatformPaint(canvas_);
|
||||
}
|
||||
|
||||
void Canvas::Transform(const ui::Transform& transform) {
|
||||
void Canvas::Transform(const gfx::Transform& transform) {
|
||||
canvas_->concat(transform.matrix());
|
||||
}
|
||||
|
||||
|
@ -17,16 +17,13 @@
|
||||
|
||||
class SkBitmap;
|
||||
|
||||
namespace ui {
|
||||
class Transform;
|
||||
}
|
||||
|
||||
namespace gfx {
|
||||
|
||||
class Rect;
|
||||
class Font;
|
||||
class Point;
|
||||
class Size;
|
||||
class Transform;
|
||||
|
||||
// Canvas is a SkCanvas wrapper that provides a number of methods for
|
||||
// common operations used throughout an application built using ui/gfx.
|
||||
@ -362,7 +359,7 @@ class UI_EXPORT Canvas {
|
||||
void EndPlatformPaint();
|
||||
|
||||
// Apply transformation on the canvas.
|
||||
void Transform(const ui::Transform& transform);
|
||||
void Transform(const gfx::Transform& transform);
|
||||
|
||||
// Draws the given string with the beginning and/or the end using a fade
|
||||
// gradient. When truncating the head
|
||||
|
@ -28,13 +28,13 @@ bool IsMultipleOfNinetyDegrees(float degrees)
|
||||
// *rotation is set to be the appropriate sanitized rotation matrix. That is,
|
||||
// the rotation matrix corresponding to |degrees| which has entries that are all
|
||||
// either 0, 1 or -1.
|
||||
bool MassageRotationIfMultipleOfNinetyDegrees(ui::Transform* rotation,
|
||||
bool MassageRotationIfMultipleOfNinetyDegrees(gfx::Transform* rotation,
|
||||
float degrees)
|
||||
{
|
||||
if (!IsMultipleOfNinetyDegrees(degrees) || !rotation)
|
||||
return false;
|
||||
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
SkMatrix44& m = transform.matrix();
|
||||
float degrees_by_ninety = degrees / 90.0f;
|
||||
|
||||
@ -88,10 +88,10 @@ InterpolatedTransform::InterpolatedTransform(float start_time,
|
||||
|
||||
InterpolatedTransform::~InterpolatedTransform() {}
|
||||
|
||||
ui::Transform InterpolatedTransform::Interpolate(float t) const {
|
||||
gfx::Transform InterpolatedTransform::Interpolate(float t) const {
|
||||
if (reversed_)
|
||||
t = 1.0f - t;
|
||||
ui::Transform result = InterpolateButDoNotCompose(t);
|
||||
gfx::Transform result = InterpolateButDoNotCompose(t);
|
||||
if (child_.get()) {
|
||||
result.ConcatTransform(child_->Interpolate(t));
|
||||
}
|
||||
@ -102,7 +102,7 @@ void InterpolatedTransform::SetChild(InterpolatedTransform* child) {
|
||||
child_.reset(child);
|
||||
}
|
||||
|
||||
bool InterpolatedTransform::FactorTRS(const ui::Transform& transform,
|
||||
bool InterpolatedTransform::FactorTRS(const gfx::Transform& transform,
|
||||
gfx::Point* translation,
|
||||
float* rotation,
|
||||
gfx::Point3f* scale) {
|
||||
@ -203,8 +203,8 @@ InterpolatedRotation::InterpolatedRotation(float start_degrees,
|
||||
|
||||
InterpolatedRotation::~InterpolatedRotation() {}
|
||||
|
||||
ui::Transform InterpolatedRotation::InterpolateButDoNotCompose(float t) const {
|
||||
ui::Transform result;
|
||||
gfx::Transform InterpolatedRotation::InterpolateButDoNotCompose(float t) const {
|
||||
gfx::Transform result;
|
||||
float interpolated_degrees = ValueBetween(t, start_degrees_, end_degrees_);
|
||||
result.SetRotate(interpolated_degrees);
|
||||
if (t == 0.0f || t == 1.0f)
|
||||
@ -240,9 +240,9 @@ InterpolatedAxisAngleRotation::InterpolatedAxisAngleRotation(
|
||||
|
||||
InterpolatedAxisAngleRotation::~InterpolatedAxisAngleRotation() {}
|
||||
|
||||
ui::Transform
|
||||
gfx::Transform
|
||||
InterpolatedAxisAngleRotation::InterpolateButDoNotCompose(float t) const {
|
||||
ui::Transform result;
|
||||
gfx::Transform result;
|
||||
result.SetRotateAbout(axis_, ValueBetween(t, start_degrees_, end_degrees_));
|
||||
return result;
|
||||
}
|
||||
@ -282,8 +282,8 @@ InterpolatedScale::InterpolatedScale(const gfx::Point3f& start_scale,
|
||||
|
||||
InterpolatedScale::~InterpolatedScale() {}
|
||||
|
||||
ui::Transform InterpolatedScale::InterpolateButDoNotCompose(float t) const {
|
||||
ui::Transform result;
|
||||
gfx::Transform InterpolatedScale::InterpolateButDoNotCompose(float t) const {
|
||||
gfx::Transform result;
|
||||
float scale_x = ValueBetween(t, start_scale_.x(), end_scale_.x());
|
||||
float scale_y = ValueBetween(t, start_scale_.y(), end_scale_.y());
|
||||
// TODO(vollick) 3d xforms.
|
||||
@ -313,9 +313,9 @@ InterpolatedTranslation::InterpolatedTranslation(const gfx::Point& start_pos,
|
||||
|
||||
InterpolatedTranslation::~InterpolatedTranslation() {}
|
||||
|
||||
ui::Transform
|
||||
gfx::Transform
|
||||
InterpolatedTranslation::InterpolateButDoNotCompose(float t) const {
|
||||
ui::Transform result;
|
||||
gfx::Transform result;
|
||||
// TODO(vollick) 3d xforms.
|
||||
result.SetTranslate(ValueBetween(t, start_pos_.x(), end_pos_.x()),
|
||||
ValueBetween(t, start_pos_.y(), end_pos_.y()));
|
||||
@ -327,12 +327,12 @@ InterpolatedTranslation::InterpolateButDoNotCompose(float t) const {
|
||||
//
|
||||
|
||||
InterpolatedConstantTransform::InterpolatedConstantTransform(
|
||||
const ui::Transform& transform)
|
||||
const gfx::Transform& transform)
|
||||
: InterpolatedTransform(),
|
||||
transform_(transform) {
|
||||
}
|
||||
|
||||
ui::Transform
|
||||
gfx::Transform
|
||||
InterpolatedConstantTransform::InterpolateButDoNotCompose(float t) const {
|
||||
return transform_;
|
||||
}
|
||||
@ -361,18 +361,18 @@ InterpolatedTransformAboutPivot::InterpolatedTransformAboutPivot(
|
||||
|
||||
InterpolatedTransformAboutPivot::~InterpolatedTransformAboutPivot() {}
|
||||
|
||||
ui::Transform
|
||||
gfx::Transform
|
||||
InterpolatedTransformAboutPivot::InterpolateButDoNotCompose(float t) const {
|
||||
if (transform_.get()) {
|
||||
return transform_->Interpolate(t);
|
||||
}
|
||||
return Transform();
|
||||
return gfx::Transform();
|
||||
}
|
||||
|
||||
void InterpolatedTransformAboutPivot::Init(const gfx::Point& pivot,
|
||||
InterpolatedTransform* xform) {
|
||||
ui::Transform to_pivot;
|
||||
ui::Transform from_pivot;
|
||||
gfx::Transform to_pivot;
|
||||
gfx::Transform from_pivot;
|
||||
to_pivot.SetTranslate(-pivot.x(), -pivot.y());
|
||||
from_pivot.SetTranslate(pivot.x(), pivot.y());
|
||||
|
||||
@ -387,15 +387,15 @@ void InterpolatedTransformAboutPivot::Init(const gfx::Point& pivot,
|
||||
}
|
||||
|
||||
InterpolatedTRSTransform::InterpolatedTRSTransform(
|
||||
const ui::Transform& start_transform,
|
||||
const ui::Transform& end_transform)
|
||||
const gfx::Transform& start_transform,
|
||||
const gfx::Transform& end_transform)
|
||||
: InterpolatedTransform() {
|
||||
Init(start_transform, end_transform);
|
||||
}
|
||||
|
||||
InterpolatedTRSTransform::InterpolatedTRSTransform(
|
||||
const ui::Transform& start_transform,
|
||||
const ui::Transform& end_transform,
|
||||
const gfx::Transform& start_transform,
|
||||
const gfx::Transform& end_transform,
|
||||
float start_time,
|
||||
float end_time)
|
||||
: InterpolatedTransform() {
|
||||
@ -404,16 +404,16 @@ InterpolatedTRSTransform::InterpolatedTRSTransform(
|
||||
|
||||
InterpolatedTRSTransform::~InterpolatedTRSTransform() {}
|
||||
|
||||
ui::Transform
|
||||
gfx::Transform
|
||||
InterpolatedTRSTransform::InterpolateButDoNotCompose(float t) const {
|
||||
if (transform_.get()) {
|
||||
return transform_->Interpolate(t);
|
||||
}
|
||||
return Transform();
|
||||
return gfx::Transform();
|
||||
}
|
||||
|
||||
void InterpolatedTRSTransform::Init(const Transform& start_transform,
|
||||
const Transform& end_transform) {
|
||||
void InterpolatedTRSTransform::Init(const gfx::Transform& start_transform,
|
||||
const gfx::Transform& end_transform) {
|
||||
gfx::Point start_translation, end_translation;
|
||||
gfx::Point3f start_scale, end_scale;
|
||||
float start_degrees, end_degrees;
|
||||
|
@ -33,7 +33,7 @@ class UI_EXPORT InterpolatedTransform {
|
||||
virtual ~InterpolatedTransform();
|
||||
|
||||
// Returns the interpolated transform at time t. Note: not virtual.
|
||||
ui::Transform Interpolate(float t) const;
|
||||
gfx::Transform Interpolate(float t) const;
|
||||
|
||||
// The Intepolate ultimately returns the product of our transform at time t
|
||||
// and our child's transform at time t (if we have one).
|
||||
@ -46,14 +46,14 @@ class UI_EXPORT InterpolatedTransform {
|
||||
void SetReversed(bool reversed) { reversed_ = reversed; }
|
||||
bool Reversed() const { return reversed_; }
|
||||
|
||||
static bool FactorTRS(const ui::Transform& transform,
|
||||
static bool FactorTRS(const gfx::Transform& transform,
|
||||
gfx::Point* translation,
|
||||
float* rotation,
|
||||
gfx::Point3f* scale);
|
||||
|
||||
protected:
|
||||
// Calculates the interpolated transform without considering our child.
|
||||
virtual ui::Transform InterpolateButDoNotCompose(float t) const = 0;
|
||||
virtual gfx::Transform InterpolateButDoNotCompose(float t) const = 0;
|
||||
|
||||
// If time in (start_time_, end_time_], this function linearly interpolates
|
||||
// between start_value and end_value. More precisely it returns
|
||||
@ -97,7 +97,7 @@ class UI_EXPORT InterpolatedRotation : public InterpolatedTransform {
|
||||
virtual ~InterpolatedRotation();
|
||||
|
||||
protected:
|
||||
virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
|
||||
virtual gfx::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
|
||||
|
||||
private:
|
||||
const float start_degrees_;
|
||||
@ -125,7 +125,7 @@ class UI_EXPORT InterpolatedAxisAngleRotation : public InterpolatedTransform {
|
||||
virtual ~InterpolatedAxisAngleRotation();
|
||||
|
||||
protected:
|
||||
virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
|
||||
virtual gfx::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
|
||||
|
||||
private:
|
||||
gfx::Point3f axis_;
|
||||
@ -155,7 +155,7 @@ class UI_EXPORT InterpolatedScale : public InterpolatedTransform {
|
||||
virtual ~InterpolatedScale();
|
||||
|
||||
protected:
|
||||
virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
|
||||
virtual gfx::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
|
||||
|
||||
private:
|
||||
const gfx::Point3f start_scale_;
|
||||
@ -175,7 +175,7 @@ class UI_EXPORT InterpolatedTranslation : public InterpolatedTransform {
|
||||
virtual ~InterpolatedTranslation();
|
||||
|
||||
protected:
|
||||
virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
|
||||
virtual gfx::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
|
||||
|
||||
private:
|
||||
const gfx::Point start_pos_;
|
||||
@ -195,14 +195,14 @@ class UI_EXPORT InterpolatedTranslation : public InterpolatedTransform {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class UI_EXPORT InterpolatedConstantTransform : public InterpolatedTransform {
|
||||
public:
|
||||
InterpolatedConstantTransform(const ui::Transform& transform);
|
||||
InterpolatedConstantTransform(const gfx::Transform& transform);
|
||||
virtual ~InterpolatedConstantTransform();
|
||||
|
||||
protected:
|
||||
virtual ui::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
|
||||
virtual gfx::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
|
||||
|
||||
private:
|
||||
const ui::Transform transform_;
|
||||
const gfx::Transform transform_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(InterpolatedConstantTransform);
|
||||
};
|
||||
@ -229,7 +229,7 @@ class UI_EXPORT InterpolatedTransformAboutPivot : public InterpolatedTransform {
|
||||
virtual ~InterpolatedTransformAboutPivot();
|
||||
|
||||
protected:
|
||||
virtual Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
|
||||
virtual gfx::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
|
||||
|
||||
private:
|
||||
void Init(const gfx::Point& pivot, InterpolatedTransform* transform);
|
||||
@ -241,22 +241,22 @@ class UI_EXPORT InterpolatedTransformAboutPivot : public InterpolatedTransform {
|
||||
|
||||
class UI_EXPORT InterpolatedTRSTransform : public InterpolatedTransform {
|
||||
public:
|
||||
InterpolatedTRSTransform(const Transform& start_transform,
|
||||
const Transform& end_transform);
|
||||
InterpolatedTRSTransform(const gfx::Transform& start_transform,
|
||||
const gfx::Transform& end_transform);
|
||||
|
||||
InterpolatedTRSTransform(const Transform& start_transform,
|
||||
const Transform& end_transform,
|
||||
InterpolatedTRSTransform(const gfx::Transform& start_transform,
|
||||
const gfx::Transform& end_transform,
|
||||
float start_time,
|
||||
float end_time);
|
||||
|
||||
virtual ~InterpolatedTRSTransform();
|
||||
|
||||
protected:
|
||||
virtual Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
|
||||
virtual gfx::Transform InterpolateButDoNotCompose(float t) const OVERRIDE;
|
||||
|
||||
private:
|
||||
void Init(const ui::Transform& start_transform,
|
||||
const ui::Transform& end_transform);
|
||||
void Init(const gfx::Transform& start_transform,
|
||||
const gfx::Transform& end_transform);
|
||||
|
||||
scoped_ptr<InterpolatedTransform> transform_;
|
||||
};
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
namespace {
|
||||
|
||||
void CheckApproximatelyEqual(const ui::Transform& lhs,
|
||||
const ui::Transform& rhs) {
|
||||
void CheckApproximatelyEqual(const gfx::Transform& lhs,
|
||||
const gfx::Transform& rhs) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
EXPECT_FLOAT_EQ(lhs.matrix().get(i, j), rhs.matrix().get(i, j));
|
||||
@ -37,9 +37,9 @@ TEST(InterpolatedTransformTest, InterpolatedRotation) {
|
||||
0, 100, 100, 200);
|
||||
|
||||
for (int i = 0; i <= 100; ++i) {
|
||||
ui::Transform rotation;
|
||||
gfx::Transform rotation;
|
||||
rotation.SetRotate(i);
|
||||
ui::Transform interpolated = interpolated_rotation.Interpolate(i / 100.0f);
|
||||
gfx::Transform interpolated = interpolated_rotation.Interpolate(i / 100.0f);
|
||||
CheckApproximatelyEqual(rotation, interpolated);
|
||||
interpolated = interpolated_rotation_diff_start_end.Interpolate(i + 100);
|
||||
CheckApproximatelyEqual(rotation, interpolated);
|
||||
@ -53,9 +53,9 @@ TEST(InterpolatedTransformTest, InterpolatedScale) {
|
||||
gfx::Point3f(0, 0, 0), gfx::Point3f(100, 100, 100), 100, 200);
|
||||
|
||||
for (int i = 0; i <= 100; ++i) {
|
||||
ui::Transform scale;
|
||||
gfx::Transform scale;
|
||||
scale.SetScale(i, i);
|
||||
ui::Transform interpolated = interpolated_scale.Interpolate(i / 100.0f);
|
||||
gfx::Transform interpolated = interpolated_scale.Interpolate(i / 100.0f);
|
||||
CheckApproximatelyEqual(scale, interpolated);
|
||||
interpolated = interpolated_scale_diff_start_end.Interpolate(i + 100);
|
||||
CheckApproximatelyEqual(scale, interpolated);
|
||||
@ -70,9 +70,9 @@ TEST(InterpolatedTransformTest, InterpolatedTranslate) {
|
||||
gfx::Point(0, 0), gfx::Point(100, 100), 100, 200);
|
||||
|
||||
for (int i = 0; i <= 100; ++i) {
|
||||
ui::Transform xform;
|
||||
gfx::Transform xform;
|
||||
xform.SetTranslate(i, i);
|
||||
ui::Transform interpolated = interpolated_xform.Interpolate(i / 100.0f);
|
||||
gfx::Transform interpolated = interpolated_xform.Interpolate(i / 100.0f);
|
||||
CheckApproximatelyEqual(xform, interpolated);
|
||||
interpolated = interpolated_xform_diff_start_end.Interpolate(i + 100);
|
||||
CheckApproximatelyEqual(xform, interpolated);
|
||||
@ -86,8 +86,8 @@ TEST(InterpolatedTransformTest, InterpolatedRotationAboutPivot) {
|
||||
ui::InterpolatedTransformAboutPivot interpolated_xform(
|
||||
pivot,
|
||||
new ui::InterpolatedRotation(0, 90));
|
||||
ui::Transform result = interpolated_xform.Interpolate(0.0f);
|
||||
CheckApproximatelyEqual(ui::Transform(), result);
|
||||
gfx::Transform result = interpolated_xform.Interpolate(0.0f);
|
||||
CheckApproximatelyEqual(gfx::Transform(), result);
|
||||
result = interpolated_xform.Interpolate(1.0f);
|
||||
gfx::Point expected_result = pivot;
|
||||
result.TransformPoint(pivot);
|
||||
@ -103,8 +103,8 @@ TEST(InterpolatedTransformTest, InterpolatedScaleAboutPivot) {
|
||||
ui::InterpolatedTransformAboutPivot interpolated_xform(
|
||||
pivot,
|
||||
new ui::InterpolatedScale(gfx::Point3f(1, 1, 1), gfx::Point3f(2, 2, 2)));
|
||||
ui::Transform result = interpolated_xform.Interpolate(0.0f);
|
||||
CheckApproximatelyEqual(ui::Transform(), result);
|
||||
gfx::Transform result = interpolated_xform.Interpolate(0.0f);
|
||||
CheckApproximatelyEqual(gfx::Transform(), result);
|
||||
result = interpolated_xform.Interpolate(1.0f);
|
||||
gfx::Point expected_result = pivot;
|
||||
result.TransformPoint(pivot);
|
||||
@ -117,7 +117,7 @@ TEST(InterpolatedTransformTest, InterpolatedScaleAboutPivot) {
|
||||
TEST(InterpolatedTransformTest, FactorTRS) {
|
||||
for (int degrees = 0; degrees < 360; ++degrees) {
|
||||
// build a transformation matrix.
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetScale(degrees + 1, 2 * degrees + 1);
|
||||
transform.ConcatRotate(degrees);
|
||||
transform.ConcatTranslate(degrees * 2, -degrees * 3);
|
||||
@ -179,7 +179,7 @@ ui::InterpolatedTransform* GetScreenRotation(int degrees, bool reversed) {
|
||||
new ui::InterpolatedScale(1.0f, 1.0f / scale_factor, 0.5f, 1.0f));
|
||||
|
||||
scoped_ptr<ui::InterpolatedTransform> to_return(
|
||||
new ui::InterpolatedConstantTransform(ui::Transform()));
|
||||
new ui::InterpolatedConstantTransform(gfx::Transform()));
|
||||
|
||||
scale_up->SetChild(scale_down.release());
|
||||
translation->SetChild(scale_up.release());
|
||||
@ -196,7 +196,7 @@ TEST(InterpolatedTransformTest, ScreenRotationEndsCleanly) {
|
||||
const bool reversed = i == 1;
|
||||
scoped_ptr<ui::InterpolatedTransform> screen_rotation(
|
||||
GetScreenRotation(degrees, reversed));
|
||||
ui::Transform interpolated = screen_rotation->Interpolate(1.0f);
|
||||
gfx::Transform interpolated = screen_rotation->Interpolate(1.0f);
|
||||
SkMatrix44& m = interpolated.matrix();
|
||||
// Upper-left 3x3 matrix should all be 0, 1 or -1.
|
||||
for (int row = 0; row < 3; ++row) {
|
||||
@ -247,7 +247,7 @@ ui::InterpolatedTransform* GetMaximize() {
|
||||
|
||||
TEST(InterpolatedTransformTest, MaximizeEndsCleanly) {
|
||||
scoped_ptr<ui::InterpolatedTransform> maximize(GetMaximize());
|
||||
ui::Transform interpolated = maximize->Interpolate(1.0f);
|
||||
gfx::Transform interpolated = maximize->Interpolate(1.0f);
|
||||
SkMatrix44& m = interpolated.matrix();
|
||||
// Upper-left 3x3 matrix should all be 0, 1 or -1.
|
||||
for (int row = 0; row < 3; ++row) {
|
||||
|
@ -19,7 +19,7 @@ static int SymmetricRound(float x) {
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace ui {
|
||||
namespace gfx {
|
||||
|
||||
Transform::Transform() {
|
||||
matrix_.reset();
|
||||
@ -39,7 +39,7 @@ void Transform::SetRotate(float degree) {
|
||||
matrix_.setRotateDegreesAbout(0, 0, 1, SkFloatToScalar(degree));
|
||||
}
|
||||
|
||||
void Transform::SetRotateAbout(const gfx::Point3f& axis, float degree) {
|
||||
void Transform::SetRotateAbout(const Point3f& axis, float degree) {
|
||||
matrix_.setRotateDegreesAbout(axis.x(),
|
||||
axis.y(),
|
||||
axis.z(),
|
||||
@ -86,7 +86,7 @@ void Transform::ConcatRotate(float degree) {
|
||||
matrix_.postConcat(rot);
|
||||
}
|
||||
|
||||
void Transform::ConcatRotateAbout(const gfx::Point3f& axis, float degree) {
|
||||
void Transform::ConcatRotateAbout(const Point3f& axis, float degree) {
|
||||
SkMatrix44 rot;
|
||||
rot.setRotateDegreesAbout(axis.x(),
|
||||
axis.y(),
|
||||
@ -127,15 +127,15 @@ bool Transform::GetInverse(Transform* transform) const {
|
||||
return matrix_.invert(&transform->matrix_);
|
||||
}
|
||||
|
||||
void Transform::TransformPoint(gfx::Point& point) const {
|
||||
void Transform::TransformPoint(Point& point) const {
|
||||
TransformPointInternal(matrix_, point);
|
||||
}
|
||||
|
||||
void Transform::TransformPoint(gfx::Point3f& point) const {
|
||||
void Transform::TransformPoint(Point3f& point) const {
|
||||
TransformPointInternal(matrix_, point);
|
||||
}
|
||||
|
||||
bool Transform::TransformPointReverse(gfx::Point& point) const {
|
||||
bool Transform::TransformPointReverse(Point& point) const {
|
||||
// TODO(sad): Try to avoid trying to invert the matrix.
|
||||
SkMatrix44 inverse;
|
||||
if (!matrix_.invert(&inverse))
|
||||
@ -145,7 +145,7 @@ bool Transform::TransformPointReverse(gfx::Point& point) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Transform::TransformPointReverse(gfx::Point3f& point) const {
|
||||
bool Transform::TransformPointReverse(Point3f& point) const {
|
||||
// TODO(sad): Try to avoid trying to invert the matrix.
|
||||
SkMatrix44 inverse;
|
||||
if (!matrix_.invert(&inverse))
|
||||
@ -155,26 +155,26 @@ bool Transform::TransformPointReverse(gfx::Point3f& point) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Transform::TransformRect(gfx::Rect* rect) const {
|
||||
SkRect src = gfx::RectToSkRect(*rect);
|
||||
void Transform::TransformRect(Rect* rect) const {
|
||||
SkRect src = RectToSkRect(*rect);
|
||||
const SkMatrix& matrix = matrix_;
|
||||
matrix.mapRect(&src);
|
||||
*rect = gfx::SkRectToRect(src);
|
||||
*rect = SkRectToRect(src);
|
||||
}
|
||||
|
||||
bool Transform::TransformRectReverse(gfx::Rect* rect) const {
|
||||
bool Transform::TransformRectReverse(Rect* rect) const {
|
||||
SkMatrix44 inverse;
|
||||
if (!matrix_.invert(&inverse))
|
||||
return false;
|
||||
const SkMatrix& matrix = inverse;
|
||||
SkRect src = gfx::RectToSkRect(*rect);
|
||||
SkRect src = RectToSkRect(*rect);
|
||||
matrix.mapRect(&src);
|
||||
*rect = gfx::SkRectToRect(src);
|
||||
*rect = SkRectToRect(src);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Transform::TransformPointInternal(const SkMatrix44& xform,
|
||||
gfx::Point3f& point) const {
|
||||
Point3f& point) const {
|
||||
SkScalar p[4] = {
|
||||
SkFloatToScalar(point.x()),
|
||||
SkFloatToScalar(point.y()),
|
||||
@ -191,7 +191,7 @@ void Transform::TransformPointInternal(const SkMatrix44& xform,
|
||||
}
|
||||
|
||||
void Transform::TransformPointInternal(const SkMatrix44& xform,
|
||||
gfx::Point& point) const {
|
||||
Point& point) const {
|
||||
SkScalar p[4] = {
|
||||
SkIntToScalar(point.x()),
|
||||
SkIntToScalar(point.y()),
|
||||
@ -204,4 +204,4 @@ void Transform::TransformPointInternal(const SkMatrix44& xform,
|
||||
SymmetricRound(p[1]));
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
} // namespace gfx
|
||||
|
@ -9,12 +9,10 @@
|
||||
#include "ui/base/ui_export.h"
|
||||
|
||||
namespace gfx {
|
||||
|
||||
class Rect;
|
||||
class Point;
|
||||
class Point3f;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
|
||||
// 4x4 transformation matrix. Transform is cheap and explicitly allows
|
||||
// copy/assign.
|
||||
@ -39,7 +37,7 @@ class UI_EXPORT Transform {
|
||||
void SetRotate(float degree);
|
||||
|
||||
// Sets the rotation of the transform (about a vector).
|
||||
void SetRotateAbout(const gfx::Point3f& point, float degree);
|
||||
void SetRotateAbout(const Point3f& point, float degree);
|
||||
|
||||
// Sets the scaling parameters.
|
||||
void SetScaleX(float x);
|
||||
@ -60,7 +58,7 @@ class UI_EXPORT Transform {
|
||||
void ConcatRotate(float degree);
|
||||
|
||||
// Applies an axis-angle rotation on the current transformation.
|
||||
void ConcatRotateAbout(const gfx::Point3f& point, float degree);
|
||||
void ConcatRotateAbout(const Point3f& point, float degree);
|
||||
|
||||
// Applies scaling on current transform.
|
||||
void ConcatScale(float x, float y);
|
||||
@ -84,30 +82,30 @@ class UI_EXPORT Transform {
|
||||
|
||||
// Applies the transformation on the point. Returns true if the point is
|
||||
// transformed successfully.
|
||||
void TransformPoint(gfx::Point3f& point) const;
|
||||
void TransformPoint(Point3f& point) const;
|
||||
|
||||
// Applies the transformation on the point. Returns true if the point is
|
||||
// transformed successfully. Rounds the result to the nearest point.
|
||||
void TransformPoint(gfx::Point& point) const;
|
||||
void TransformPoint(Point& point) const;
|
||||
|
||||
// Applies the reverse transformation on the point. Returns true if the
|
||||
// transformation can be inverted.
|
||||
bool TransformPointReverse(gfx::Point3f& point) const;
|
||||
bool TransformPointReverse(Point3f& point) const;
|
||||
|
||||
// Applies the reverse transformation on the point. Returns true if the
|
||||
// transformation can be inverted. Rounds the result to the nearest point.
|
||||
bool TransformPointReverse(gfx::Point& point) const;
|
||||
bool TransformPointReverse(Point& point) const;
|
||||
|
||||
// Applies transformation on the rectangle. Returns true if the transformed
|
||||
// rectangle was axis aligned. If it returns false, rect will be the
|
||||
// smallest axis aligned bounding box containing the transformed rect.
|
||||
void TransformRect(gfx::Rect* rect) const;
|
||||
void TransformRect(Rect* rect) const;
|
||||
|
||||
// Applies the reverse transformation on the rectangle. Returns true if
|
||||
// the transformed rectangle was axis aligned. If it returns false,
|
||||
// rect will be the smallest axis aligned bounding box containing the
|
||||
// transformed rect.
|
||||
bool TransformRectReverse(gfx::Rect* rect) const;
|
||||
bool TransformRectReverse(Rect* rect) const;
|
||||
|
||||
// Returns the underlying matrix.
|
||||
const SkMatrix44& matrix() const { return matrix_; }
|
||||
@ -115,16 +113,16 @@ class UI_EXPORT Transform {
|
||||
|
||||
private:
|
||||
void TransformPointInternal(const SkMatrix44& xform,
|
||||
gfx::Point& point) const;
|
||||
Point& point) const;
|
||||
|
||||
void TransformPointInternal(const SkMatrix44& xform,
|
||||
gfx::Point3f& point) const;
|
||||
Point3f& point) const;
|
||||
|
||||
SkMatrix44 matrix_;
|
||||
|
||||
// copy/assign are allowed.
|
||||
};
|
||||
|
||||
}// namespace ui
|
||||
} // namespace gfx
|
||||
|
||||
#endif // UI_GFX_TRANSFORM_H_
|
||||
|
@ -20,7 +20,7 @@ bool PointsAreNearlyEqual(const gfx::Point3f& lhs,
|
||||
}
|
||||
|
||||
TEST(XFormTest, Equality) {
|
||||
ui::Transform lhs, rhs, interpolated;
|
||||
gfx::Transform lhs, rhs, interpolated;
|
||||
rhs.matrix().set3x3(1, 2, 3,
|
||||
4, 5, 6,
|
||||
7, 8, 9);
|
||||
@ -40,8 +40,8 @@ TEST(XFormTest, Equality) {
|
||||
EXPECT_TRUE(rhs != interpolated);
|
||||
}
|
||||
}
|
||||
lhs = ui::Transform();
|
||||
rhs = ui::Transform();
|
||||
lhs = gfx::Transform();
|
||||
rhs = gfx::Transform();
|
||||
for (int i = 1; i < 100; ++i) {
|
||||
lhs.SetTranslate(i, i);
|
||||
rhs.SetTranslate(-i, -i);
|
||||
@ -69,7 +69,7 @@ TEST(XFormTest, ConcatTranslate) {
|
||||
10, 20 },
|
||||
};
|
||||
|
||||
ui::Transform xform;
|
||||
gfx::Transform xform;
|
||||
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
|
||||
const TestCase& value = test_cases[i];
|
||||
xform.ConcatTranslate(value.tx, value.ty);
|
||||
@ -96,7 +96,7 @@ TEST(XFormTest, ConcatScale) {
|
||||
{ 1, std::numeric_limits<float>::quiet_NaN(), 1 }
|
||||
};
|
||||
|
||||
ui::Transform xform;
|
||||
gfx::Transform xform;
|
||||
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
|
||||
const TestCase& value = test_cases[i];
|
||||
xform.ConcatScale(value.scale, value.scale);
|
||||
@ -125,7 +125,7 @@ TEST(XFormTest, ConcatRotate) {
|
||||
{ 1, 0, std::numeric_limits<float>::quiet_NaN(), 1, 0 }
|
||||
};
|
||||
|
||||
ui::Transform xform;
|
||||
gfx::Transform xform;
|
||||
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
|
||||
const TestCase& value = test_cases[i];
|
||||
xform.ConcatRotate(value.degrees);
|
||||
@ -157,7 +157,7 @@ TEST(XFormTest, SetTranslate) {
|
||||
const TestCase& value = test_cases[i];
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
gfx::Point3f p0, p1, p2;
|
||||
ui::Transform xform;
|
||||
gfx::Transform xform;
|
||||
switch (k) {
|
||||
case 0:
|
||||
p1.SetPoint(value.x1, 0, 0);
|
||||
@ -204,7 +204,7 @@ TEST(XFormTest, SetScale) {
|
||||
const TestCase& value = test_cases[i];
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
gfx::Point3f p0, p1, p2;
|
||||
ui::Transform xform;
|
||||
gfx::Transform xform;
|
||||
switch (k) {
|
||||
case 0:
|
||||
p1.SetPoint(value.before, 0, 0);
|
||||
@ -259,7 +259,7 @@ TEST(XFormTest, SetRotate) {
|
||||
gfx::Point3f p1(value.x, value.y, 0);
|
||||
gfx::Point3f p2(value.xprime, value.yprime, 0);
|
||||
p0 = p1;
|
||||
ui::Transform xform;
|
||||
gfx::Transform xform;
|
||||
xform.SetRotate(value.degree);
|
||||
// just want to make sure that we don't crash in the case of NaN.
|
||||
if (value.degree == value.degree) {
|
||||
@ -290,7 +290,7 @@ TEST(XFormTest, ConcatTranslate2D) {
|
||||
10, 20},
|
||||
};
|
||||
|
||||
ui::Transform xform;
|
||||
gfx::Transform xform;
|
||||
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
|
||||
const TestCase& value = test_cases[i];
|
||||
xform.ConcatTranslate(value.tx, value.ty);
|
||||
@ -318,7 +318,7 @@ TEST(XFormTest, ConcatScale2D) {
|
||||
{ 1, std::numeric_limits<float>::quiet_NaN(), 1}
|
||||
};
|
||||
|
||||
ui::Transform xform;
|
||||
gfx::Transform xform;
|
||||
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
|
||||
const TestCase& value = test_cases[i];
|
||||
xform.ConcatScale(value.scale, value.scale);
|
||||
@ -348,7 +348,7 @@ TEST(XFormTest, ConcatRotate2D) {
|
||||
{ 1, 0, std::numeric_limits<float>::quiet_NaN(), 1, 0}
|
||||
};
|
||||
|
||||
ui::Transform xform;
|
||||
gfx::Transform xform;
|
||||
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
|
||||
const TestCase& value = test_cases[i];
|
||||
xform.ConcatRotate(value.degrees);
|
||||
@ -383,7 +383,7 @@ TEST(XFormTest, SetTranslate2D) {
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
float epsilon = 0.0001f;
|
||||
gfx::Point p0, p1, p2;
|
||||
ui::Transform xform;
|
||||
gfx::Transform xform;
|
||||
switch (k) {
|
||||
case 0:
|
||||
p1.SetPoint(value.x1, 0);
|
||||
@ -436,7 +436,7 @@ TEST(XFormTest, SetScale2D) {
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
float epsilon = 0.0001f;
|
||||
gfx::Point p0, p1, p2;
|
||||
ui::Transform xform;
|
||||
gfx::Transform xform;
|
||||
switch (k) {
|
||||
case 0:
|
||||
p1.SetPoint(value.before, 0);
|
||||
@ -496,7 +496,7 @@ TEST(XFormTest, SetRotate2D) {
|
||||
for (int j = 1; j >= -1; --j) {
|
||||
float epsilon = 0.1f;
|
||||
gfx::Point pt(value.x, value.y);
|
||||
ui::Transform xform;
|
||||
gfx::Transform xform;
|
||||
// should be invariant to small floating point errors.
|
||||
xform.SetRotate(value.degree + j * epsilon);
|
||||
// just want to make sure that we don't crash in the case of NaN.
|
||||
|
@ -6,10 +6,10 @@
|
||||
|
||||
#include "ui/gfx/point.h"
|
||||
|
||||
namespace ui {
|
||||
namespace gfx {
|
||||
|
||||
Transform GetScaleTransform(const gfx::Point& anchor, float scale) {
|
||||
ui::Transform transform;
|
||||
Transform GetScaleTransform(const Point& anchor, float scale) {
|
||||
Transform transform;
|
||||
transform.ConcatScale(scale, scale);
|
||||
transform.ConcatTranslate(anchor.x() * (1 - scale),
|
||||
anchor.y() * (1 - scale));
|
||||
|
@ -9,14 +9,12 @@
|
||||
#include "ui/gfx/transform.h"
|
||||
|
||||
namespace gfx {
|
||||
class Point;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
class Point;
|
||||
|
||||
// Returns a scale transform at |anchor| point.
|
||||
UI_EXPORT Transform GetScaleTransform(const gfx::Point& anchor, float scale);
|
||||
UI_EXPORT Transform GetScaleTransform(const Point& anchor, float scale);
|
||||
|
||||
} // namespace ui
|
||||
} // namespace gfx
|
||||
|
||||
#endif // UI_GFX_TRANSFORM_UTIL_H_
|
||||
|
@ -11,7 +11,7 @@ TEST(TransformUtilTest, GetScaleTransform) {
|
||||
const gfx::Point kAnchor(20, 40);
|
||||
const float kScale = 0.5f;
|
||||
|
||||
ui::Transform scale = ui::GetScaleTransform(kAnchor, kScale);
|
||||
gfx::Transform scale = gfx::GetScaleTransform(kAnchor, kScale);
|
||||
|
||||
const int kOffset = 10;
|
||||
for (int sign_x = -1; sign_x <= 1; ++sign_x) {
|
||||
|
@ -325,7 +325,7 @@ gfx::Rect View::GetVisibleBounds() const {
|
||||
gfx::Rect vis_bounds(GetLocalBounds());
|
||||
gfx::Rect ancestor_bounds;
|
||||
const View* view = this;
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
|
||||
while (view != NULL && !vis_bounds.IsEmpty()) {
|
||||
transform.ConcatTransform(view->GetTransform());
|
||||
@ -426,12 +426,12 @@ void View::OnEnabledChanged() {
|
||||
|
||||
// Transformations -------------------------------------------------------------
|
||||
|
||||
const ui::Transform& View::GetTransform() const {
|
||||
static const ui::Transform* no_op = new ui::Transform;
|
||||
const gfx::Transform& View::GetTransform() const {
|
||||
static const gfx::Transform* no_op = new gfx::Transform;
|
||||
return layer() ? layer()->transform() : *no_op;
|
||||
}
|
||||
|
||||
void View::SetTransform(const ui::Transform& transform) {
|
||||
void View::SetTransform(const gfx::Transform& transform) {
|
||||
if (!transform.HasChange()) {
|
||||
if (layer()) {
|
||||
layer()->SetTransform(transform);
|
||||
@ -1765,7 +1765,7 @@ void View::SetLayerBounds(const gfx::Rect& bounds) {
|
||||
// Transformations -------------------------------------------------------------
|
||||
|
||||
bool View::GetTransformRelativeTo(const View* ancestor,
|
||||
ui::Transform* transform) const {
|
||||
gfx::Transform* transform) const {
|
||||
const View* p = this;
|
||||
|
||||
while (p && p != ancestor) {
|
||||
@ -1783,7 +1783,7 @@ bool View::GetTransformRelativeTo(const View* ancestor,
|
||||
|
||||
bool View::ConvertPointForAncestor(const View* ancestor,
|
||||
gfx::Point* point) const {
|
||||
ui::Transform trans;
|
||||
gfx::Transform trans;
|
||||
// TODO(sad): Have some way of caching the transformation results.
|
||||
bool result = GetTransformRelativeTo(ancestor, &trans);
|
||||
gfx::Point3f p(*point);
|
||||
@ -1794,7 +1794,7 @@ bool View::ConvertPointForAncestor(const View* ancestor,
|
||||
|
||||
bool View::ConvertPointFromAncestor(const View* ancestor,
|
||||
gfx::Point* point) const {
|
||||
ui::Transform trans;
|
||||
gfx::Transform trans;
|
||||
bool result = GetTransformRelativeTo(ancestor, &trans);
|
||||
gfx::Point3f p(*point);
|
||||
trans.TransformPointReverse(p);
|
||||
|
@ -37,6 +37,7 @@ namespace gfx {
|
||||
class Canvas;
|
||||
class Insets;
|
||||
class Path;
|
||||
class Transform;
|
||||
}
|
||||
|
||||
namespace ui {
|
||||
@ -46,7 +47,6 @@ class Layer;
|
||||
class TextInputClient;
|
||||
class Texture;
|
||||
class ThemeProvider;
|
||||
class Transform;
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
@ -260,13 +260,13 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
|
||||
|
||||
// Methods for setting transformations for a view (e.g. rotation, scaling).
|
||||
|
||||
const ui::Transform& GetTransform() const;
|
||||
const gfx::Transform& GetTransform() const;
|
||||
|
||||
// Clipping parameters. Clipping is done relative to the view bounds.
|
||||
void set_clip_insets(gfx::Insets clip_insets) { clip_insets_ = clip_insets; }
|
||||
|
||||
// Sets the transform to the supplied transform.
|
||||
void SetTransform(const ui::Transform& transform);
|
||||
void SetTransform(const gfx::Transform& transform);
|
||||
|
||||
// Sets whether this view paints to a layer. A view paints to a layer if
|
||||
// either of the following are true:
|
||||
@ -1231,7 +1231,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
|
||||
// to this. Returns true if |ancestor| is found. If |ancestor| is not found,
|
||||
// or NULL, |transform| is set to convert from root view coordinates to this.
|
||||
bool GetTransformRelativeTo(const View* ancestor,
|
||||
ui::Transform* transform) const;
|
||||
gfx::Transform* transform) const;
|
||||
|
||||
// Coordinate conversion -----------------------------------------------------
|
||||
|
||||
|
@ -962,13 +962,13 @@ gfx::Rect ConvertRectToView(View* view, const gfx::Rect& r) {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void RotateCounterclockwise(ui::Transform* transform) {
|
||||
void RotateCounterclockwise(gfx::Transform* transform) {
|
||||
transform->matrix().set3x3(0, -1, 0,
|
||||
1, 0, 0,
|
||||
0, 0, 1);
|
||||
}
|
||||
|
||||
void RotateClockwise(ui::Transform* transform) {
|
||||
void RotateClockwise(gfx::Transform* transform) {
|
||||
transform->matrix().set3x3( 0, 1, 0,
|
||||
-1, 0, 0,
|
||||
0, 0, 1);
|
||||
@ -2048,7 +2048,7 @@ TEST_F(ViewTest, TransformPaint) {
|
||||
EXPECT_EQ(gfx::Rect(100, 100, 200, 100), v1->scheduled_paint_rect());
|
||||
|
||||
// Rotate |v1| counter-clockwise.
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
RotateCounterclockwise(&transform);
|
||||
transform.SetTranslateY(500.0f);
|
||||
v1->SetTransform(transform);
|
||||
@ -2082,7 +2082,7 @@ TEST_F(ViewTest, TransformEvent) {
|
||||
// At this moment, |v2| occupies (100, 100) to (300, 200) in |root|.
|
||||
|
||||
// Rotate |v1| counter-clockwise.
|
||||
ui::Transform transform(v1->GetTransform());
|
||||
gfx::Transform transform(v1->GetTransform());
|
||||
RotateCounterclockwise(&transform);
|
||||
transform.SetTranslateY(500.0f);
|
||||
v1->SetTransform(transform);
|
||||
@ -2126,8 +2126,8 @@ TEST_F(ViewTest, TransformEvent) {
|
||||
|
||||
root->OnMouseReleased(released);
|
||||
|
||||
v1->SetTransform(ui::Transform());
|
||||
v2->SetTransform(ui::Transform());
|
||||
v1->SetTransform(gfx::Transform());
|
||||
v2->SetTransform(gfx::Transform());
|
||||
|
||||
TestView* v3 = new TestView();
|
||||
v3->SetBoundsRect(gfx::Rect(10, 10, 20, 30));
|
||||
@ -2161,9 +2161,9 @@ TEST_F(ViewTest, TransformEvent) {
|
||||
|
||||
root->OnMouseReleased(released);
|
||||
|
||||
v1->SetTransform(ui::Transform());
|
||||
v2->SetTransform(ui::Transform());
|
||||
v3->SetTransform(ui::Transform());
|
||||
v1->SetTransform(gfx::Transform());
|
||||
v2->SetTransform(gfx::Transform());
|
||||
v3->SetTransform(gfx::Transform());
|
||||
|
||||
v1->Reset();
|
||||
v2->Reset();
|
||||
@ -2223,7 +2223,7 @@ TEST_F(ViewTest, TransformVisibleBound) {
|
||||
EXPECT_EQ(gfx::Rect(0, 0, 50, 10), child->GetVisibleBounds());
|
||||
|
||||
// Rotate |child| counter-clockwise
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
RotateCounterclockwise(&transform);
|
||||
transform.SetTranslateY(50.0f);
|
||||
child->SetTransform(transform);
|
||||
@ -2339,18 +2339,18 @@ TEST_F(ViewTest, ConvertPointToViewWithTransform) {
|
||||
top_view.SetBoundsRect(gfx::Rect(0, 0, 1000, 1000));
|
||||
|
||||
child->SetBoundsRect(gfx::Rect(7, 19, 500, 500));
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetScale(3.0f, 4.0f);
|
||||
child->SetTransform(transform);
|
||||
|
||||
child_child->SetBoundsRect(gfx::Rect(17, 13, 100, 100));
|
||||
transform = ui::Transform();
|
||||
transform = gfx::Transform();
|
||||
transform.SetScale(5.0f, 7.0f);
|
||||
child_child->SetTransform(transform);
|
||||
|
||||
// Sanity check to make sure basic transforms act as expected.
|
||||
{
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.ConcatTranslate(1, 1);
|
||||
transform.ConcatScale(100, 55);
|
||||
transform.ConcatTranslate(110, -110);
|
||||
@ -2367,11 +2367,11 @@ TEST_F(ViewTest, ConvertPointToViewWithTransform) {
|
||||
}
|
||||
|
||||
{
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetTranslate(1, 1);
|
||||
ui::Transform t2;
|
||||
gfx::Transform t2;
|
||||
t2.SetScale(100, 55);
|
||||
ui::Transform t3;
|
||||
gfx::Transform t3;
|
||||
t3.SetTranslate(110, -110);
|
||||
transform.ConcatTransform(t2);
|
||||
transform.ConcatTransform(t3);
|
||||
@ -2459,7 +2459,7 @@ TEST_F(ViewTest, ConvertRectWithTransform) {
|
||||
EXPECT_EQ(gfx::Rect(35, 35, 15, 40), v2->ConvertRectToWidget(rect));
|
||||
|
||||
// Rotate |v2|
|
||||
ui::Transform t2;
|
||||
gfx::Transform t2;
|
||||
RotateCounterclockwise(&t2);
|
||||
t2.SetTranslateY(100.0f);
|
||||
v2->SetTransform(t2);
|
||||
@ -2469,7 +2469,7 @@ TEST_F(ViewTest, ConvertRectWithTransform) {
|
||||
EXPECT_EQ(gfx::Rect(35, 110, 40, 15), v2->ConvertRectToWidget(rect));
|
||||
|
||||
// Scale down |v1|
|
||||
ui::Transform t1;
|
||||
gfx::Transform t1;
|
||||
t1.SetScale(0.5, 0.5);
|
||||
v1->SetTransform(t1);
|
||||
|
||||
@ -2976,7 +2976,7 @@ TEST_F(ViewLayerTest, LayerToggling) {
|
||||
EXPECT_EQ(gfx::Rect(30, 50, 30, 40), v2->layer()->bounds());
|
||||
|
||||
// Make v1 have a layer again and verify v2s layer is wired up correctly.
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetScale(2.0f, 2.0f);
|
||||
v1->SetTransform(transform);
|
||||
EXPECT_TRUE(v1->layer() != NULL);
|
||||
@ -3128,7 +3128,7 @@ TEST_F(ViewLayerTest, BoundInRTL) {
|
||||
// Makes sure a transform persists after toggling the visibility.
|
||||
TEST_F(ViewLayerTest, ToggleVisibilityWithTransform) {
|
||||
View* view = new View;
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetScale(2.0f, 2.0f);
|
||||
view->SetTransform(transform);
|
||||
widget()->SetContentsView(view);
|
||||
@ -3144,7 +3144,7 @@ TEST_F(ViewLayerTest, ToggleVisibilityWithTransform) {
|
||||
// Verifies a transform persists after removing/adding a view with a transform.
|
||||
TEST_F(ViewLayerTest, ResetTransformOnLayerAfterAdd) {
|
||||
View* view = new View;
|
||||
ui::Transform transform;
|
||||
gfx::Transform transform;
|
||||
transform.SetScale(2.0f, 2.0f);
|
||||
view->SetTransform(transform);
|
||||
widget()->SetContentsView(view);
|
||||
|
@ -1045,7 +1045,7 @@ bool Widget::OnNativeWidgetPaintAccelerated(const gfx::Rect& dirty_region) {
|
||||
// to avoid leaving ghosts.
|
||||
bool force_clear = false;
|
||||
if (GetRootView()->layer()) {
|
||||
const ui::Transform& layer_transform = GetRootView()->layer()->transform();
|
||||
const gfx::Transform& layer_transform = GetRootView()->layer()->transform();
|
||||
if (layer_transform != GetRootView()->GetTransform()) {
|
||||
// The layer has not caught up to the view (i.e., the layer is still
|
||||
// animating), and so a clear is required.
|
||||
|
Reference in New Issue
Block a user