Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1384)

Unified Diff: ppapi/shared_impl/font_impl.h

Issue 6981001: Make the Pepper proxy support in-process font rendering. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/shared_impl/font_impl.h
===================================================================
--- ppapi/shared_impl/font_impl.h (revision 0)
+++ ppapi/shared_impl/font_impl.h (revision 0)
@@ -0,0 +1,123 @@
+// Copyright (c) 2011 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 PPAPI_SHARED_IMPL_FONT_IMPL_H_
+#define PPAPI_SHARED_IMPL_FONT_IMPL_H_
+#pragma once
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/scoped_ptr.h"
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_stdint.h"
+
+struct PP_FontDescription_Dev;
+struct PP_FontMetrics_Dev;
+struct PP_Point;
+struct PP_Rect;
+
+namespace base {
+class WaitableEvent;
+}
+
+namespace skia {
+class PlatformCanvas;
+} // namespace skia
+
+namespace WebKit {
+class WebFont;
+} // namespace WebKit
+
+namespace pp {
+namespace shared_impl {
+
+// This class is a bit subtle. It's designed to be used in two contexts:
+// - In the renderer in the same thread as WebKit.
+// - On a special WebKit thread in the plugin process.
+// As a result, the actual implementation is provided in terms of functions
+// prefixed by "Do" that don't depend on any global Pepper state, and that
+// supply the return values via output parameters (for the other-thread case).
+// Each implementation is then in charge of setting up the call appropriately.
+//
+// The Do* functions take an optional waitable event. If provided, this
+// event will be signaled when the function completes. This allows the
+// cross-thread implementation to know when the function completes.
+class FontImpl {
+ public:
+ // C++ version of PP_TextRun_Dev. Since the Do* functions will be called on
+ // an alternate thread in the proxy, and since there are different methods
+ // of converting PP_Var -> strings in the plugin and the proxy, we can't
+ // use PP_Vars in the Do* funcitons below.
piman 2011/05/09 20:13:44 funcitons->functions
+ struct TextRun {
+ std::string text;
+ bool rtl;
+ bool override_direction;
+ };
+
+ FontImpl();
+ virtual ~FontImpl();
+
+ // Validates the parameters in thee description. Can be called on any thread.
+ static bool IsPPFontDescriptionValid(const PP_FontDescription_Dev& desc);
+
+ protected:
+ // DoDrawText takes too many arguments to be used with base::Bind, so we
+ // use this struct to hold them.
+ struct DrawTextParams {
+ DrawTextParams(skia::PlatformCanvas* destination_arg,
+ const TextRun& text_arg,
+ const PP_Point* position_arg,
piman 2011/05/09 20:13:44 Can we make position a const & as well, for consis
brettw 2011/05/09 21:00:35 My internal functions match the PPAPI functions, w
+ uint32_t color_arg,
+ const PP_Rect* clip_arg,
+ bool image_data_is_opaque_arg);
+ ~DrawTextParams();
+
+ skia::PlatformCanvas* destination;
+ const TextRun& text;
+ const PP_Point* position;
+ uint32_t color;
+ const PP_Rect* clip;
+ bool image_data_is_opaque;
+ };
+
+ // The face name from the description is given in desc_face so we can avoid
+ // a dependency on var conversion. See class description for waitable_event
+ // documentation.
+ void DoCreate(base::WaitableEvent* event,
+ const PP_FontDescription_Dev& desc,
+ const std::string& desc_face);
+
+ // The face name in the description is not filled in to avoid a dependency
+ // on creating vars. Instead, the face name is placed into the given string.
+ // See class description for waitable_event documentation.
+ void DoDescribe(base::WaitableEvent* event,
+ PP_FontDescription_Dev* description,
+ std::string* face,
+ PP_FontMetrics_Dev* metrics,
+ PP_Bool* result);
+ void DoDrawTextAt(base::WaitableEvent* event,
+ const DrawTextParams& params);
+ void DoMeasureText(base::WaitableEvent* event,
+ const TextRun& text, int32_t* result);
+ void DoCharacterOffsetForPixel(base::WaitableEvent* event,
+ const TextRun& text,
+ int32_t pixel_position,
+ uint32_t* result);
+ void DoPixelOffsetForCharacter(base::WaitableEvent* event,
+ const TextRun& text,
+ uint32_t char_offset,
+ int32_t* result);
+
+ // Access only on the WebKit thread.
+ scoped_ptr<WebKit::WebFont> font_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FontImpl);
+};
+
+} // namespace shared_impl
+} // namespace pp
+
+#endif // PPAPI_SHARED_IMPL_FONT_IMPL_H_
Property changes on: ppapi/shared_impl/font_impl.h
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698