diff options
author | Michael Vrhel <michael.vrhel@artifex.com> | 2013-10-23 21:31:51 -0700 |
---|---|---|
committer | Michael Vrhel <michael.vrhel@artifex.com> | 2013-10-23 21:33:33 -0700 |
commit | 52dd8a3e321bb965f8f02494026d545fddf54c01 (patch) | |
tree | ee9433ab5977e2ecec88f10197d16fd5b5d758e2 /platform/winrt/mupdf_cpp | |
parent | 3379beab77726c2be11e369113f4ca795ff883d9 (diff) | |
download | mupdf-52dd8a3e321bb965f8f02494026d545fddf54c01.tar.xz |
Fix so that multi-threaded rendering of display list works.
Proper use of mutex lock in areas where we multiple threads can
not be accessing the document or page level objects at the same
time. With this fix, multiple threads can be rendering different
display lists at the same time.
Also fix for use of page selection scroll bar so that it does not
render the page until the user lifts off the bar. This is the
same as the Android app and avoids smaller devices getting overloaded
if you do rapid scrolling in a document.
Diffstat (limited to 'platform/winrt/mupdf_cpp')
-rw-r--r-- | platform/winrt/mupdf_cpp/MainPage.xaml | 2 | ||||
-rw-r--r-- | platform/winrt/mupdf_cpp/MainPage.xaml.cpp | 75 | ||||
-rw-r--r-- | platform/winrt/mupdf_cpp/MainPage.xaml.h | 5 |
3 files changed, 38 insertions, 44 deletions
diff --git a/platform/winrt/mupdf_cpp/MainPage.xaml b/platform/winrt/mupdf_cpp/MainPage.xaml index 22fbe5da..eaf096e3 100644 --- a/platform/winrt/mupdf_cpp/MainPage.xaml +++ b/platform/winrt/mupdf_cpp/MainPage.xaml @@ -14,7 +14,7 @@ <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> - <Slider x:Name="xaml_PageSlider" Minimum="0" Maximum="10" ValueChanged="Slider_ValueChanged" Grid.Column="0" Margin="10,0" VerticalAlignment="Center" /> + <Slider x:Name="xaml_PageSlider" Minimum="0" Maximum="10" PointerCaptureLost="Slider_ValueChanged" Grid.Column="0" Margin="10,0" VerticalAlignment="Center" /> <Button x:Name="Find_File" Style="{StaticResource OpenFileAppBarButtonStyle}" Tag="OpenFile" HorizontalAlignment="Right" Grid.Column="1" Click="Picker"/> </Grid> </AppBar> diff --git a/platform/winrt/mupdf_cpp/MainPage.xaml.cpp b/platform/winrt/mupdf_cpp/MainPage.xaml.cpp index d31c2b94..166d81cf 100644 --- a/platform/winrt/mupdf_cpp/MainPage.xaml.cpp +++ b/platform/winrt/mupdf_cpp/MainPage.xaml.cpp @@ -6,7 +6,7 @@ #include "pch.h" #include "MainPage.xaml.h" -#define LOOK_AHEAD 0 /* A +/- count on the pages to pre-render */ +#define LOOK_AHEAD 1 /* A +/- count on the pages to pre-render */ #define THUMB_PREADD 10 #define MIN_SCALE 0.5 @@ -737,18 +737,44 @@ void mupdf_cpp::MainPage::RenderRange(int curr_page) } } -void mupdf_cpp::MainPage::Slider_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e) +void mupdf_cpp::MainPage::FlipView_SelectionChanged(Object^ sender, SelectionChangedEventArgs^ e) +{ + if (m_init_done && !m_page_update) + { + int pos = this->m_curr_flipView->SelectedIndex; + + if (pos >= 0) + { + if (xaml_PageSlider->IsEnabled) + { + xaml_PageSlider->Value = pos; + } + if (m_sliderchange) + { + m_sliderchange = false; + return; + } + else + { + /* Make sure to clear any text search */ + auto doc_old = this->m_docPages->GetAt(m_currpage); + doc_old->TextBox = nullptr; + } + /* Get the current page */ + int curr_page = this->m_currpage; + this->RenderRange(pos); + this->ReleasePages(curr_page, pos); + } + } +} + +void mupdf_cpp::MainPage::Slider_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) { int newValue = (int) this->xaml_PageSlider->Value - 1; /* zero based */ if (IsNotStandardView()) return; - if (m_update_flip) - { - m_update_flip = false; - return; - } if (m_init_done && this->xaml_PageSlider->IsEnabled) { /* Make sure to clear any text search */ @@ -778,38 +804,6 @@ void mupdf_cpp::MainPage::Slider_ValueChanged(Platform::Object^ sender, Windows: } } -void mupdf_cpp::MainPage::FlipView_SelectionChanged(Object^ sender, SelectionChangedEventArgs^ e) -{ - if (m_init_done && !m_page_update) - { - int pos = this->m_curr_flipView->SelectedIndex; - - if (pos >= 0) - { - m_update_flip = true; - if (xaml_PageSlider->IsEnabled) - { - xaml_PageSlider->Value = pos; - } - if (m_sliderchange) - { - m_sliderchange = false; - return; - } - else - { - /* Make sure to clear any text search */ - auto doc_old = this->m_docPages->GetAt(m_currpage); - doc_old->TextBox = nullptr; - } - /* Get the current page */ - int curr_page = this->m_currpage; - this->RenderRange(pos); - this->ReleasePages(curr_page, pos); - } - } -} - /* Search Related Code */ void mupdf_cpp::MainPage::Searcher(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { @@ -975,7 +969,8 @@ void mupdf_cpp::MainPage::SearchInDirection(int dir, String^ textToFind) ProgressBar^ my_xaml_Progress = (ProgressBar^) (this->FindName("xaml_Progress")); xaml_ProgressStack->Visibility = Windows::UI::Xaml::Visibility::Visible; - auto temp = mu_doc->SearchDocumentWithProgressAsync(textToFind, dir, start); + auto temp = mu_doc->SearchDocumentWithProgressAsync(textToFind, dir, start, + m_num_pages); temp->Progress = ref new AsyncOperationProgressHandler<int, double>(this, &MainPage::SearchProgress); auto search_task = create_task(temp, token); diff --git a/platform/winrt/mupdf_cpp/MainPage.xaml.h b/platform/winrt/mupdf_cpp/MainPage.xaml.h index 80978bc8..417073e4 100644 --- a/platform/winrt/mupdf_cpp/MainPage.xaml.h +++ b/platform/winrt/mupdf_cpp/MainPage.xaml.h @@ -109,7 +109,6 @@ namespace mupdf_cpp bool m_insearch; /* Used for UI display */ bool m_search_active; /* Used to avoid multiple UI clicks */ bool m_sliderchange; - bool m_update_flip; double m_Progress; void ReplaceImage(int page_num, InMemoryRandomAccessStream^ ras, Point ras_size); @@ -125,7 +124,6 @@ namespace mupdf_cpp void HandleFileNotFoundException(Platform::COMException^ e); void NotifyUserFileNotExist(); void SetFlipView(); - void Slider_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e); void Slider_Released(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e); void FlipView_SelectionChanged(Object^ sender, SelectionChangedEventArgs^ e); void SearchNext(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); @@ -173,5 +171,6 @@ namespace mupdf_cpp void Page_Loaded(Object^ sender, RoutedEventArgs^ e); Windows::ApplicationModel::Activation::ProtocolActivatedEventArgs^ _protocolEventArgs; Windows::ApplicationModel::Activation::FileActivatedEventArgs^ _fileEventArgs; - }; + void Slider_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e); +}; } |