Commit 8d0a42f1 authored by Dominik Röttsches's avatar Dominik Röttsches Committed by Commit Bot

Merge BlobRotation and CanvasRotationInVertical

Bug: 788725
Change-Id: I09d62b7df3f739006972a27f35ab26da4808e310
Reviewed-on: https://chromium-review.googlesource.com/807933Reviewed-by: default avatarFlorin Malita <fmalita@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521698}
parent 9a9083e4
...@@ -114,8 +114,7 @@ void DrawBlobs(PaintCanvas* canvas, ...@@ -114,8 +114,7 @@ void DrawBlobs(PaintCanvas* canvas,
for (const auto& blob_info : blobs) { for (const auto& blob_info : blobs) {
DCHECK(blob_info.blob); DCHECK(blob_info.blob);
PaintCanvasAutoRestore auto_restore(canvas, false); PaintCanvasAutoRestore auto_restore(canvas, false);
if (blob_info.rotation == if (blob_info.rotation == CanvasRotationInVertical::kRotateCanvasUpright) {
ShapeResultBloberizer::BlobRotation::kCCWRotation) {
canvas->save(); canvas->save();
SkMatrix m; SkMatrix m;
...@@ -289,7 +288,7 @@ unsigned InterceptsFromBlobs(const ShapeResultBloberizer::BlobBuffer& blobs, ...@@ -289,7 +288,7 @@ unsigned InterceptsFromBlobs(const ShapeResultBloberizer::BlobBuffer& blobs,
// for a change in font. A TextBlob can contain runs with differing fonts // for a change in font. A TextBlob can contain runs with differing fonts
// and the getTextBlobIntercepts method handles multiple fonts for us. For // and the getTextBlobIntercepts method handles multiple fonts for us. For
// upright in vertical blobs we currently have to bail, see crbug.com/655154 // upright in vertical blobs we currently have to bail, see crbug.com/655154
if (blob_info.rotation == ShapeResultBloberizer::BlobRotation::kCCWRotation) if (blob_info.rotation == CanvasRotationInVertical::kRotateCanvasUpright)
continue; continue;
SkScalar* offset_intercepts_buffer = nullptr; SkScalar* offset_intercepts_buffer = nullptr;
......
...@@ -32,12 +32,11 @@ void ShapeResultBloberizer::CommitPendingRun() { ...@@ -32,12 +32,11 @@ void ShapeResultBloberizer::CommitPendingRun() {
if (pending_glyphs_.IsEmpty()) if (pending_glyphs_.IsEmpty())
return; return;
const auto pending_rotation = GetBlobRotation(pending_canvas_rotation_); if (pending_canvas_rotation_ != builder_rotation_) {
if (pending_rotation != builder_rotation_) {
// The pending run rotation doesn't match the current blob; start a new // The pending run rotation doesn't match the current blob; start a new
// blob. // blob.
CommitPendingBlob(); CommitPendingBlob();
builder_rotation_ = pending_rotation; builder_rotation_ = pending_canvas_rotation_;
} }
PaintFont run_font; PaintFont run_font;
...@@ -75,15 +74,6 @@ const ShapeResultBloberizer::BlobBuffer& ShapeResultBloberizer::Blobs() { ...@@ -75,15 +74,6 @@ const ShapeResultBloberizer::BlobBuffer& ShapeResultBloberizer::Blobs() {
return blobs_; return blobs_;
} }
// TODO(drott) crbug.com/788725: Try to merge BlobRotation and
// CanvasRotationInVertical.
ShapeResultBloberizer::BlobRotation ShapeResultBloberizer::GetBlobRotation(
const CanvasRotationInVertical canvas_rotation) {
return canvas_rotation == CanvasRotationInVertical::kRegular
? BlobRotation::kNoRotation
: BlobRotation::kCCWRotation;
}
float ShapeResultBloberizer::FillGlyphs( float ShapeResultBloberizer::FillGlyphs(
const TextRunPaintInfo& run_info, const TextRunPaintInfo& run_info,
const ShapeResultBuffer& result_buffer) { const ShapeResultBuffer& result_buffer) {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define ShapeResultBloberizer_h #define ShapeResultBloberizer_h
#include "platform/PlatformExport.h" #include "platform/PlatformExport.h"
#include "platform/fonts/CanvasRotationInVertical.h"
#include "platform/fonts/Glyph.h" #include "platform/fonts/Glyph.h"
#include "platform/fonts/SimpleFontData.h" #include "platform/fonts/SimpleFontData.h"
#include "platform/fonts/shaping/ShapeResultBuffer.h" #include "platform/fonts/shaping/ShapeResultBuffer.h"
...@@ -60,7 +61,7 @@ class PLATFORM_EXPORT ShapeResultBloberizer { ...@@ -60,7 +61,7 @@ class PLATFORM_EXPORT ShapeResultBloberizer {
CommitPendingRun(); CommitPendingRun();
pending_font_data_ = font_data; pending_font_data_ = font_data;
pending_canvas_rotation_ = canvas_rotation; pending_canvas_rotation_ = canvas_rotation;
DCHECK_EQ(GetBlobRotation(canvas_rotation), BlobRotation::kNoRotation); DCHECK_EQ(canvas_rotation, CanvasRotationInVertical::kRegular);
} }
pending_glyphs_.push_back(glyph); pending_glyphs_.push_back(glyph);
...@@ -80,7 +81,7 @@ class PLATFORM_EXPORT ShapeResultBloberizer { ...@@ -80,7 +81,7 @@ class PLATFORM_EXPORT ShapeResultBloberizer {
pending_font_data_ = font_data; pending_font_data_ = font_data;
pending_canvas_rotation_ = canvas_rotation; pending_canvas_rotation_ = canvas_rotation;
pending_vertical_baseline_x_offset_ = pending_vertical_baseline_x_offset_ =
GetBlobRotation(canvas_rotation) == BlobRotation::kNoRotation canvas_rotation == CanvasRotationInVertical::kRegular
? 0 ? 0
: font_data->GetFontMetrics().FloatAscent() - : font_data->GetFontMetrics().FloatAscent() -
font_data->GetFontMetrics().FloatAscent( font_data->GetFontMetrics().FloatAscent(
...@@ -93,12 +94,11 @@ class PLATFORM_EXPORT ShapeResultBloberizer { ...@@ -93,12 +94,11 @@ class PLATFORM_EXPORT ShapeResultBloberizer {
pending_offsets_.push_back(offset.Y()); pending_offsets_.push_back(offset.Y());
} }
enum class BlobRotation { kNoRotation, kCCWRotation };
struct BlobInfo { struct BlobInfo {
BlobInfo(scoped_refptr<PaintTextBlob> b, BlobRotation r) BlobInfo(scoped_refptr<PaintTextBlob> b, CanvasRotationInVertical r)
: blob(std::move(b)), rotation(r) {} : blob(std::move(b)), rotation(r) {}
scoped_refptr<PaintTextBlob> blob; scoped_refptr<PaintTextBlob> blob;
BlobRotation rotation; CanvasRotationInVertical rotation;
}; };
using BlobBuffer = Vector<BlobInfo, 16>; using BlobBuffer = Vector<BlobInfo, 16>;
...@@ -142,7 +142,6 @@ class PLATFORM_EXPORT ShapeResultBloberizer { ...@@ -142,7 +142,6 @@ class PLATFORM_EXPORT ShapeResultBloberizer {
void CommitPendingBlob(); void CommitPendingBlob();
bool HasPendingVerticalOffsets() const; bool HasPendingVerticalOffsets() const;
static BlobRotation GetBlobRotation(const CanvasRotationInVertical);
const Font& font_; const Font& font_;
const float device_scale_factor_; const float device_scale_factor_;
...@@ -150,7 +149,8 @@ class PLATFORM_EXPORT ShapeResultBloberizer { ...@@ -150,7 +149,8 @@ class PLATFORM_EXPORT ShapeResultBloberizer {
// Current text blob state. // Current text blob state.
PaintTextBlobBuilder builder_; PaintTextBlobBuilder builder_;
BlobRotation builder_rotation_ = BlobRotation::kNoRotation; CanvasRotationInVertical builder_rotation_ =
CanvasRotationInVertical::kRegular;
size_t builder_run_count_ = 0; size_t builder_run_count_ = 0;
// Current run state. // Current run state.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment