Commit ee544e1a authored by morrita@chromium.org's avatar morrita@chromium.org

Mojo: Get rid of ui::gfx from sample_app

This CL replaces gfx based geometry objects with ones from mojo::.

TEST=none
R=beng@chromium.org, viettrungluu@chromium.org
BUG=330467

Review URL: https://codereview.chromium.org/409263002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284951 0039d316-1c4b-4281-b951-d872f2087c98
parent 51d931c0
include_rules = [
"+ui/events/event_constants.h", # pending enum support in mojom
"+ui/gfx", # TODO(beng): trim the size of this dep.
]
......@@ -15,8 +15,9 @@
namespace examples {
namespace {
float CalculateDragDistance(const gfx::PointF& start, const mojo::Point& end) {
return hypot(start.x() - end.x, start.y() - end.y);
float CalculateDragDistance(const mojo::Point& start, const mojo::Point& end) {
return hypot(static_cast<float>(start.x - end.x),
static_cast<float>(start.y - end.y));
}
float GetRandomColor() {
......@@ -40,10 +41,10 @@ GLES2ClientImpl::~GLES2ClientImpl() {
}
void GLES2ClientImpl::SetSize(const mojo::Size& size) {
size_ = gfx::Size(size.width, size.height);
if (size_.IsEmpty())
size_ = size;
if (size_.width == 0 || size_.height == 0)
return;
cube_.Init(size_.width(), size_.height());
cube_.Init(size_.width, size_.height);
RequestAnimationFrames();
}
......@@ -54,7 +55,7 @@ void GLES2ClientImpl::HandleInputEvent(const mojo::Event& event) {
if (event.flags & ui::EF_RIGHT_MOUSE_BUTTON)
break;
CancelAnimationFrames();
capture_point_.SetPoint(event.location->x, event.location->y);
capture_point_ = *event.location;
last_drag_point_ = capture_point_;
drag_start_time_ = mojo::GetTimeTicksNow();
break;
......@@ -63,15 +64,15 @@ void GLES2ClientImpl::HandleInputEvent(const mojo::Event& event) {
if (event.flags & ui::EF_RIGHT_MOUSE_BUTTON)
break;
if (!getting_animation_frames_) {
int direction = event.location->y < last_drag_point_.y() ||
event.location->x > last_drag_point_.x() ? 1 : -1;
int direction = event.location->y < last_drag_point_.y ||
event.location->x > last_drag_point_.x ? 1 : -1;
cube_.set_direction(direction);
cube_.UpdateForDragDistance(
CalculateDragDistance(last_drag_point_, *event.location));
cube_.Draw();
MojoGLES2SwapBuffers();
last_drag_point_.SetPoint(event.location->x, event.location->y);
last_drag_point_ = *event.location;
}
break;
case ui::ET_MOUSE_RELEASED:
......@@ -86,7 +87,7 @@ void GLES2ClientImpl::HandleInputEvent(const mojo::Event& event) {
CalculateDragDistance(capture_point_, *event.location),
delta);
capture_point_ = last_drag_point_ = gfx::PointF();
capture_point_ = last_drag_point_ = mojo::Point();
RequestAnimationFrames();
break;
}
......
......@@ -7,9 +7,8 @@
#include "mojo/examples/sample_app/spinning_cube.h"
#include "mojo/public/c/gles2/gles2.h"
#include "mojo/services/public/interfaces/geometry/geometry.mojom.h"
#include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.h"
#include "ui/gfx/point_f.h"
#include "ui/gfx/size.h"
namespace examples {
......@@ -31,10 +30,10 @@ class GLES2ClientImpl {
void CancelAnimationFrames();
MojoTimeTicks last_time_;
gfx::Size size_;
mojo::Size size_;
SpinningCube cube_;
gfx::PointF capture_point_;
gfx::PointF last_drag_point_;
mojo::Point capture_point_;
mojo::Point last_drag_point_;
MojoTimeTicks drag_start_time_;
bool getting_animation_frames_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment