gecko-dev/widget/gonk/GeckoTouchDispatcher.h
Nathan Froyd 01583602a9 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout.  The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.

CLOSED TREE makes big refactorings like this a piece of cake.

 # The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    xargs perl -p -i -e '
 s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
 s/nsRefPtr ?</RefPtr</g;   # handle declarations and variables
'

 # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h

 # Handle nsRefPtr.h itself, a couple places that define constructors
 # from nsRefPtr, and code generators specially.  We do this here, rather
 # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
 # things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
     mfbt/nsRefPtr.h \
     xpcom/glue/nsCOMPtr.h \
     xpcom/base/OwningNonNull.h \
     ipc/ipdl/ipdl/lower.py \
     ipc/ipdl/ipdl/builtin.py \
     dom/bindings/Codegen.py \
     python/lldbutils/lldbutils/utils.py

 # In our indiscriminate substitution above, we renamed
 # nsRefPtrGetterAddRefs, the class behind getter_AddRefs.  Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
    xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'

if [ -d .git ]; then
    git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
    hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi

--HG--
rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 01:24:48 -04:00

100 lines
3.7 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 sts=2 et sw=2 tw=80: */
/* Copyright 2014 Mozilla Foundation and Mozilla contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef GECKO_TOUCH_INPUT_DISPATCHER_h
#define GECKO_TOUCH_INPUT_DISPATCHER_h
#include "InputData.h"
#include "Units.h"
#include "mozilla/Mutex.h"
#include <vector>
#include "mozilla/RefPtr.h"
class nsIWidget;
namespace mozilla {
namespace layers {
class CompositorVsyncScheduler;
}
// Used to resample touch events whenever a vsync event occurs. It batches
// touch moves and on every vsync, resamples the touch position to create smooth
// scrolls. We use the Android touch resample algorithm. It uses a combination of
// extrapolation and interpolation. The algorithm takes the vsync time and
// subtracts mVsyncAdjust time in ms and creates a sample time. All touch events are
// relative to this sample time. If the last touch event occurs AFTER this
// sample time, interpolate the last two touch events. If the last touch event occurs BEFORE
// this sample time, we extrapolate the last two touch events to the sample
// time. The magic numbers defined as constants are taken from android
// InputTransport.cpp.
class GeckoTouchDispatcher final
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GeckoTouchDispatcher)
public:
static GeckoTouchDispatcher* GetInstance();
void NotifyTouch(MultiTouchInput& aTouch, TimeStamp aEventTime);
void DispatchTouchEvent(MultiTouchInput aMultiTouch);
void DispatchTouchNonMoveEvent(MultiTouchInput aInput);
void DispatchTouchMoveEvents(TimeStamp aVsyncTime);
void NotifyVsync(TimeStamp aVsyncTimestamp);
void SetCompositorVsyncScheduler(layers::CompositorVsyncScheduler* aObserver);
protected:
~GeckoTouchDispatcher() {}
private:
GeckoTouchDispatcher();
void ResampleTouchMoves(MultiTouchInput& aOutTouch, TimeStamp vsyncTime);
void SendTouchEvent(MultiTouchInput& aData);
void DispatchMouseEvent(MultiTouchInput& aMultiTouch,
bool aForwardToChildren);
// mTouchQueueLock is used to protect the vector and state below
// as it is accessed on multiple threads.
Mutex mTouchQueueLock;
std::vector<MultiTouchInput> mTouchMoveEvents;
bool mHavePendingTouchMoves;
int mInflightNonMoveEvents;
// end stuff protected by mTouchQueueLock
bool mResamplingEnabled;
bool mTouchEventsFiltered;
bool mEnabledUniformityInfo;
// All times below are in nanoseconds
TimeDuration mVsyncAdjust; // Time from vsync we create sample times from
TimeDuration mMaxPredict; // How far into the future we're allowed to extrapolate
TimeDuration mMinDelta; // Minimal time difference between touches for resampling
// Amount of time between vsync and the last event that is required before we
// resample
TimeDuration mMinResampleTime;
// Threshold if a vsync event runs too far behind touch events
TimeDuration mDelayedVsyncThreshold;
// How far ahead can vsync events get ahead of touch events.
TimeDuration mOldTouchThreshold;
RefPtr<layers::CompositorVsyncScheduler> mCompositorVsyncScheduler;
};
} // namespace mozilla
#endif // GECKO_TOUCH_INPUT_DISPATCHER_h