зеркало из https://github.com/mozilla/pjs.git
Put back some things left out of dougt's merge
This commit is contained in:
Родитель
0cd49f54de
Коммит
e7d3aade18
|
@ -597,14 +597,12 @@ BasicBufferOGL::BeginPaint(ContentType aContentType,
|
|||
// of the buffer. We need to invalidate the remaining sections so that they get redrawn too.
|
||||
// Alternatively we could teach BlitTextureImage to rearrange the rotated segments onto
|
||||
// the new buffer.
|
||||
|
||||
|
||||
// When the rotated buffer is reorganised, the bottom-right section will be drawn in the top left.
|
||||
// Find the point where this content ends.
|
||||
|
||||
nsIntPoint rotationPoint(mBufferRect.x + mBufferRect.width - mBufferRotation.x,
|
||||
mBufferRect.y + mBufferRect.height - mBufferRotation.y);
|
||||
|
||||
// Mark the remaining quadrants (bottom-left&right, top-right) as invalid.
|
||||
// The buffer looks like:
|
||||
// ______
|
||||
// |1 |2 | Where the center point is offset by mBufferRotation from the top-left corner.
|
||||
|
@ -621,6 +619,7 @@ BasicBufferOGL::BeginPaint(ContentType aContentType,
|
|||
//
|
||||
// Quadrants 2 and 1
|
||||
nsIntRect bottom(mBufferRect.x, rotationPoint.y, mBufferRect.width, mBufferRotation.y);
|
||||
// Quadrant 3
|
||||
nsIntRect topright(rotationPoint.x, mBufferRect.y, mBufferRotation.x, rotationPoint.y - mBufferRect.y);
|
||||
|
||||
if (!bottom.IsEmpty()) {
|
||||
|
|
|
@ -571,7 +571,7 @@ abstract public class GeckoApp
|
|||
public class SessionSnapshotRunnable implements Runnable {
|
||||
Tab mThumbnailTab;
|
||||
SessionSnapshotRunnable(Tab thumbnailTab) {
|
||||
mThumbnailTab = thumbnailTab;
|
||||
mThumbnailTab = thumbnailTab;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
|
|
@ -60,11 +60,12 @@ public class GeckoGLLayerClient extends GeckoLayerClient
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean beginDrawing(int width, int height, int tileWidth, int tileHeight,
|
||||
String metadata, boolean hasDirectTexture) {
|
||||
if (!super.beginDrawing(width, height, tileWidth, tileHeight, metadata,
|
||||
hasDirectTexture)) {
|
||||
return false;
|
||||
public Rect beginDrawing(int width, int height, int tileWidth, int tileHeight,
|
||||
String metadata, boolean hasDirectTexture) {
|
||||
Rect bufferRect = super.beginDrawing(width, height, tileWidth, tileHeight,
|
||||
metadata, hasDirectTexture);
|
||||
if (bufferRect == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Be sure to adjust the buffer size; if it's not at least as large as the viewport size,
|
||||
|
@ -74,7 +75,7 @@ public class GeckoGLLayerClient extends GeckoLayerClient
|
|||
mBufferSize = new IntSize(width, height);
|
||||
}
|
||||
|
||||
return true;
|
||||
return bufferRect;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -50,6 +50,7 @@ import android.graphics.Bitmap;
|
|||
import android.graphics.Color;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.os.SystemClock;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
|
@ -123,22 +124,24 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent
|
|||
sendResizeEventIfNecessary();
|
||||
}
|
||||
|
||||
public boolean beginDrawing(int width, int height, int tileWidth, int tileHeight,
|
||||
String metadata, boolean hasDirectTexture) {
|
||||
public Rect beginDrawing(int width, int height, int tileWidth, int tileHeight,
|
||||
String metadata, boolean hasDirectTexture) {
|
||||
Log.e(LOGTAG, "### beginDrawing " + width + " " + height + " " + tileWidth + " " +
|
||||
tileHeight + " " + hasDirectTexture);
|
||||
|
||||
// If we've changed surface types, cancel this draw
|
||||
if (handleDirectTextureChange(hasDirectTexture)) {
|
||||
Log.e(LOGTAG, "### Cancelling draw due to direct texture change");
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!shouldDrawProceed(tileWidth, tileHeight)) {
|
||||
Log.e(LOGTAG, "### Cancelling draw due to shouldDrawProceed()");
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
LayerController controller = getLayerController();
|
||||
|
||||
try {
|
||||
JSONObject viewportObject = new JSONObject(metadata);
|
||||
mNewGeckoViewport = new ViewportMetrics(viewportObject);
|
||||
|
@ -149,16 +152,54 @@ public abstract class GeckoLayerClient extends LayerClient implements GeckoEvent
|
|||
String backgroundColorString = viewportObject.optString("backgroundColor");
|
||||
if (backgroundColorString != null && !backgroundColorString.equals(mLastCheckerboardColor)) {
|
||||
mLastCheckerboardColor = backgroundColorString;
|
||||
LayerController controller = getLayerController();
|
||||
controller.setCheckerboardColor(parseColorFromGecko(backgroundColorString));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Log.e(LOGTAG, "Aborting draw, bad viewport description: " + metadata);
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// Make sure we don't spend time painting areas we aren't interested in.
|
||||
// Only do this if the Gecko viewport isn't going to override our viewport.
|
||||
Rect bufferRect = new Rect(0, 0, width, height);
|
||||
|
||||
if (!mUpdateViewportOnEndDraw) {
|
||||
// First, find out our ideal displayport. We do this by taking the
|
||||
// clamped viewport origin and taking away the optimum viewport offset.
|
||||
// This would be what we would send to Gecko if adjustViewport were
|
||||
// called now.
|
||||
ViewportMetrics currentMetrics = controller.getViewportMetrics();
|
||||
PointF currentBestOrigin = RectUtils.getOrigin(currentMetrics.getClampedViewport());
|
||||
PointF viewportOffset = currentMetrics.getOptimumViewportOffset(new IntSize(width, height));
|
||||
currentBestOrigin.offset(-viewportOffset.x, -viewportOffset.y);
|
||||
|
||||
Rect currentRect = RectUtils.round(new RectF(currentBestOrigin.x, currentBestOrigin.y,
|
||||
currentBestOrigin.x + width, currentBestOrigin.y + height));
|
||||
|
||||
// Second, store Gecko's displayport.
|
||||
PointF currentOrigin = mNewGeckoViewport.getDisplayportOrigin();
|
||||
bufferRect = RectUtils.round(new RectF(currentOrigin.x, currentOrigin.y,
|
||||
currentOrigin.x + width, currentOrigin.y + height));
|
||||
|
||||
|
||||
// Take the intersection of the two as the area we're interested in rendering.
|
||||
if (!bufferRect.intersect(currentRect)) {
|
||||
// If there's no intersection, we have no need to render anything,
|
||||
// but make sure to update the viewport size.
|
||||
beginTransaction(mTileLayer);
|
||||
try {
|
||||
updateViewport(true);
|
||||
} finally {
|
||||
endTransaction(mTileLayer);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
bufferRect.offset(Math.round(-currentOrigin.x), Math.round(-currentOrigin.y));
|
||||
}
|
||||
|
||||
beginTransaction(mTileLayer);
|
||||
return true;
|
||||
return bufferRect;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -163,30 +163,12 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean beginDrawing(int width, int height, int tileWidth, int tileHeight,
|
||||
String metadata, boolean hasDirectTexture) {
|
||||
if (!super.beginDrawing(width, height, tileWidth, tileHeight, metadata,
|
||||
hasDirectTexture)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We only need to set a render offset/allocate buffer memory if
|
||||
// we're using MultiTileLayer. Otherwise, just synchronise the
|
||||
// buffer size and return.
|
||||
if (!(mTileLayer instanceof MultiTileLayer)) {
|
||||
if (mBufferSize.width != width || mBufferSize.height != height)
|
||||
mBufferSize = new IntSize(width, height);
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the origin has changed, alter the rendering offset so that
|
||||
// rendering is snapped to the tile grid and clear the invalid area.
|
||||
boolean originChanged = true;
|
||||
Point origin = PointUtils.round(mNewGeckoViewport.getDisplayportOrigin());
|
||||
|
||||
if (mGeckoViewport != null) {
|
||||
Point oldOrigin = PointUtils.round(mGeckoViewport.getDisplayportOrigin());
|
||||
originChanged = !origin.equals(oldOrigin);
|
||||
public Rect beginDrawing(int width, int height, int tileWidth, int tileHeight,
|
||||
String metadata, boolean hasDirectTexture) {
|
||||
Rect bufferRect = super.beginDrawing(width, height, tileWidth, tileHeight,
|
||||
metadata, hasDirectTexture);
|
||||
if (bufferRect == null) {
|
||||
return bufferRect;
|
||||
}
|
||||
|
||||
// If the window size has changed, reallocate the buffer to match.
|
||||
|
@ -209,7 +191,7 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient {
|
|||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return bufferRect;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -321,6 +303,7 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient {
|
|||
throw new RuntimeException("Screen size of " + mScreenSize +
|
||||
" larger than maximum texture size of " + maxSize);
|
||||
}
|
||||
|
||||
// Round to next power of two until we have NPOT texture support, respecting maximum
|
||||
// texture size
|
||||
return new IntSize(Math.min(maxSize, IntSize.nextPowerOfTwo(mScreenSize.width +
|
||||
|
@ -334,6 +317,5 @@ public class GeckoSoftwareLayerClient extends GeckoLayerClient {
|
|||
// Round up depending on layer implementation to remove texture wastage
|
||||
return !mHasDirectTexture ? TILE_SIZE : new IntSize(0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -356,7 +356,7 @@ AndroidGeckoLayerClient::InitGeckoLayerClientClass(JNIEnv *jEnv)
|
|||
|
||||
jGeckoLayerClientClass = getClassGlobalRef("org/mozilla/gecko/gfx/GeckoLayerClient");
|
||||
|
||||
jBeginDrawingMethod = getMethod("beginDrawing", "(IIIILjava/lang/String;Z)Z");
|
||||
jBeginDrawingMethod = getMethod("beginDrawing", "(IIIILjava/lang/String;Z)Landroid/graphics/Rect;");
|
||||
jEndDrawingMethod = getMethod("endDrawing", "(IIII)V");
|
||||
#endif
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ AndroidGeckoSoftwareLayerClient::InitGeckoSoftwareLayerClientClass(JNIEnv *jEnv)
|
|||
|
||||
jLockBufferMethod = getMethod("lockBuffer", "()Ljava/nio/ByteBuffer;");
|
||||
jUnlockBufferMethod = getMethod("unlockBuffer", "()V");
|
||||
jBeginDrawingMethod = getMethod("beginDrawing", "(IIIILjava/lang/String;Z)Z");
|
||||
jBeginDrawingMethod = getMethod("beginDrawing", "(IIIILjava/lang/String;Z)Landroid/graphics/Rect;");
|
||||
jEndDrawingMethod = getMethod("endDrawing", "(IIII)V");
|
||||
#endif
|
||||
}
|
||||
|
@ -782,7 +782,7 @@ AndroidGeckoSurfaceView::Draw2D(jobject buffer, int stride)
|
|||
|
||||
bool
|
||||
AndroidGeckoLayerClient::BeginDrawing(int aWidth, int aHeight, int aTileWidth, int aTileHeight,
|
||||
const nsAString &aMetadata, bool aHasDirectTexture)
|
||||
nsIntRect &aDirtyRect, const nsAString &aMetadata, bool aHasDirectTexture)
|
||||
{
|
||||
NS_ASSERTION(!isNull(), "BeginDrawing() called on null layer client!");
|
||||
JNIEnv *env = AndroidBridge::GetJNIEnv();
|
||||
|
@ -791,8 +791,20 @@ AndroidGeckoLayerClient::BeginDrawing(int aWidth, int aHeight, int aTileWidth, i
|
|||
|
||||
AndroidBridge::AutoLocalJNIFrame(env, 1);
|
||||
jstring jMetadata = env->NewString(nsPromiseFlatString(aMetadata).get(), aMetadata.Length());
|
||||
return env->CallBooleanMethod(wrapped_obj, jBeginDrawingMethod, aWidth, aHeight, aTileWidth,
|
||||
aTileHeight, jMetadata, aHasDirectTexture);
|
||||
|
||||
jobject rectObject = env->CallObjectMethod(wrapped_obj, jBeginDrawingMethod,
|
||||
aWidth, aHeight, aTileWidth, aTileHeight,
|
||||
jMetadata, aHasDirectTexture);
|
||||
|
||||
if (rectObject == nsnull)
|
||||
return false;
|
||||
|
||||
AndroidRect rect(env, rectObject);
|
||||
nsIntRect newDirtyRect = aDirtyRect.Intersect(nsIntRect(rect.Top(), rect.Left(),
|
||||
rect.Width(), rect.Height()));
|
||||
aDirtyRect.SetRect(newDirtyRect.x, newDirtyRect.y, newDirtyRect.width, newDirtyRect.height);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -160,7 +160,7 @@ public:
|
|||
void Init(jobject jobj);
|
||||
|
||||
bool BeginDrawing(int aWidth, int aHeight, int aTileWidth, int aTileHeight,
|
||||
const nsAString &aMetadata, bool aHasDirectTexture);
|
||||
nsIntRect &aDirtyRect, const nsAString &aMetadata, bool aHasDirectTexture);
|
||||
void EndDrawing(const nsIntRect &aRect);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1257,7 +1257,12 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
|
|||
metadataProvider->GetDrawMetadata(metadata);
|
||||
}
|
||||
|
||||
nsIntRect dirtyRect = ae->Rect().Intersect(nsIntRect(0, 0, gAndroidBounds.width, gAndroidBounds.height));
|
||||
#if 0
|
||||
// BEGIN HACK: gl layers
|
||||
nsPaintEvent event(true, NS_PAINT, this);
|
||||
nsIntRect tileRect(0, 0, gAndroidBounds.width, gAndroidBounds.height);
|
||||
event.region = tileRect;
|
||||
#endif
|
||||
|
||||
static unsigned char *bits2 = NULL;
|
||||
static gfxIntSize bitsSize(0, 0);
|
||||
|
@ -1273,10 +1278,24 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
|
|||
new gfxImageSurface(bits2, gfxIntSize(32, 32), 32 * 2,
|
||||
gfxASurface::ImageFormatRGB16_565);
|
||||
|
||||
#if 0
|
||||
nsRefPtr<gfxContext> ctx = new gfxContext(targetSurface);
|
||||
AutoLayerManagerSetup setupLayerManager(this, ctx, BasicLayerManager::BUFFER_NONE);
|
||||
|
||||
nsEventStatus status;
|
||||
status = DispatchEvent(&event);
|
||||
|
||||
return;
|
||||
// END HACK: gl layers
|
||||
#endif
|
||||
|
||||
nsIntRect dirtyRect = ae->Rect().Intersect(nsIntRect(0, 0, gAndroidBounds.width, gAndroidBounds.height));
|
||||
|
||||
AndroidGeckoLayerClient &client = AndroidBridge::Bridge()->GetLayerClient();
|
||||
if (!client.BeginDrawing(gAndroidBounds.width, gAndroidBounds.height,
|
||||
gAndroidTileSize.width, gAndroidTileSize.height,
|
||||
metadata, HasDirectTexture())) {
|
||||
dirtyRect, metadata, HasDirectTexture())) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### BeginDrawing returned false!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче