| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/core/view/View.h" | 6 #include "sky/engine/core/view/View.h" |
| 7 | 7 |
| 8 namespace blink { | 8 namespace blink { |
| 9 | 9 |
| 10 PassRefPtr<View> View::create(const base::Closure& scheduleFrameCallback) | 10 PassRefPtr<View> View::create(const base::Closure& scheduleFrameCallback) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 { | 31 { |
| 32 double h = m_displayMetrics.physical_size.height; | 32 double h = m_displayMetrics.physical_size.height; |
| 33 return h / m_displayMetrics.device_pixel_ratio; | 33 return h / m_displayMetrics.device_pixel_ratio; |
| 34 } | 34 } |
| 35 | 35 |
| 36 void View::setEventCallback(PassOwnPtr<EventCallback> callback) | 36 void View::setEventCallback(PassOwnPtr<EventCallback> callback) |
| 37 { | 37 { |
| 38 m_eventCallback = callback; | 38 m_eventCallback = callback; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void View::setMetricsChangedCallback(PassOwnPtr<VoidCallback> callback) |
| 42 { |
| 43 m_metricsChangedCallback = callback; |
| 44 } |
| 45 |
| 41 void View::setBeginFrameCallback(PassOwnPtr<BeginFrameCallback> callback) | 46 void View::setBeginFrameCallback(PassOwnPtr<BeginFrameCallback> callback) |
| 42 { | 47 { |
| 43 m_beginFrameCallback = callback; | 48 m_beginFrameCallback = callback; |
| 44 } | 49 } |
| 45 | 50 |
| 46 void View::scheduleFrame() | 51 void View::scheduleFrame() |
| 47 { | 52 { |
| 48 m_scheduleFrameCallback.Run(); | 53 m_scheduleFrameCallback.Run(); |
| 49 } | 54 } |
| 50 | 55 |
| 51 void View::setDisplayMetrics(const SkyDisplayMetrics& metrics) | 56 void View::setDisplayMetrics(const SkyDisplayMetrics& metrics) |
| 52 { | 57 { |
| 53 m_displayMetrics = metrics; | 58 m_displayMetrics = metrics; |
| 59 if (m_metricsChangedCallback) |
| 60 m_metricsChangedCallback->handleEvent(); |
| 54 } | 61 } |
| 55 | 62 |
| 56 void View::handleInputEvent(PassRefPtr<Event> event) | 63 void View::handleInputEvent(PassRefPtr<Event> event) |
| 57 { | 64 { |
| 58 if (m_eventCallback) | 65 if (m_eventCallback) |
| 59 m_eventCallback->handleEvent(event.get()); | 66 m_eventCallback->handleEvent(event.get()); |
| 60 } | 67 } |
| 61 | 68 |
| 62 void View::beginFrame(base::TimeTicks frameTime) | 69 void View::beginFrame(base::TimeTicks frameTime) |
| 63 { | 70 { |
| 64 if (!m_beginFrameCallback) | 71 if (!m_beginFrameCallback) |
| 65 return; | 72 return; |
| 66 double frameTimeMS = (frameTime - base::TimeTicks()).InMillisecondsF(); | 73 double frameTimeMS = (frameTime - base::TimeTicks()).InMillisecondsF(); |
| 67 m_beginFrameCallback->handleEvent(frameTimeMS); | 74 m_beginFrameCallback->handleEvent(frameTimeMS); |
| 68 } | 75 } |
| 69 | 76 |
| 70 } // namespace blink | 77 } // namespace blink |
| OLD | NEW |