Пример #1
0
 public void vSetSel(float x1, float y1, float x2, float y2) {
   if (m_pages == null) return;
   int pcur = 0;
   int pcnt = m_pages.length;
   while (pcur < pcnt) {
     m_pages[pcur].ClearSel();
     pcur++;
   }
   PDFPos pos = vGetPos((int) x1, (int) y1);
   PDFVPage vpage = m_pages[pos.pageno];
   vpage.SetSel(x1, y1, x2, y2, m_scroller.getCurrX(), m_scroller.getCurrY());
   if (m_listener != null) m_listener.OnPDFInvalidate(false);
 }
Пример #2
0
 public void vRenderSync(PDFVPage page) {
   if (m_pages == null || page == null) return;
   m_thread.end_render(page);
   page.RenderPrepare();
   page.m_cache.Render();
   if (m_listener != null) m_listener.OnPDFInvalidate(false);
 }
Пример #3
0
 protected void vFlushRange() {
   if (m_status == STA_ZOOM) return;
   int pageno1 = vGetPage(0, 0);
   int pageno2 = vGetPage(m_w, m_h);
   if (pageno1 >= 0 && pageno2 >= 0) {
     if (pageno1 > pageno2) {
       int tmp = pageno1;
       pageno1 = pageno2;
       pageno2 = tmp;
     }
     pageno2++;
     if (m_prange_start < pageno1) {
       int start = m_prange_start;
       int end = pageno1;
       if (end > m_prange_end) end = m_prange_end;
       while (start < end) {
         PDFVPage vpage = m_pages[start];
         m_thread.end_render(vpage);
         vpage.DeleteBmp();
         start++;
       }
     }
     if (m_prange_end > pageno2) {
       int start = pageno2;
       int end = m_prange_end;
       if (start < m_prange_start) start = m_prange_start;
       while (start < end) {
         PDFVPage vpage = m_pages[start];
         m_thread.end_render(vpage);
         vpage.DeleteBmp();
         start++;
       }
     }
   } else {
     int start = m_prange_start;
     int end = m_prange_end;
     while (start < end) {
       PDFVPage vpage = m_pages[start];
       m_thread.end_render(vpage);
       vpage.DeleteBmp();
       start++;
     }
   }
   m_prange_start = pageno1;
   m_prange_end = pageno2;
   pageno1 = vGetPage(m_w / 4, m_h / 4);
   if (m_listener != null && pageno1 != m_pageno) {
     m_listener.OnPDFPageChanged(m_pageno = pageno1);
   }
 }
Пример #4
0
 public void vDraw(Canvas canvas) {
   if (m_pages == null) return;
   // long rec_time = System.currentTimeMillis();
   int left = m_scroller.getCurrX();
   int top = m_scroller.getCurrY();
   int left1 = left;
   int top1 = top;
   if (left1 > m_docw - m_w) left1 = m_docw - m_w;
   if (left1 < 0) left1 = 0;
   if (top1 > m_doch - m_h) top1 = m_doch - m_h;
   if (top1 < 0) top1 = 0;
   if (left1 != left) {
     m_scroller.setFinalX(left1);
     left = left1;
   }
   if (top1 != top) {
     m_scroller.setFinalY(top1);
     top = top1;
   }
   vFlushRange();
   int cur = m_prange_start;
   int end = m_prange_end;
   int sel_rect1[] = null;
   int sel_rect2[] = null;
   if (m_drawbmp) {
     if (Global.dark_mode) {
       m_bmp.eraseColor(m_back);
       Canvas bcan = new Canvas(m_bmp);
       while (cur < end) {
         PDFVPage vpage = m_pages[cur];
         if (m_status != STA_ZOOM) m_thread.start_render(vpage);
         vpage.Draw(bcan, left, top);
         if (sel_rect1 == null || sel_rect2 == null) {
           sel_rect1 = vpage.GetSelRect1(left, top);
           sel_rect2 = vpage.GetSelRect2(left, top);
         }
         if (m_finder.find_get_page() == cur) m_finder.find_draw(bcan, vpage, left, top);
         cur++;
       }
       m_draw_bmp.Create(m_bmp);
       m_draw_bmp.Invert();
       m_draw_bmp.Free(m_bmp);
       // Log.i("time_d1", String.valueOf(System.currentTimeMillis() - rec_time));
       canvas.drawBitmap(m_bmp, 0, 0, null);
       // Log.i("time_d2", String.valueOf(System.currentTimeMillis() - rec_time));
     } else {
       canvas.drawColor(m_back);
       while (cur < end) {
         PDFVPage vpage = m_pages[cur];
         if (m_status != STA_ZOOM) m_thread.start_render(vpage);
         if (sel_rect1 == null || sel_rect2 == null) {
           sel_rect1 = vpage.GetSelRect1(left, top);
           sel_rect2 = vpage.GetSelRect2(left, top);
         }
         vpage.Draw(canvas, left, top);
         if (m_finder.find_get_page() == cur) m_finder.find_draw(canvas, vpage, left, top);
         cur++;
       }
     }
   } else {
     m_bmp.eraseColor(m_back);
     // Log.i("time_d0", String.valueOf(System.currentTimeMillis() - rec_time));
     m_draw_bmp.Create(m_bmp);
     while (cur < end) {
       PDFVPage vpage = m_pages[cur];
       m_thread.start_render(vpage);
       if (sel_rect1 == null || sel_rect2 == null) {
         sel_rect1 = vpage.GetSelRect1(left, top);
         sel_rect2 = vpage.GetSelRect2(left, top);
       }
       vpage.Draw(m_draw_bmp, left, top);
       if (m_finder.find_get_page() == cur) m_finder.find_draw(m_draw_bmp, vpage, left, top);
       cur++;
     }
     if (Global.dark_mode) m_draw_bmp.Invert();
     m_draw_bmp.Free(m_bmp);
     // Log.i("time_d1", String.valueOf(System.currentTimeMillis() - rec_time));
     canvas.drawBitmap(m_bmp, 0, 0, null);
     // Log.i("time_d2", String.valueOf(System.currentTimeMillis() - rec_time));
   }
   if (m_listener != null) {
     cur = m_prange_start;
     end = m_prange_end;
     while (cur < end) {
       m_listener.OnPDFPageDisplayed(canvas, m_pages[cur]);
       cur++;
     }
     if (sel_rect1 != null && sel_rect2 != null)
       m_listener.OnPDFSelecting(canvas, sel_rect1, sel_rect2);
   }
   // Log.i("time_draw", String.valueOf(System.currentTimeMillis() - rec_time));
 }