Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f10bc378
authored
Dec 17, 2019
by
ibaker
Committed by
Oliver Woodman
Dec 18, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Migrate usages of Cue's bitmap constructor to Cue.Builder
PiperOrigin-RevId: 285956436
parent
04b1782a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
66 deletions
library/core/src/main/java/com/google/android/exoplayer2/text/Cue.java
library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbParser.java
library/core/src/main/java/com/google/android/exoplayer2/text/pgs/PgsDecoder.java
library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlNode.java
library/core/src/main/java/com/google/android/exoplayer2/text/Cue.java
View file @
f10bc378
...
...
@@ -228,50 +228,6 @@ public final class Cue {
public
final
float
textSize
;
/**
* Creates an image cue.
*
* @param bitmap See {@link #bitmap}.
* @param horizontalPosition The position of the horizontal anchor within the viewport, expressed
* as a fraction of the viewport width.
* @param horizontalPositionAnchor The horizontal anchor. One of {@link #ANCHOR_TYPE_START},
* {@link #ANCHOR_TYPE_MIDDLE}, {@link #ANCHOR_TYPE_END} and {@link #TYPE_UNSET}.
* @param verticalPosition The position of the vertical anchor within the viewport, expressed as a
* fraction of the viewport height.
* @param verticalPositionAnchor The vertical anchor. One of {@link #ANCHOR_TYPE_START}, {@link
* #ANCHOR_TYPE_MIDDLE}, {@link #ANCHOR_TYPE_END} and {@link #TYPE_UNSET}.
* @param width The width of the cue as a fraction of the viewport width.
* @param height The height of the cue as a fraction of the viewport height, or {@link
* #DIMEN_UNSET} if the bitmap should be displayed at its natural height for the specified
* {@code width}.
* @deprecated Use {@link Builder}.
*/
@Deprecated
public
Cue
(
Bitmap
bitmap
,
float
horizontalPosition
,
@AnchorType
int
horizontalPositionAnchor
,
float
verticalPosition
,
@AnchorType
int
verticalPositionAnchor
,
float
width
,
float
height
)
{
this
(
/* text= */
null
,
/* textAlignment= */
null
,
bitmap
,
verticalPosition
,
/* lineType= */
LINE_TYPE_FRACTION
,
verticalPositionAnchor
,
horizontalPosition
,
horizontalPositionAnchor
,
/* textSizeType= */
TYPE_UNSET
,
/* textSize= */
DIMEN_UNSET
,
width
,
height
,
/* windowColorSet= */
false
,
/* windowColor= */
Color
.
BLACK
);
}
/**
* Creates a text cue whose {@link #textAlignment} is null, whose type parameters are set to
* {@link #TYPE_UNSET} and whose dimension parameters are set to {@link #DIMEN_UNSET}.
*
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbParser.java
View file @
f10bc378
...
...
@@ -208,12 +208,23 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
fillRegionPaint
);
}
Bitmap
cueBitmap
=
Bitmap
.
createBitmap
(
bitmap
,
baseHorizontalAddress
,
baseVerticalAddress
,
regionComposition
.
width
,
regionComposition
.
height
);
cues
.
add
(
new
Cue
(
cueBitmap
,
(
float
)
baseHorizontalAddress
/
displayDefinition
.
width
,
Cue
.
ANCHOR_TYPE_START
,
(
float
)
baseVerticalAddress
/
displayDefinition
.
height
,
Cue
.
ANCHOR_TYPE_START
,
(
float
)
regionComposition
.
width
/
displayDefinition
.
width
,
(
float
)
regionComposition
.
height
/
displayDefinition
.
height
));
cues
.
add
(
new
Cue
.
Builder
()
.
setBitmap
(
Bitmap
.
createBitmap
(
bitmap
,
baseHorizontalAddress
,
baseVerticalAddress
,
regionComposition
.
width
,
regionComposition
.
height
))
.
setPosition
((
float
)
baseHorizontalAddress
/
displayDefinition
.
width
)
.
setPositionAnchor
(
Cue
.
ANCHOR_TYPE_START
)
.
setLine
(
(
float
)
baseVerticalAddress
/
displayDefinition
.
height
,
Cue
.
LINE_TYPE_FRACTION
)
.
setLineAnchor
(
Cue
.
ANCHOR_TYPE_START
)
.
setSize
((
float
)
regionComposition
.
width
/
displayDefinition
.
width
)
.
setBitmapHeight
((
float
)
regionComposition
.
height
/
displayDefinition
.
height
)
.
build
());
canvas
.
drawColor
(
Color
.
TRANSPARENT
,
PorterDuff
.
Mode
.
CLEAR
);
// Restore clean clipping state.
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/pgs/PgsDecoder.java
View file @
f10bc378
...
...
@@ -235,14 +235,15 @@ public final class PgsDecoder extends SimpleSubtitleDecoder {
Bitmap
bitmap
=
Bitmap
.
createBitmap
(
argbBitmapData
,
bitmapWidth
,
bitmapHeight
,
Bitmap
.
Config
.
ARGB_8888
);
// Build the cue.
return
new
Cue
(
bitmap
,
(
float
)
bitmapX
/
planeWidth
,
Cue
.
ANCHOR_TYPE_START
,
(
float
)
bitmapY
/
planeHeight
,
Cue
.
ANCHOR_TYPE_START
,
(
float
)
bitmapWidth
/
planeWidth
,
(
float
)
bitmapHeight
/
planeHeight
);
return
new
Cue
.
Builder
()
.
setBitmap
(
bitmap
)
.
setPosition
((
float
)
bitmapX
/
planeWidth
)
.
setPositionAnchor
(
Cue
.
ANCHOR_TYPE_START
)
.
setLine
((
float
)
bitmapY
/
planeHeight
,
Cue
.
LINE_TYPE_FRACTION
)
.
setLineAnchor
(
Cue
.
ANCHOR_TYPE_START
)
.
setSize
((
float
)
bitmapWidth
/
planeWidth
)
.
setBitmapHeight
((
float
)
bitmapHeight
/
planeHeight
)
.
build
();
}
public
void
reset
()
{
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlNode.java
View file @
f10bc378
...
...
@@ -228,14 +228,15 @@ import java.util.TreeSet;
TtmlRegion
region
=
regionMap
.
get
(
regionImagePair
.
first
);
cues
.
add
(
new
Cue
(
bitmap
,
region
.
position
,
Cue
.
ANCHOR_TYPE_START
,
region
.
line
,
region
.
lineAnchor
,
region
.
width
,
region
.
height
));
new
Cue
.
Builder
()
.
setBitmap
(
bitmap
)
.
setPosition
(
region
.
position
)
.
setPositionAnchor
(
Cue
.
ANCHOR_TYPE_START
)
.
setLine
(
region
.
line
,
Cue
.
LINE_TYPE_FRACTION
)
.
setLineAnchor
(
region
.
lineAnchor
)
.
setSize
(
region
.
width
)
.
setBitmapHeight
(
region
.
height
)
.
build
());
}
// Create text based cues.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment