Bug 785246: Recreate BrowserToolbar curve with low-level window functions. [r=mfinkle]
--HG-- extra : rebase_source : 28c57bcc00aa8c824ed7e25c648085a084206e35
|
@ -0,0 +1,53 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
public class BrowserToolbarBackground extends LinearLayout
|
||||
implements CanvasDelegate.DrawManager {
|
||||
Path mPath;
|
||||
CanvasDelegate mCanvasDelegate;
|
||||
|
||||
public BrowserToolbarBackground(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
// Path is clipped.
|
||||
mPath = new Path();
|
||||
mCanvasDelegate = new CanvasDelegate(this, Mode.DST_OUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
int width = getMeasuredWidth();
|
||||
int height = getMeasuredHeight();
|
||||
float curve = height * 1.125f;
|
||||
|
||||
mPath.reset();
|
||||
mPath.moveTo(width, height);
|
||||
mPath.cubicTo((width - (curve * 0.75f)), height,
|
||||
(width - (curve * 0.25f)), 0,
|
||||
(width - curve), 0);
|
||||
mPath.lineTo(width, 0);
|
||||
mPath.lineTo(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
mCanvasDelegate.draw(canvas, mPath, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defaultDraw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.os.Build;
|
||||
|
||||
public class CanvasDelegate {
|
||||
Paint mPaint;
|
||||
PorterDuffXfermode mMode;
|
||||
DrawManager mDrawManager;
|
||||
|
||||
// DrawManager would do a default draw of the background.
|
||||
public static interface DrawManager {
|
||||
public void defaultDraw(Canvas cavas);
|
||||
}
|
||||
|
||||
public CanvasDelegate(DrawManager drawManager, Mode mode) {
|
||||
mDrawManager = drawManager;
|
||||
|
||||
// DST_IN masks, DST_OUT clips.
|
||||
mMode = new PorterDuffXfermode(mode);
|
||||
|
||||
mPaint = new Paint();
|
||||
mPaint.setAntiAlias(true);
|
||||
mPaint.setColor(0xFFFF0000);
|
||||
}
|
||||
|
||||
public void draw(Canvas canvas, Path path, int width, int height) {
|
||||
// Save the canvas. All PorterDuff operations should be done in a offscreen bitmap.
|
||||
int count = canvas.saveLayer(0, 0, width, height, null,
|
||||
Canvas.MATRIX_SAVE_FLAG |
|
||||
Canvas.CLIP_SAVE_FLAG |
|
||||
Canvas.HAS_ALPHA_LAYER_SAVE_FLAG |
|
||||
Canvas.FULL_COLOR_LAYER_SAVE_FLAG |
|
||||
Canvas.CLIP_TO_LAYER_SAVE_FLAG);
|
||||
|
||||
// Do a default draw.
|
||||
mDrawManager.defaultDraw(canvas);
|
||||
|
||||
if (path != null && !path.isEmpty()) {
|
||||
// ICS added double-buffering, which made it easier for drawing the Path directly over the DST.
|
||||
// In pre-ICS, drawPath() doesn't seem to use ARGB_8888 mode for performance, hence transparency is not preserved.
|
||||
if (Build.VERSION.SDK_INT >= 14) {
|
||||
mPaint.setXfermode(mMode);
|
||||
canvas.drawPath(path, mPaint);
|
||||
} else {
|
||||
// Allocate a bitmap and draw the masking/clipping path.
|
||||
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
(new Canvas(bitmap)).drawPath(path, mPaint);
|
||||
|
||||
mPaint.setXfermode(mMode);
|
||||
canvas.drawBitmap(bitmap, 0, 0, mPaint);
|
||||
|
||||
mPaint.setXfermode(null);
|
||||
}
|
||||
}
|
||||
|
||||
// Restore the canvas.
|
||||
canvas.restoreToCount(count);
|
||||
}
|
||||
}
|
|
@ -44,6 +44,8 @@ public final class GeckoViewsFactory implements LayoutInflater.Factory {
|
|||
return new AboutHomeSection(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "AwesomeBarTabs"))
|
||||
return new AwesomeBarTabs(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "BrowserToolbarBackground"))
|
||||
return new BrowserToolbarBackground(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "FormAssistPopup"))
|
||||
return new FormAssistPopup(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "LinkTextView"))
|
||||
|
|
|
@ -51,8 +51,10 @@ FENNEC_JAVA_FILES = \
|
|||
awesomebar/HistoryTab.java \
|
||||
BrowserApp.java \
|
||||
BrowserToolbar.java \
|
||||
BrowserToolbarBackground.java \
|
||||
CameraImageResultHandler.java \
|
||||
CameraVideoResultHandler.java \
|
||||
CanvasDelegate.java \
|
||||
SyncPreference.java \
|
||||
db/BrowserDB.java \
|
||||
db/LocalBrowserDB.java \
|
||||
|
@ -464,7 +466,6 @@ RES_DRAWABLE_BASE = \
|
|||
res/drawable/address_bar_back_button.xml \
|
||||
res/drawable/address_bar_back_button_bg.xml \
|
||||
res/drawable/address_bar_back_button_pressed_bg.xml \
|
||||
res/drawable/address_bar_bg_curve.png \
|
||||
res/drawable/address_bar_forward_button.xml \
|
||||
res/drawable/address_bar_texture_port.png \
|
||||
res/drawable/address_bar_url.xml \
|
||||
|
@ -545,7 +546,6 @@ RES_DRAWABLE_HDPI = \
|
|||
res/drawable-hdpi/tabs_crop_pressed.png \
|
||||
res/drawable-hdpi/tabs_full_normal.png \
|
||||
res/drawable-hdpi/tabs_full_pressed.png \
|
||||
res/drawable-hdpi/address_bar_bg_curve.png \
|
||||
res/drawable-hdpi/address_bar_texture_port.png \
|
||||
res/drawable-hdpi/address_bar_url_default.9.png \
|
||||
res/drawable-hdpi/address_bar_url_pressed.9.png \
|
||||
|
@ -581,7 +581,6 @@ RES_DRAWABLE_XHDPI = \
|
|||
res/drawable-xhdpi/abouthome_promo_logo_apps.png \
|
||||
res/drawable-xhdpi/abouthome_promo_logo_sync.png \
|
||||
res/drawable-xhdpi/abouthome_thumbnail.png \
|
||||
res/drawable-xhdpi/address_bar_bg_curve.png \
|
||||
res/drawable-xhdpi/address_bar_bg_shadow.png \
|
||||
res/drawable-xhdpi/address_bar_texture_port.png \
|
||||
res/drawable-xhdpi/address_bar_url_default.9.png \
|
||||
|
@ -728,7 +727,6 @@ RES_DRAWABLE_LAND_V14 = \
|
|||
RES_DRAWABLE_LAND_MDPI_V14 = \
|
||||
res/drawable-land-mdpi-v14/ic_awesomebar_go.png \
|
||||
res/drawable-land-mdpi-v14/ic_awesomebar_search.png \
|
||||
res/drawable-land-mdpi-v14/address_bar_bg_curve.png \
|
||||
res/drawable-land-mdpi-v14/address_bar_texture_land.png \
|
||||
res/drawable-land-mdpi-v14/address_bar_url_default.9.png \
|
||||
res/drawable-land-mdpi-v14/address_bar_url_pressed.9.png \
|
||||
|
@ -754,7 +752,6 @@ RES_DRAWABLE_LAND_MDPI_V14 = \
|
|||
RES_DRAWABLE_LAND_HDPI_V14 = \
|
||||
res/drawable-land-hdpi-v14/ic_awesomebar_go.png \
|
||||
res/drawable-land-hdpi-v14/ic_awesomebar_search.png \
|
||||
res/drawable-land-hdpi-v14/address_bar_bg_curve.png \
|
||||
res/drawable-land-hdpi-v14/address_bar_texture_land.png \
|
||||
res/drawable-land-hdpi-v14/address_bar_url_default.9.png \
|
||||
res/drawable-land-hdpi-v14/address_bar_url_pressed.9.png \
|
||||
|
@ -780,7 +777,6 @@ RES_DRAWABLE_LAND_HDPI_V14 = \
|
|||
RES_DRAWABLE_LAND_XHDPI_V14 = \
|
||||
res/drawable-land-xhdpi-v14/ic_awesomebar_go.png \
|
||||
res/drawable-land-xhdpi-v14/ic_awesomebar_search.png \
|
||||
res/drawable-land-xhdpi-v14/address_bar_bg_curve.png \
|
||||
res/drawable-land-xhdpi-v14/address_bar_texture_land.png \
|
||||
res/drawable-land-xhdpi-v14/address_bar_url_default.9.png \
|
||||
res/drawable-land-xhdpi-v14/address_bar_url_pressed.9.png \
|
||||
|
@ -804,7 +800,6 @@ RES_DRAWABLE_LAND_XHDPI_V14 = \
|
|||
$(NULL)
|
||||
|
||||
RES_DRAWABLE_LARGE_MDPI_V11 = \
|
||||
res/drawable-large-mdpi-v11/address_bar_bg_curve.png \
|
||||
res/drawable-large-mdpi-v11/address_bar_bg.xml \
|
||||
res/drawable-large-mdpi-v11/address_bar_texture_tablet.png \
|
||||
res/drawable-large-mdpi-v11/address_bar_back_button_bg.png \
|
||||
|
@ -837,7 +832,6 @@ RES_DRAWABLE_LARGE_MDPI_V11 = \
|
|||
$(NULL)
|
||||
|
||||
RES_DRAWABLE_LARGE_HDPI_V11 = \
|
||||
res/drawable-large-hdpi-v11/address_bar_bg_curve.png \
|
||||
res/drawable-large-hdpi-v11/address_bar_texture_tablet.png \
|
||||
res/drawable-large-hdpi-v11/address_bar_back_button_bg.png \
|
||||
res/drawable-large-hdpi-v11/address_bar_back_button_pressed_bg.png \
|
||||
|
@ -869,7 +863,6 @@ RES_DRAWABLE_LARGE_HDPI_V11 = \
|
|||
$(NULL)
|
||||
|
||||
RES_DRAWABLE_LARGE_XHDPI_V11 = \
|
||||
res/drawable-large-xhdpi-v11/address_bar_bg_curve.png \
|
||||
res/drawable-large-xhdpi-v11/address_bar_texture_tablet.png \
|
||||
res/drawable-large-xhdpi-v11/address_bar_back_button_bg.png \
|
||||
res/drawable-large-xhdpi-v11/address_bar_back_button_pressed_bg.png \
|
||||
|
|
До Ширина: | Высота: | Размер: 8.6 KiB |
До Ширина: | Высота: | Размер: 6.5 KiB |
До Ширина: | Высота: | Размер: 4.0 KiB |
До Ширина: | Высота: | Размер: 9.8 KiB |
До Ширина: | Высота: | Размер: 11 KiB |
До Ширина: | Высота: | Размер: 6.0 KiB |
До Ширина: | Высота: | Размер: 17 KiB |
До Ширина: | Высота: | Размер: 14 KiB |
Двоичные данные
mobile/android/base/resources/drawable/address_bar_bg_curve.png
До Ширина: | Высота: | Размер: 4.6 KiB |
|
@ -23,18 +23,12 @@
|
|||
android:layout_height="0dip"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<View android:id="@+id/curve"
|
||||
android:layout_width="60dip"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg_curve"/>
|
||||
|
||||
<View android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_toLeftOf="@id/curve"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="14dip"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
|
||||
<ImageButton android:id="@+id/menu"
|
||||
style="@style/AddressBar.ImageButton.Unused"/>
|
||||
|
|
|
@ -23,19 +23,12 @@
|
|||
android:layout_height="0dip"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<View android:id="@+id/curve"
|
||||
android:layout_width="60dip"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="35dip"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg_curve"/>
|
||||
|
||||
<View android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_toLeftOf="@id/curve"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="50dip"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
|
||||
<ImageButton android:id="@+id/menu"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
|
|
|
@ -10,19 +10,12 @@
|
|||
<RelativeLayout android:id="@+id/address_bar"
|
||||
style="@style/AddressBar">
|
||||
|
||||
<View android:id="@+id/curve"
|
||||
android:layout_width="84dip"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="56dip"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg_curve"/>
|
||||
|
||||
<View android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_toLeftOf="@id/curve"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="75dip"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
|
||||
<ImageButton android:id="@+id/menu"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
|
|
|
@ -23,18 +23,12 @@
|
|||
android:layout_height="0dip"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<View android:id="@+id/curve"
|
||||
android:layout_width="72dip"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg_curve"/>
|
||||
|
||||
<View android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_toLeftOf="@id/curve"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="17dip"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
|
||||
<ImageButton android:id="@+id/menu"
|
||||
style="@style/AddressBar.ImageButton.Unused"/>
|
||||
|
@ -120,12 +114,12 @@
|
|||
|
||||
</FrameLayout>
|
||||
|
||||
<ImageView android:id="@+id/shadow"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/address_bar_bg_shadow_repeat"
|
||||
android:visibility="gone"/>
|
||||
<ImageView android:id="@+id/shadow"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/address_bar_bg_shadow_repeat"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
|
|
@ -23,19 +23,12 @@
|
|||
android:layout_height="0dip"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<View android:id="@+id/curve"
|
||||
android:layout_width="72dip"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="48dip"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg_curve"/>
|
||||
|
||||
<View android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_toLeftOf="@id/curve"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
<org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="64dip"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/address_bar_bg"/>
|
||||
|
||||
<ImageButton android:id="@+id/menu"
|
||||
style="@style/AddressBar.ImageButton"
|
||||
|
@ -131,12 +124,12 @@
|
|||
|
||||
</FrameLayout>
|
||||
|
||||
<ImageView android:id="@+id/shadow"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/address_bar_bg_shadow_repeat"
|
||||
android:visibility="gone"/>
|
||||
<ImageView android:id="@+id/shadow"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/address_bar_bg_shadow_repeat"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
|