2014-03-12 06:27:30 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef GFX_TextRenderer_H
|
|
|
|
#define GFX_TextRenderer_H
|
|
|
|
|
|
|
|
#include "mozilla/gfx/2D.h"
|
2014-04-14 23:04:24 +04:00
|
|
|
#include "nsISupportsImpl.h"
|
2014-03-12 06:27:30 +04:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
class Compositor;
|
|
|
|
|
2014-04-14 23:04:24 +04:00
|
|
|
class TextRenderer
|
2014-03-12 06:27:30 +04:00
|
|
|
{
|
2014-06-19 06:28:59 +04:00
|
|
|
~TextRenderer();
|
|
|
|
|
2014-03-12 06:27:30 +04:00
|
|
|
public:
|
2014-04-14 23:04:24 +04:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(TextRenderer)
|
|
|
|
|
2014-08-20 08:55:14 +04:00
|
|
|
explicit TextRenderer(Compositor *aCompositor)
|
2015-05-19 18:14:45 +03:00
|
|
|
: mCompositor(aCompositor), mMap({nullptr, 0})
|
2014-03-12 06:27:30 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void RenderText(const std::string& aText, const gfx::IntPoint& aOrigin,
|
|
|
|
const gfx::Matrix4x4& aTransform, uint32_t aTextSize,
|
|
|
|
uint32_t aTargetPixelWidth);
|
|
|
|
|
|
|
|
gfx::DataSourceSurface::MappedSurface& GetSurfaceMap() { return mMap; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2014-08-27 19:57:43 +04:00
|
|
|
// Note that this may still fail to set mGlyphBitmaps to a valid value
|
|
|
|
// if the underlying CreateDataSourceSurface fails for some reason.
|
2014-03-12 06:27:30 +04:00
|
|
|
void EnsureInitialized();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Compositor> mCompositor;
|
|
|
|
RefPtr<gfx::DataSourceSurface> mGlyphBitmaps;
|
2014-03-12 06:27:30 +04:00
|
|
|
gfx::DataSourceSurface::MappedSurface mMap;
|
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
2014-03-12 06:27:30 +04:00
|
|
|
|
|
|
|
#endif
|