/** Recalculates page rectangles. */ private void updatePageRects() { if (mViewRect.width() == 0 || mViewRect.height() == 0) { return; } else if (mViewMode == SHOW_ONE_PAGE) { mPageRectRight.set(mViewRect); mPageRectRight.left += mViewRect.width() * mMargins.left; mPageRectRight.right -= mViewRect.width() * mMargins.right; mPageRectRight.top += mViewRect.height() * mMargins.top; mPageRectRight.bottom -= mViewRect.height() * mMargins.bottom; mPageRectLeft.set(mPageRectRight); mPageRectLeft.offset(-mPageRectRight.width(), 0); int bitmapW = (int) ((mPageRectRight.width() * mViewportWidth) / mViewRect.width()); int bitmapH = (int) ((mPageRectRight.height() * mViewportHeight) / mViewRect.height()); mObserver.onPageSizeChanged(bitmapW, bitmapH); } else if (mViewMode == SHOW_TWO_PAGES) { mPageRectRight.set(mViewRect); mPageRectRight.left += mViewRect.width() * mMargins.left; mPageRectRight.right -= mViewRect.width() * mMargins.right; mPageRectRight.top += mViewRect.height() * mMargins.top; mPageRectRight.bottom -= mViewRect.height() * mMargins.bottom; mPageRectLeft.set(mPageRectRight); mPageRectLeft.right = (mPageRectLeft.right + mPageRectLeft.left) / 2; mPageRectRight.left = mPageRectLeft.right; int bitmapW = (int) ((mPageRectRight.width() * mViewportWidth) / mViewRect.width()); int bitmapH = (int) ((mPageRectRight.height() * mViewportHeight) / mViewRect.height()); mObserver.onPageSizeChanged(bitmapW, bitmapH); } }
@Override public synchronized void onDrawFrame(GL10 gl) { mObserver.onDrawFrame(); if (mBackgroundColorChanged) { gl.glClearColor( Color.red(mBackgroundColor) / 255f, Color.green(mBackgroundColor) / 255f, Color.blue(mBackgroundColor) / 255f, Color.alpha(mBackgroundColor) / 255f); mBackgroundColorChanged = false; } gl.glClear(GL10.GL_COLOR_BUFFER_BIT); // | GL10.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); if (USE_PERSPECTIVE_PROJECTION) { gl.glTranslatef(0, 0, -6f); } for (int i = 0; i < mCurlMeshes.size(); ++i) { mCurlMeshes.get(i).onDrawFrame(gl); } }
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { gl.glClearColor(0f, 0f, 0f, 1f); gl.glShadeModel(GL10.GL_SMOOTH); gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST); gl.glHint(GL10.GL_LINE_SMOOTH_HINT, GL10.GL_NICEST); gl.glHint(GL10.GL_POLYGON_SMOOTH_HINT, GL10.GL_NICEST); gl.glEnable(GL10.GL_LINE_SMOOTH); gl.glDisable(GL10.GL_DEPTH_TEST); gl.glDisable(GL10.GL_CULL_FACE); mObserver.onSurfaceCreated(); }