mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
The NewTextPainter is still disabled by default. A future patch will flip the flag to enable it. This patch uses a new approach to writing bindings by encoding data into array buffers. This approach is more efficient than the existing IDL based approach. If this works out well, we should convert our other performance-sensitive interfaces to this approach in future patches.
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef SKY_ENGINE_CORE_TEXT_PARAGRAPHBUILDER_H_
|
|
#define SKY_ENGINE_CORE_TEXT_PARAGRAPHBUILDER_H_
|
|
|
|
#include "sky/engine/core/css/CSSFontSelector.h"
|
|
#include "sky/engine/core/css/resolver/FontBuilder.h"
|
|
#include "sky/engine/core/text/Paragraph.h"
|
|
#include "sky/engine/tonic/dart_wrappable.h"
|
|
#include "sky/engine/tonic/int32_list.h"
|
|
#include "sky/engine/wtf/PassRefPtr.h"
|
|
#include "sky/engine/wtf/RefCounted.h"
|
|
|
|
namespace blink {
|
|
|
|
class ParagraphBuilder : public RefCounted<ParagraphBuilder>, public DartWrappable {
|
|
DEFINE_WRAPPERTYPEINFO();
|
|
public:
|
|
static PassRefPtr<ParagraphBuilder> create() {
|
|
return adoptRef(new ParagraphBuilder());
|
|
}
|
|
|
|
~ParagraphBuilder() override;
|
|
|
|
void pushStyle(Int32List& encoded, const String& fontFamily, double fontSize);
|
|
void pop();
|
|
|
|
void addText(const String& text);
|
|
|
|
PassRefPtr<Paragraph> build(Int32List& encoded, double lineHeight);
|
|
|
|
private:
|
|
explicit ParagraphBuilder();
|
|
|
|
void createRenderView();
|
|
|
|
RefPtr<CSSFontSelector> m_fontSelector;
|
|
OwnPtr<RenderView> m_renderView;
|
|
RenderObject* m_renderParagraph;
|
|
RenderObject* m_currentRenderObject;
|
|
};
|
|
|
|
} // namespace blink
|
|
|
|
#endif // SKY_ENGINE_CORE_TEXT_PARAGRAPHBUILDER_H_
|