This CL updates chrome to the latest version of skia, retrieved via DEPS, and
placed in third_party. All relevant skia changes (for all 3 platforms) have been upstreamed. Most of this CL is mind-numbingly repetitive. Things of interest are: skia.gyp (now points at third_party versions), DEPS, and SkUserConfig.h. stdint.h: Skia now requires C99 integer types, which MSVC doesn't support natively. I have put typedefs in config/win/stdint.h. Note that the new version of skia appears to render rects whose coordinates are "backwards" (ie., x2 < x1 or y2 < y1), which were formerly culled. There were a couple obvious instances of this in the code which I fixed, but there may be more. There were ~35 layout test failures due to minor pixel differences which I rebaselined on Windows and Linux, and 8 genuine failures related to masks and stroked text, which I have put in text_expectations.txt and assigned to myself. (There was another change which broke ~1700 tests on each platform, but I put that change behind an #ifdef for now). R=brettw Review URL: http://codereview.chromium.org/65012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15949 0039d316-1c4b-4281-b951-d872f2087c98
Esse commit está contido em:
+3
@@ -31,6 +31,9 @@ deps = {
|
||||
"src/v8":
|
||||
"http://v8.googlecode.com/svn/trunk@1927",
|
||||
|
||||
"src/third_party/skia":
|
||||
"http://skia.googlecode.com/svn/trunk@171",
|
||||
|
||||
"src/webkit/data/layout_tests/LayoutTests":
|
||||
Var("webkit_trunk") + "/LayoutTests@" + Var("webkit_revision"),
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "app/l10n_util.h"
|
||||
#include "base/gfx/rect.h"
|
||||
#include "base/logging.h"
|
||||
#include "skia/include/SkShader.h"
|
||||
#include "third_party/skia/include/core/SkShader.h"
|
||||
|
||||
bool ChromeCanvas::GetClipRect(gfx::Rect* r) {
|
||||
SkRect clip;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "app/gfx/chrome_font.h"
|
||||
#include "app/l10n_util.h"
|
||||
#include "base/gfx/rect.h"
|
||||
#include "skia/include/SkShader.h"
|
||||
#include "third_party/skia/include/core/SkShader.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#if defined(OS_WIN)
|
||||
typedef struct HFONT__* HFONT;
|
||||
#elif defined(OS_LINUX)
|
||||
#include "skia/include/SkRefCnt.h"
|
||||
#include "third_party/skia/include/core/SkRefCnt.h"
|
||||
class SkPaint;
|
||||
class SkTypeface;
|
||||
#endif
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/sys_string_conversions.h"
|
||||
|
||||
#include "skia/include/SkTypeface.h"
|
||||
#include "skia/include/SkPaint.h"
|
||||
#include "third_party/skia/include/core/SkTypeface.h"
|
||||
#include "third_party/skia/include/core/SkPaint.h"
|
||||
|
||||
ChromeFont::ChromeFont(const ChromeFont& other) {
|
||||
CopyChromeFont(other);
|
||||
@@ -80,8 +80,8 @@ ChromeFont ChromeFont::CreateFont(const std::wstring& font_family,
|
||||
int font_size) {
|
||||
DCHECK_GT(font_size, 0);
|
||||
|
||||
SkTypeface* tf = SkTypeface::Create(base::SysWideToUTF8(font_family).c_str(),
|
||||
SkTypeface::kNormal);
|
||||
SkTypeface* tf = SkTypeface::CreateFromName(
|
||||
base::SysWideToUTF8(font_family).c_str(), SkTypeface::kNormal);
|
||||
DCHECK(tf) << "Could not find font: " << base::SysWideToUTF8(font_family);
|
||||
SkAutoUnref tf_helper(tf);
|
||||
|
||||
@@ -106,8 +106,9 @@ ChromeFont ChromeFont::DeriveFont(int size_delta, int style) const {
|
||||
if (ITALIC & style)
|
||||
skstyle |= SkTypeface::kItalic;
|
||||
|
||||
SkTypeface* tf = SkTypeface::Create(base::SysWideToUTF8(font_family_).c_str(),
|
||||
static_cast<SkTypeface::Style>(skstyle));
|
||||
SkTypeface* tf = SkTypeface::CreateFromName(
|
||||
base::SysWideToUTF8(font_family_).c_str(),
|
||||
static_cast<SkTypeface::Style>(skstyle));
|
||||
SkAutoUnref tf_helper(tf);
|
||||
|
||||
return ChromeFont(tf, font_family_, font_size_ + size_delta, skstyle);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#if defined(OS_WIN)
|
||||
#include "skia/ext/skia_utils_win.h"
|
||||
#endif
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
namespace color_utils {
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef APP_GFX_COLOR_UTILS_H_
|
||||
#define APP_GFX_COLOR_UTILS_H_
|
||||
|
||||
#include "skia/include/SkColor.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
|
||||
class SkBitmap;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "base/gfx/size.h"
|
||||
#include "base/logging.h"
|
||||
#include "skia/ext/image_operations.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
// Defining the dimensions for the icon images. We store only one value because
|
||||
// we always resize to a square image; that is, the value 48 means that we are
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "base/file_util.h"
|
||||
#include "base/path_service.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef APP_THEME_PROVIDER_H_
|
||||
#define APP_THEME_PROVIDER_H_
|
||||
|
||||
#include "skia/include/SkColor.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
|
||||
class SkBitmap;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
extern "C" {
|
||||
#include "third_party/libjpeg/jpeglib.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "base/scoped_handle.h"
|
||||
#include "skia/ext/platform_canvas.h"
|
||||
#include "skia/ext/skia_utils_win.h"
|
||||
#include "skia/include/SkShader.h"
|
||||
#include "third_party/skia/include/core/SkShader.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <uxtheme.h>
|
||||
#include "base/basictypes.h"
|
||||
#include "base/gfx/size.h"
|
||||
#include "skia/include/SkColor.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
|
||||
namespace skia {
|
||||
class PlatformCanvasWin;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "base/gfx/png_decoder.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
extern "C" {
|
||||
#include "third_party/libpng/png.h"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "base/basictypes.h"
|
||||
#include "base/gfx/png_encoder.h"
|
||||
#include "base/logging.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
extern "C" {
|
||||
#include "third_party/libpng/png.h"
|
||||
|
||||
@@ -63,7 +63,6 @@
|
||||
#if defined(OS_MACOSX)
|
||||
#include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h"
|
||||
#endif
|
||||
#include "skia/include/corecg/SkTypes.h"
|
||||
|
||||
extern int BrowserMain(const MainFunctionParams&);
|
||||
extern int RendererMain(const MainFunctionParams&);
|
||||
@@ -114,12 +113,6 @@ void PureCall() {
|
||||
}
|
||||
|
||||
void OnNoMemory() {
|
||||
// Skia indicates that it can safely handle some NULL allocs by clearing
|
||||
// this flag. In this case, we'll ignore the new_handler and won't crash.
|
||||
if (!sk_malloc_will_throw()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Kill the process. This is important for security, since WebKit doesn't
|
||||
// NULL-check many memory allocations. If a malloc fails, returns NULL, and
|
||||
// the buffer is then used, it provides a handy mapping of memory starting at
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "chrome/common/notification_service.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "googleurl/src/url_util.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// AutocompleteEditModel
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "chrome/browser/history/history_types.h"
|
||||
#include "chrome/common/notification_observer.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "testing/gtest/include/gtest/gtest_prod.h"
|
||||
#include "views/controls/tree/tree_node_model.h"
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "base/gfx/rect.h"
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "base/task.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
class BrowserIdleTimer;
|
||||
class BrowserWindow;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include "net/base/cookie_monster.h"
|
||||
#include "net/url_request/url_request_context.h"
|
||||
#include "net/url_request/url_request_error_job.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
|
||||
using base::TimeDelta;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#import "chrome/browser/app_controller_mac.h"
|
||||
#import "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
|
||||
#include "chrome/browser/command_updater.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
// TODO(shess): This code is mostly copied from the gtk
|
||||
// implementation. Make sure it's all appropriate and flesh it out.
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#include "grit/locale_settings.h"
|
||||
#include "grit/theme_resources.h"
|
||||
#include "skia/ext/image_operations.h"
|
||||
#include "skia/include/SkPath.h"
|
||||
#include "skia/include/SkShader.h"
|
||||
#include "third_party/skia/include/core/SkPath.h"
|
||||
#include "third_party/skia/include/core/SkShader.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "app/os_exchange_data.h"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "base/scoped_ptr.h"
|
||||
#include "chrome/browser/extensions/extension_host.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
// TODO(port): Port these files.
|
||||
#if defined(OS_WIN)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "chrome/common/gears_api.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "net/base/base64.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "webkit/glue/dom_operations.h"
|
||||
|
||||
// The following 2 helpers are borrowed from the Gears codebase.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "chrome/browser/tab_contents/tab_contents.h"
|
||||
#include "chrome/common/gtk_util.h"
|
||||
#include "chrome/common/page_transition_types.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "webkit/glue/window_open_disposition.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "base/stl_util-inl.h"
|
||||
#include "base/string_util.h"
|
||||
#include "chrome/common/gtk_util.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
MenuGtk::MenuGtk(MenuGtk::Delegate* delegate,
|
||||
const MenuCreateMaterial* menu_data,
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "grit/generated_resources.h"
|
||||
#include "grit/theme_resources.h"
|
||||
#include "skia/ext/skia_utils.h"
|
||||
#include "skia/include/SkGradientShader.h"
|
||||
#include "third_party/skia/include/effects/SkGradientShader.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "base/basictypes.h"
|
||||
#include "base/gfx/rect.h"
|
||||
#include "chrome/common/owned_widget_gtk.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
namespace gfx {
|
||||
class Size;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "chrome/browser/history/history.h"
|
||||
#include "chrome/browser/history/history_types.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "chrome/browser/history/url_database.h"
|
||||
#include "chrome/common/sqlite_utils.h"
|
||||
#include "chrome/common/thumbnail_score.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
using base::Time;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "chrome/browser/history/url_database.h" // For DBCloseScoper.
|
||||
#include "chrome/browser/meta_table_helper.h"
|
||||
#include "chrome/common/sqlite_compiled_statement.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
struct sqlite3;
|
||||
struct ThumbnailScore;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "base/message_loop.h"
|
||||
#include "base/thread.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
IconLoader::IconLoader(const IconGroupID& group, IconSize size,
|
||||
Delegate* delegate)
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "base/logging.h"
|
||||
#include "chrome/common/transport_dib.h"
|
||||
#include "skia/ext/platform_canvas.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "skia/include/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
|
||||
BackingStore::BackingStore(const gfx::Size& size)
|
||||
: size_(size) {
|
||||
|
||||
@@ -67,7 +67,7 @@ using WebKit::WebCache;
|
||||
#include "chrome/common/temp_scaffolding_stubs.h"
|
||||
#endif
|
||||
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
|
||||
// This class creates the IO thread for the renderer when running in
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "chrome/common/thumbnail_score.h"
|
||||
#include "chrome/common/url_constants.h"
|
||||
#include "net/base/net_util.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "webkit/api/public/WebFindOptions.h"
|
||||
#include "webkit/glue/autofill_form.h"
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "base/gfx/native_widget_types.h"
|
||||
#include "base/shared_memory.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "webkit/glue/webplugin.h"
|
||||
#include "webkit/glue/webwidget_delegate.h"
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "chrome/browser/tab_contents/navigation_controller.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "webkit/glue/window_open_disposition.h"
|
||||
|
||||
class AlertInfoBarDelegate;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "chrome/common/page_transition_types.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "grit/theme_resources.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
class NavigationController;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "skia/include/SkColor.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
|
||||
class NavigationController;
|
||||
class NavigationEntry;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "chrome/browser/views/autocomplete/autocomplete_popup_win.h"
|
||||
#include "grit/generated_resources.h"
|
||||
#include "grit/theme_resources.h"
|
||||
#include "skia/include/SkShader.h"
|
||||
#include "third_party/skia/include/core/SkShader.h"
|
||||
#include "third_party/icu38/public/common/unicode/ubidi.h"
|
||||
#include "views/widget/widget.h"
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "views/controls/menu/menu.h"
|
||||
#include "views/controls/menu/view_menu_delegate.h"
|
||||
#include "views/view.h"
|
||||
#include "skia/include/corecg/SkRect.h"
|
||||
#include "third_party/skia/include/core/SkRect.h"
|
||||
|
||||
class Browser;
|
||||
class PageNavigator;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "chrome/browser/view_ids.h"
|
||||
#include "grit/generated_resources.h"
|
||||
#include "grit/theme_resources.h"
|
||||
#include "skia/include/SkGradientShader.h"
|
||||
#include "third_party/skia/include/effects/SkGradientShader.h"
|
||||
#include "views/background.h"
|
||||
#include "views/controls/button/image_button.h"
|
||||
#include "views/controls/label.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#define CHROME_BROWSER_VIEWS_HWND_HTML_VIEW_H_
|
||||
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "views/controls/hwnd_view.h"
|
||||
|
||||
class RenderViewHost;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "grit/generated_resources.h"
|
||||
#include "grit/locale_settings.h"
|
||||
#include "grit/theme_resources.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "views/background.h"
|
||||
#include "views/grid_layout.h"
|
||||
#include "views/controls/button/native_button.h"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "grit/generated_resources.h"
|
||||
#include "grit/theme_resources.h"
|
||||
#include "skia/ext/skia_utils_win.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "views/controls/button/radio_button.h"
|
||||
#include "views/controls/text_field.h"
|
||||
#include "views/grid_layout.h"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "grit/generated_resources.h"
|
||||
#include "grit/theme_resources.h"
|
||||
#include "grit/locale_settings.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "views/controls/button/native_button.h"
|
||||
#include "views/controls/text_field.h"
|
||||
#include "views/grid_layout.h"
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "grit/chromium_strings.h"
|
||||
#include "grit/generated_resources.h"
|
||||
#include "grit/theme_resources.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "views/controls/button/radio_button.h"
|
||||
#include "views/controls/label.h"
|
||||
#include "views/controls/table/table_view.h"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "grit/chromium_strings.h"
|
||||
#include "grit/generated_resources.h"
|
||||
#include "grit/theme_resources.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "unicode/uloc.h"
|
||||
#include "views/controls/button/radio_button.h"
|
||||
#include "views/controls/combo_box.h"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "grit/theme_resources.h"
|
||||
#include "net/base/cert_status_flags.h"
|
||||
#include "net/base/x509_certificate.h"
|
||||
#include "skia/include/SkColor.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "views/background.h"
|
||||
#include "views/grid_layout.h"
|
||||
#include "views/controls/button/native_button.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "grit/generated_resources.h"
|
||||
#include "grit/theme_resources.h"
|
||||
#include "skia/ext/skia_utils.h"
|
||||
#include "skia/include/SkGradientShader.h"
|
||||
#include "third_party/skia/include/effects/SkGradientShader.h"
|
||||
|
||||
static const int kSadTabOffset = -64;
|
||||
static const int kIconTitleSpacing = 20;
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
#include "grit/generated_resources.h"
|
||||
#include "grit/theme_resources.h"
|
||||
#include "net/base/net_util.h"
|
||||
#include "skia/include/SkPaint.h"
|
||||
#include "skia/include/SkPath.h"
|
||||
#include "skia/include/corecg/SkRect.h"
|
||||
#include "third_party/skia/include/core/SkPaint.h"
|
||||
#include "third_party/skia/include/core/SkPath.h"
|
||||
#include "third_party/skia/include/core/SkRect.h"
|
||||
#include "views/controls/label.h"
|
||||
#include "views/widget/root_view.h"
|
||||
#include "views/widget/widget_win.h"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "chrome/browser/tab_contents/tab_contents.h"
|
||||
#include "chrome/common/notification_service.h"
|
||||
#include "grit/theme_resources.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "views/event.h"
|
||||
#include "views/widget/root_view.h"
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "chrome/browser/tabs/tab_strip_model.h"
|
||||
#include "chrome/browser/views/tabs/hwnd_photobooth.h"
|
||||
#include "chrome/browser/views/tabs/tab_renderer.h"
|
||||
#include "skia/include/SkShader.h"
|
||||
#include "third_party/skia/include/core/SkShader.h"
|
||||
#include "views/widget/widget_win.h"
|
||||
|
||||
const int kTransparentAlpha = 200;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "base/gfx/point.h"
|
||||
#include "base/gfx/size.h"
|
||||
#include "base/task.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "views/view.h"
|
||||
|
||||
namespace views {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "base/gfx/point.h"
|
||||
#include "chrome/browser/tab_contents/tab_contents.h"
|
||||
#include "chrome/browser/views/tabs/hwnd_photobooth.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "views/widget/widget_win.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "chrome/browser/meta_table_helper.h"
|
||||
#include "chrome/browser/search_engines/template_url.h"
|
||||
#include "chrome/common/sqlite_utils.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "testing/gtest/include/gtest/gtest_prod.h"
|
||||
#include "webkit/glue/autofill_form.h"
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "chrome/browser/search_engines/template_url.h"
|
||||
#include "chrome/browser/webdata/web_database.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webkit/glue/autofill_form.h"
|
||||
#include "webkit/glue/password_form.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "base/linux_util.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "webkit/glue/webview_delegate.h"
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "base/shared_memory.h"
|
||||
#include "chrome/common/ipc_message_macros.h"
|
||||
#include "chrome/common/transport_dib.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "webkit/glue/dom_operations.h"
|
||||
#include "webkit/glue/webappcachecontext.h"
|
||||
#include "webkit/glue/webcursor.h"
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
#include "grit/renderer_resources.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "skia/include/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "webkit/glue/webkit_glue.h"
|
||||
#include "SkDevice.h"
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "chrome/browser/dom_ui/html_dialog_ui.h"
|
||||
#include "chrome/browser/tab_contents/navigation_entry.h"
|
||||
#include "googleurl/src/gurl.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
class BookmarkContextMenu;
|
||||
class BookmarkNode;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "chrome/renderer/extensions/extension_process_bindings.h"
|
||||
#include "chrome/renderer/external_host_bindings.h"
|
||||
#include "chrome/renderer/render_widget.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "testing/gtest/include/gtest/gtest_prod.h"
|
||||
#include "webkit/api/public/WebConsoleMessage.h"
|
||||
#include "webkit/glue/dom_serializer_delegate.h"
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
#include "chrome/common/transport_dib.h"
|
||||
#include "chrome/renderer/render_process.h"
|
||||
#include "skia/ext/platform_canvas.h"
|
||||
#include "skia/include/SkShader.h"
|
||||
#include "third_party/skia/include/core/SkShader.h"
|
||||
#include "webkit/api/public/WebRect.h"
|
||||
#include "webkit/api/public/WebScreenInfo.h"
|
||||
#include "webkit/api/public/WebSize.h"
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#include "skia/include/SkPixelRef.h"
|
||||
#include "skia/include/SkMallocPixelRef.h"
|
||||
#include "third_party/skia/include/core/SkPixelRef.h"
|
||||
#include "third_party/skia/include/core/SkMallocPixelRef.h"
|
||||
#endif // defined(OS_POSIX)
|
||||
|
||||
#include "webkit/glue/webtextdirection.h"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "chrome/common/ipc_channel.h"
|
||||
#include "chrome/renderer/render_process.h"
|
||||
#include "skia/ext/platform_canvas.h"
|
||||
#include "skia/include/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
#include "webkit/api/public/WebRect.h"
|
||||
#include "webkit/glue/webwidget_delegate.h"
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkUserConfig_DEFINED
|
||||
#define SkUserConfig_DEFINED
|
||||
|
||||
/* SkTypes.h, the root of the public header files, does the following trick:
|
||||
|
||||
#include <SkPreConfig.h>
|
||||
#include <SkUserConfig.h>
|
||||
#include <SkPostConfig.h>
|
||||
|
||||
SkPreConfig.h runs first, and it is responsible for initializing certain
|
||||
skia defines.
|
||||
|
||||
SkPostConfig.h runs last, and its job is to just check that the final
|
||||
defines are consistent (i.e. that we don't have mutually conflicting
|
||||
defines).
|
||||
|
||||
SkUserConfig.h (this file) runs in the middle. It gets to change or augment
|
||||
the list of flags initially set in preconfig, and then postconfig checks
|
||||
that everything still makes sense.
|
||||
|
||||
Below are optional defines that add, subtract, or change default behavior
|
||||
in Skia. Your port can locally edit this file to enable/disable flags as
|
||||
you choose, or these can be delared on your command line (i.e. -Dfoo).
|
||||
|
||||
By default, this include file will always default to having all of the flags
|
||||
commented out, so including it will have no effect.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* Scalars (the fractional value type in skia) can be implemented either as
|
||||
floats or 16.16 integers (fixed). Exactly one of these two symbols must be
|
||||
defined.
|
||||
*/
|
||||
//#define SK_SCALAR_IS_FLOAT
|
||||
//#define SK_SCALAR_IS_FIXED
|
||||
|
||||
|
||||
/* Somewhat independent of how SkScalar is implemented, Skia also wants to know
|
||||
if it can use floats at all. Naturally, if SK_SCALAR_IS_FLOAT is defined,
|
||||
then so muse SK_CAN_USE_FLOAT, but if scalars are fixed, SK_CAN_USE_FLOAT
|
||||
can go either way.
|
||||
*/
|
||||
//#define SK_CAN_USE_FLOAT
|
||||
|
||||
/* For some performance-critical scalar operations, skia will optionally work
|
||||
around the standard float operators if it knows that the CPU does not have
|
||||
native support for floats. If your environment uses software floating point,
|
||||
define this flag.
|
||||
*/
|
||||
//#define SK_SOFTWARE_FLOAT
|
||||
|
||||
|
||||
/* Skia has lots of debug-only code. Often this is just null checks or other
|
||||
parameter checking, but sometimes it can be quite intrusive (e.g. check that
|
||||
each 32bit pixel is in premultiplied form). This code can be very useful
|
||||
during development, but will slow things down in a shipping product.
|
||||
|
||||
By default, these mutually exclusive flags are defined in SkPreConfig.h,
|
||||
based on the presence or absence of NDEBUG, but that decision can be changed
|
||||
here.
|
||||
*/
|
||||
//#define SK_DEBUG
|
||||
//#define SK_RELEASE
|
||||
|
||||
|
||||
/* If, in debugging mode, Skia needs to stop (presumably to invoke a debugger)
|
||||
it will call SK_CRASH(). If this is not defined it, it is defined in
|
||||
SkPostConfig.h to write to an illegal address
|
||||
*/
|
||||
//#define SK_CRASH() *(int *)(uintptr_t)0 = 0
|
||||
|
||||
|
||||
/* preconfig will have attempted to determine the endianness of the system,
|
||||
but you can change these mutually exclusive flags here.
|
||||
*/
|
||||
//#define SK_CPU_BENDIAN
|
||||
//#define SK_CPU_LENDIAN
|
||||
|
||||
|
||||
/* Some compilers don't support long long for 64bit integers. If yours does
|
||||
not, define this to the appropriate type.
|
||||
*/
|
||||
//#define SkLONGLONG int64_t
|
||||
|
||||
|
||||
/* Some envorinments do not suport writable globals (eek!). If yours does not,
|
||||
define this flag.
|
||||
*/
|
||||
//#define SK_USE_RUNTIME_GLOBALS
|
||||
|
||||
|
||||
/* To write debug messages to a console, skia will call SkDebugf(...) following
|
||||
printf conventions (e.g. const char* format, ...). If you want to redirect
|
||||
this to something other than printf, define yours here
|
||||
*/
|
||||
//#define SkDebugf(...) MyFunction(__VA_ARGS__)
|
||||
|
||||
|
||||
/* If SK_DEBUG is defined, then you can optionally define SK_SUPPORT_UNITTEST
|
||||
which will run additional self-tests at startup. These can take a long time,
|
||||
so this flag is optional.
|
||||
*/
|
||||
#ifdef SK_DEBUG
|
||||
#define SK_SUPPORT_UNITTEST
|
||||
#endif
|
||||
|
||||
// ===== Begin Chrome-specific definitions =====
|
||||
|
||||
#define SK_SCALAR_IS_FLOAT
|
||||
#undef SK_SCALAR_IS_FIXED
|
||||
|
||||
// Log the file and line number for assertions.
|
||||
#define SkDebugf(...) SkDebugf_FileLine(__FILE__, __LINE__, false, __VA_ARGS__)
|
||||
void SkDebugf_FileLine(const char* file, int line, bool fatal,
|
||||
const char* format, ...);
|
||||
|
||||
// Marking the debug print as "fatal" will cause a debug break, so we don't need
|
||||
// a separate crash call here.
|
||||
#define SK_DEBUGBREAK(cond) do { if (!(cond)) { \
|
||||
SkDebugf_FileLine(__FILE__, __LINE__, true, \
|
||||
"%s:%d: failed assertion \"%s\"\n", \
|
||||
__FILE__, __LINE__, #cond); } } while (false)
|
||||
|
||||
#if defined(SK_BUILD_FOR_WIN32)
|
||||
|
||||
#define SK_BUILD_FOR_WIN
|
||||
|
||||
// VC8 doesn't support stdint.h, so we define those types here.
|
||||
#define SK_IGNORE_STDINT_DOT_H
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned uint32_t;
|
||||
#define SK_A32_SHIFT 24
|
||||
#define SK_R32_SHIFT 16
|
||||
#define SK_G32_SHIFT 8
|
||||
#define SK_B32_SHIFT 0
|
||||
|
||||
// VC doesn't support __restrict__, so make it a NOP.
|
||||
#undef SK_RESTRICT
|
||||
#define SK_RESTRICT
|
||||
|
||||
// Skia uses this deprecated bzero function to fill zeros into a string.
|
||||
#define bzero(str, len) memset(str, 0, len)
|
||||
|
||||
#elif defined(SK_BUILD_FOR_MAC)
|
||||
|
||||
#define SK_CPU_LENDIAN
|
||||
#undef SK_CPU_BENDIAN
|
||||
// we want (memory order) RGBA
|
||||
#define SK_A32_SHIFT 24
|
||||
#define SK_R32_SHIFT 0
|
||||
#define SK_G32_SHIFT 8
|
||||
#define SK_B32_SHIFT 16
|
||||
|
||||
#elif defined(SK_BUILD_FOR_UNIX)
|
||||
|
||||
#ifdef SK_CPU_BENDIAN
|
||||
// Below we set the order for ARGB channels in registers. I suspect that, on
|
||||
// big endian machines, you can keep this the same and everything will work.
|
||||
// The in-memory order will be different, of course, but as long as everything
|
||||
// is reading memory as words rather than bytes, it will all work. However, if
|
||||
// you find that colours are messed up I thought that I would leave a helpful
|
||||
// locator for you. Also see the comments in
|
||||
// base/gfx/bitmap_platform_device_linux.h
|
||||
#error Read the comment at this location
|
||||
#endif
|
||||
|
||||
// For Linux we want to match the most common X visual, which is
|
||||
// ARGB (in registers)
|
||||
#define SK_A32_SHIFT 24
|
||||
#define SK_R32_SHIFT 16
|
||||
#define SK_G32_SHIFT 8
|
||||
#define SK_B32_SHIFT 0
|
||||
|
||||
#endif
|
||||
|
||||
// The default crash macro writes to badbeef which can cause some strange
|
||||
// problems. Instead, pipe this through to the logging function as a fatal
|
||||
// assertion.
|
||||
#define SK_CRASH() SkDebugf_FileLine(__FILE__, __LINE__, true, "SK_CRASH")
|
||||
|
||||
// TODO(brettw) bug 6373: Re-enable Skia assertions. This is blocked on fixing
|
||||
// some of our transparency handling which generates purposely-invalid colors,
|
||||
// in turn causing assertions.
|
||||
//#ifndef NDEBUG
|
||||
// #define SK_DEBUG
|
||||
// #undef SK_RELEASE
|
||||
#undef SK_SUPPORT_UNITTEST // This is only necessary in debug mode since
|
||||
// we've disabled assertions. When we re-enable
|
||||
// them, this line can be removed.
|
||||
//#else
|
||||
#define SK_RELEASE
|
||||
#undef SK_DEBUG
|
||||
//#endif
|
||||
|
||||
// For now (and to avoid rebaselining 1700+ tests), we'll use the old version
|
||||
// of SkAlpha255To256.
|
||||
#define SK_USE_OLD_255_TO_256
|
||||
|
||||
// ===== End Chrome-specific definitions =====
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2009 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.
|
||||
|
||||
// skia is written in C99 and requires <stdint.h> and <inttypes.h>.
|
||||
// Since MSVC doesn't include these headers, we have to write our own version
|
||||
// to provide a compatibility layer between MSVC and skia
|
||||
|
||||
#ifndef SKIA_CONFIG_WIN_STDINT_H_
|
||||
#define SKIA_CONFIG_WIN_STDINT_H
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
#error This file should only be included when compiling with MSVC.
|
||||
#endif
|
||||
|
||||
// Define C99 equivalent types.
|
||||
typedef signed char int8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef signed long long int64_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
|
||||
#endif // SKIA_CONFIG_WIN_STDINT_H
|
||||
@@ -0,0 +1,58 @@
|
||||
#include "SkTypes.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <new>
|
||||
|
||||
// This implementation of sk_malloc_flags() and friends is identical
|
||||
// to SkMemory_malloc.c, except that it disables the CRT's new_handler
|
||||
// during malloc(), when SK_MALLOC_THROW is not set (ie., when
|
||||
// sk_malloc_flags() would not abort on NULL).
|
||||
|
||||
void sk_throw() {
|
||||
SkASSERT(!"sk_throw");
|
||||
abort();
|
||||
}
|
||||
|
||||
void sk_out_of_memory(void) {
|
||||
SkASSERT(!"sk_out_of_memory");
|
||||
abort();
|
||||
}
|
||||
|
||||
void* sk_malloc_throw(size_t size) {
|
||||
return sk_malloc_flags(size, SK_MALLOC_THROW);
|
||||
}
|
||||
|
||||
void* sk_realloc_throw(void* addr, size_t size) {
|
||||
void* p = realloc(addr, size);
|
||||
if (size == 0) {
|
||||
return p;
|
||||
}
|
||||
if (p == NULL) {
|
||||
sk_throw();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
void sk_free(void* p) {
|
||||
if (p) {
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
void* sk_malloc_flags(size_t size, unsigned flags) {
|
||||
std::new_handler old_handler;
|
||||
if (!(flags & SK_MALLOC_THROW)) {
|
||||
old_handler = std::set_new_handler(NULL);
|
||||
}
|
||||
void* p = malloc(size);
|
||||
if (!(flags & SK_MALLOC_THROW)) {
|
||||
std::set_new_handler(old_handler);
|
||||
}
|
||||
if (p == NULL) {
|
||||
if (flags & SK_MALLOC_THROW) {
|
||||
sk_throw();
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "SkTypeface.h"
|
||||
|
||||
// ===== Begin Chrome-specific definitions =====
|
||||
|
||||
uint32_t SkTypeface::UniqueID(const SkTypeface* face)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SkTypeface::serialize(SkWStream* stream) const {
|
||||
}
|
||||
|
||||
SkTypeface* SkTypeface::Deserialize(SkStream* stream) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ===== End Chrome-specific definitions =====
|
||||
@@ -14,8 +14,8 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/stack_container.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "skia/ext/convolver.h"
|
||||
#include "skia/include/SkColorPriv.h"
|
||||
|
||||
namespace skia {
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "skia/ext/image_operations.h"
|
||||
#include "skia/include/SkColorPriv.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkBitmap.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "skia/ext/skia_utils.h"
|
||||
#include "skia/include/SkColorPriv.h"
|
||||
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkGradientShader.h"
|
||||
|
||||
namespace skia {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "skia/ext/skia_utils.h"
|
||||
#include "skia/include/SkColorPriv.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkBitmap.h"
|
||||
|
||||
TEST(SkiaUtils, SkColorToHSLRed) {
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
/** \mainpage notitle
|
||||
* \htmlinclude "SGL Spec. rev 9.htm"
|
||||
*/
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef Sk1DPathEffect_DEFINED
|
||||
#define Sk1DPathEffect_DEFINED
|
||||
|
||||
#include "SkPathEffect.h"
|
||||
#include "SkPath.h"
|
||||
|
||||
class SkPathMeasure;
|
||||
|
||||
// This class is not exported to java.
|
||||
class Sk1DPathEffect : public SkPathEffect {
|
||||
public:
|
||||
// override from SkPathEffect
|
||||
virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
|
||||
|
||||
protected:
|
||||
/** Called at the start of each contour, returns the initial offset
|
||||
into that contour.
|
||||
*/
|
||||
virtual SkScalar begin(SkScalar contourLength) = 0;
|
||||
/** Called with the current distance along the path, with the current matrix
|
||||
for the point/tangent at the specified distance.
|
||||
Return the distance to travel for the next call. If return <= 0, then that
|
||||
contour is done.
|
||||
*/
|
||||
virtual SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure&) = 0;
|
||||
|
||||
private:
|
||||
typedef SkPathEffect INHERITED;
|
||||
};
|
||||
|
||||
class SkPath1DPathEffect : public Sk1DPathEffect {
|
||||
public:
|
||||
enum Style {
|
||||
kTranslate_Style, // translate the shape to each position
|
||||
kRotate_Style, // rotate the shape about its center
|
||||
kMorph_Style, // transform each point, and turn lines into curves
|
||||
|
||||
kStyleCount
|
||||
};
|
||||
|
||||
/** Dash by replicating the specified path.
|
||||
@param path The path to replicate (dash)
|
||||
@param advance The space between instances of path
|
||||
@param phase distance (mod advance) along path for its initial position
|
||||
@param style how to transform path at each point (based on the current
|
||||
position and tangent)
|
||||
*/
|
||||
SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style);
|
||||
|
||||
// override from SkPathEffect
|
||||
virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
|
||||
|
||||
protected:
|
||||
SkPath1DPathEffect(SkFlattenableReadBuffer& buffer);
|
||||
|
||||
// overrides from Sk1DPathEffect
|
||||
virtual SkScalar begin(SkScalar contourLength);
|
||||
virtual SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure&);
|
||||
// overrides from SkFlattenable
|
||||
virtual void flatten(SkFlattenableWriteBuffer& );
|
||||
virtual Factory getFactory() { return CreateProc; }
|
||||
|
||||
private:
|
||||
SkPath fPath; // copied from constructor
|
||||
SkScalar fAdvance; // copied from constructor
|
||||
SkScalar fInitialOffset; // computed from phase
|
||||
Style fStyle; // copied from constructor
|
||||
|
||||
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
|
||||
return SkNEW_ARGS(SkPath1DPathEffect, (buffer));
|
||||
}
|
||||
|
||||
typedef Sk1DPathEffect INHERITED;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef Sk2DPathEffect_DEFINED
|
||||
#define Sk2DPathEffect_DEFINED
|
||||
|
||||
#include "SkPathEffect.h"
|
||||
#include "SkMatrix.h"
|
||||
|
||||
// This class is not exported to java.
|
||||
class Sk2DPathEffect : public SkPathEffect {
|
||||
public:
|
||||
Sk2DPathEffect(const SkMatrix& mat);
|
||||
|
||||
// overrides
|
||||
// This method is not exported to java.
|
||||
virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
|
||||
|
||||
// overrides from SkFlattenable
|
||||
// This method is not exported to java.
|
||||
virtual void flatten(SkFlattenableWriteBuffer&);
|
||||
|
||||
// This method is not exported to java.
|
||||
virtual Factory getFactory();
|
||||
|
||||
protected:
|
||||
/** New virtual, to be overridden by subclasses.
|
||||
This is called once from filterPath, and provides the
|
||||
uv parameter bounds for the path. Subsequent calls to
|
||||
next() will receive u and v values within these bounds,
|
||||
and then a call to end() will signal the end of processing.
|
||||
*/
|
||||
virtual void begin(const SkIRect& uvBounds, SkPath* dst);
|
||||
virtual void next(const SkPoint& loc, int u, int v, SkPath* dst);
|
||||
virtual void end(SkPath* dst);
|
||||
|
||||
/** Low-level virtual called per span of locations in the u-direction.
|
||||
The default implementation calls next() repeatedly with each
|
||||
location.
|
||||
*/
|
||||
virtual void nextSpan(int u, int v, int ucount, SkPath* dst);
|
||||
|
||||
const SkMatrix& getMatrix() const { return fMatrix; }
|
||||
|
||||
// protected so that subclasses can call this during unflattening
|
||||
Sk2DPathEffect(SkFlattenableReadBuffer&);
|
||||
|
||||
private:
|
||||
SkMatrix fMatrix, fInverse;
|
||||
// illegal
|
||||
Sk2DPathEffect(const Sk2DPathEffect&);
|
||||
Sk2DPathEffect& operator=(const Sk2DPathEffect&);
|
||||
|
||||
static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
|
||||
|
||||
friend class Sk2DPathEffectBlitter;
|
||||
typedef SkPathEffect INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,508 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkAnimator_DEFINED
|
||||
#define SkAnimator_DEFINED
|
||||
|
||||
#include "SkScalar.h"
|
||||
#include "SkKey.h"
|
||||
#include "SkEventSink.h"
|
||||
|
||||
class SkAnimateMaker;
|
||||
class SkCanvas;
|
||||
class SkDisplayable;
|
||||
class SkEvent;
|
||||
class SkExtras;
|
||||
struct SkMemberInfo;
|
||||
class SkPaint;
|
||||
struct SkRect;
|
||||
class SkStream;
|
||||
class SkTypedArray;
|
||||
class SkXMLParserError;
|
||||
class SkDOM;
|
||||
struct SkDOMNode;
|
||||
|
||||
/** SkElementType is the type of element: a rectangle, a color, an animator, and so on.
|
||||
This enum is incomplete and will be fleshed out in a future release */
|
||||
enum SkElementType {
|
||||
kElementDummyType
|
||||
};
|
||||
/** SkFieldType is the type of field: a scalar, a string, an integer, a boolean, and so on.
|
||||
This enum is incomplete and will be fleshed out in a future release */
|
||||
enum SkFieldType {
|
||||
kFieldDummyType
|
||||
};
|
||||
|
||||
/** \class SkAnimator
|
||||
|
||||
The SkAnimator class decodes an XML stream into a display list. The
|
||||
display list can be drawn statically as a picture, or can drawn
|
||||
different elements at different times to form a moving animation.
|
||||
|
||||
SkAnimator does not read the system time on its own; it relies on the
|
||||
caller to pass the current time. The caller can pause, speed up, or
|
||||
reverse the animation by varying the time passed in.
|
||||
|
||||
The XML describing the display list must conform to the schema
|
||||
described by SkAnimateSchema.xsd.
|
||||
|
||||
The XML must contain an <event> element to draw. Usually, it contains
|
||||
an <event kind="onload" /> block to add some drawing elements to the
|
||||
display list when the document is first decoded.
|
||||
|
||||
Here's an "Hello World" XML sample:
|
||||
|
||||
<screenplay>
|
||||
<event kind="onload" >
|
||||
<text text="Hello World" y="20" />
|
||||
</event>
|
||||
</screenplay>
|
||||
|
||||
To read and draw this sample:
|
||||
|
||||
// choose one of these two
|
||||
SkAnimator animator; // declare an animator instance on the stack
|
||||
// SkAnimator* animator = new SkAnimator() // or one could instantiate the class
|
||||
|
||||
// choose one of these three
|
||||
animator.decodeMemory(buffer, size); // to read from RAM
|
||||
animator.decodeStream(stream); // to read from a user-defined stream (e.g., a zip file)
|
||||
animator.decodeURI(filename); // to read from a web location, or from a local text file
|
||||
|
||||
// to draw to the current window:
|
||||
SkCanvas canvas(getBitmap()); // create a canvas
|
||||
animator.draw(canvas, &paint, 0); // draw the scene
|
||||
*/
|
||||
class SkAnimator : public SkEventSink {
|
||||
public:
|
||||
SkAnimator();
|
||||
virtual ~SkAnimator();
|
||||
|
||||
/** Add a drawable extension to the graphics engine. Experimental.
|
||||
@param extras A derived class that implements methods that identify and instantiate the class
|
||||
*/
|
||||
void addExtras(SkExtras* extras);
|
||||
|
||||
/** Read in XML from a stream, and append it to the current
|
||||
animator. Returns false if an error was encountered.
|
||||
Error diagnostics are stored in fErrorCode and fLineNumber.
|
||||
@param stream The stream to append.
|
||||
@return true if the XML was parsed successfully.
|
||||
*/
|
||||
bool appendStream(SkStream* stream);
|
||||
|
||||
/** Read in XML from memory. Returns true if the file can be
|
||||
read without error. Returns false if an error was encountered.
|
||||
Error diagnostics are stored in fErrorCode and fLineNumber.
|
||||
@param buffer The XML text as UTF-8 characters.
|
||||
@param size The XML text length in bytes.
|
||||
@return true if the XML was parsed successfully.
|
||||
*/
|
||||
bool decodeMemory(const void* buffer, size_t size);
|
||||
|
||||
/** Read in XML from a stream. Returns true if the file can be
|
||||
read without error. Returns false if an error was encountered.
|
||||
Error diagnostics are stored in fErrorCode and fLineNumber.
|
||||
@param stream The stream containg the XML text as UTF-8 characters.
|
||||
@return true if the XML was parsed successfully.
|
||||
*/
|
||||
virtual bool decodeStream(SkStream* stream);
|
||||
|
||||
/** Parse the DOM tree starting at the specified node. Returns true if it can be
|
||||
parsed without error. Returns false if an error was encountered.
|
||||
Error diagnostics are stored in fErrorCode and fLineNumber.
|
||||
@return true if the DOM was parsed successfully.
|
||||
*/
|
||||
virtual bool decodeDOM(const SkDOM&, const SkDOMNode*);
|
||||
|
||||
/** Read in XML from a URI. Returns true if the file can be
|
||||
read without error. Returns false if an error was encountered.
|
||||
Error diagnostics are stored in fErrorCode and fLineNumber.
|
||||
@param uri The complete url path to be read (either ftp, http or https).
|
||||
@return true if the XML was parsed successfully.
|
||||
*/
|
||||
bool decodeURI(const char uri[]);
|
||||
|
||||
/** Pass a char event, usually a keyboard symbol, to the animator.
|
||||
This triggers events of the form <event kind="keyChar" key="... />
|
||||
@param ch The character to match against <event> element "key"
|
||||
attributes.
|
||||
@return true if the event was dispatched successfully.
|
||||
*/
|
||||
bool doCharEvent(SkUnichar ch);
|
||||
|
||||
/** Experimental:
|
||||
Pass a mouse click event along with the mouse coordinates to
|
||||
the animator. This triggers events of the form <event kind="mouseDown" ... />
|
||||
and other mouse events.
|
||||
@param state The mouse state, described by SkView::Click::State : values are
|
||||
down == 0, moved == 1, up == 2
|
||||
@param x The x-position of the mouse
|
||||
@param y The y-position of the mouse
|
||||
@return true if the event was dispatched successfully.
|
||||
*/
|
||||
bool doClickEvent(int state, SkScalar x, SkScalar y);
|
||||
|
||||
/** Pass a meta-key event, such as an arrow , to the animator.
|
||||
This triggers events of the form <event kind="keyPress" code="... />
|
||||
@param code The key to match against <event> element "code"
|
||||
attributes.
|
||||
@return true if the event was dispatched successfully.
|
||||
*/
|
||||
bool doKeyEvent(SkKey code);
|
||||
bool doKeyUpEvent(SkKey code);
|
||||
|
||||
/** Send an event to the animator. The animator's clock is set
|
||||
relative to the current time.
|
||||
@return true if the event was dispatched successfully.
|
||||
*/
|
||||
bool doUserEvent(const SkEvent& evt);
|
||||
|
||||
/** The possible results from the draw function.
|
||||
*/
|
||||
enum DifferenceType {
|
||||
kNotDifferent,
|
||||
kDifferent,
|
||||
kPartiallyDifferent
|
||||
};
|
||||
/** Draws one frame of the animation. The first call to draw always
|
||||
draws the initial frame of the animation. Subsequent calls draw
|
||||
the offset into the animation by
|
||||
subtracting the initial time from the current time.
|
||||
@param canvas The canvas to draw into.
|
||||
@param paint The paint to draw with.
|
||||
@param time The offset into the current animation.
|
||||
@return kNotDifferent if there are no active animations; kDifferent if there are active animations; and
|
||||
kPartiallyDifferent if the document contains an active <bounds> element that specifies a minimal
|
||||
redraw area.
|
||||
*/
|
||||
DifferenceType draw(SkCanvas* canvas, SkPaint* paint, SkMSec time);
|
||||
|
||||
/** Draws one frame of the animation, using a new Paint each time.
|
||||
The first call to draw always
|
||||
draws the initial frame of the animation. Subsequent calls draw
|
||||
the offset into the animation by
|
||||
subtracting the initial time from the current time.
|
||||
@param canvas The canvas to draw into.
|
||||
@param time The offset into the current animation.
|
||||
@return kNotDifferent if there are no active animations; kDifferent if there are active animations; and
|
||||
kPartiallyDifferent if the document contains an active <bounds> element that specifies a minimal
|
||||
redraw area.
|
||||
*/
|
||||
DifferenceType draw(SkCanvas* canvas, SkMSec time);
|
||||
|
||||
/** Experimental:
|
||||
Helper to choose whether to return a SkView::Click handler.
|
||||
@param x ignored
|
||||
@param y ignored
|
||||
@return true if a mouseDown event handler is enabled.
|
||||
*/
|
||||
bool findClickEvent(SkScalar x, SkScalar y);
|
||||
|
||||
|
||||
/** Get the nested animator associated with this element, if any.
|
||||
Use this to access a movie's event sink, to send events to movies.
|
||||
@param element the value returned by getElement
|
||||
@return the internal animator.
|
||||
*/
|
||||
const SkAnimator* getAnimator(const SkDisplayable* element) const;
|
||||
|
||||
/** Returns the scalar value of the specified element's attribute[index]
|
||||
@param element the value returned by getElement
|
||||
@param field the value returned by getField
|
||||
@param index the array entry
|
||||
@return the integer value to retrieve, or SK_NaN32 if unsuccessful
|
||||
*/
|
||||
int32_t getArrayInt(const SkDisplayable* element, const SkMemberInfo* field, int index);
|
||||
|
||||
/** Returns the scalar value of the specified element's attribute[index]
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@param fieldName specifies the name of the attribute
|
||||
@param index the array entry
|
||||
@return the integer value to retrieve, or SK_NaN32 if unsuccessful
|
||||
*/
|
||||
int32_t getArrayInt(const char* elementID, const char* fieldName, int index);
|
||||
|
||||
/** Returns the scalar value of the specified element's attribute[index]
|
||||
@param element the value returned by getElement
|
||||
@param field the value returned by getField
|
||||
@param index the array entry
|
||||
@return the scalar value to retrieve, or SK_ScalarNaN if unsuccessful
|
||||
*/
|
||||
SkScalar getArrayScalar(const SkDisplayable* element, const SkMemberInfo* field, int index);
|
||||
|
||||
/** Returns the scalar value of the specified element's attribute[index]
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@param fieldName specifies the name of the attribute
|
||||
@param index the array entry
|
||||
@return the scalar value to retrieve, or SK_ScalarNaN if unsuccessful
|
||||
*/
|
||||
SkScalar getArrayScalar(const char* elementID, const char* fieldName, int index);
|
||||
|
||||
/** Returns the string value of the specified element's attribute[index]
|
||||
@param element is a value returned by getElement
|
||||
@param field is a value returned by getField
|
||||
@param index the array entry
|
||||
@return the string value to retrieve, or null if unsuccessful
|
||||
*/
|
||||
const char* getArrayString(const SkDisplayable* element, const SkMemberInfo* field, int index);
|
||||
|
||||
/** Returns the string value of the specified element's attribute[index]
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@param fieldName specifies the name of the attribute
|
||||
@param index the array entry
|
||||
@return the string value to retrieve, or null if unsuccessful
|
||||
*/
|
||||
const char* getArrayString(const char* elementID, const char* fieldName, int index);
|
||||
|
||||
/** Returns the XML element corresponding to the given ID.
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@return the element matching the ID, or null if the element can't be found
|
||||
*/
|
||||
const SkDisplayable* getElement(const char* elementID);
|
||||
|
||||
/** Returns the element type corresponding to the XML element.
|
||||
The element type matches the element name; for instance, <line> returns kElement_LineType
|
||||
@param element is a value returned by getElement
|
||||
@return element type, or 0 if the element can't be found
|
||||
*/
|
||||
SkElementType getElementType(const SkDisplayable* element);
|
||||
|
||||
/** Returns the element type corresponding to the given ID.
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@return element type, or 0 if the element can't be found
|
||||
*/
|
||||
SkElementType getElementType(const char* elementID);
|
||||
|
||||
/** Returns the XML field of the named attribute in the XML element.
|
||||
@param element is a value returned by getElement
|
||||
@param fieldName is the attribute to return
|
||||
@return the attribute matching the fieldName, or null if the element can't be found
|
||||
*/
|
||||
const SkMemberInfo* getField(const SkDisplayable* element, const char* fieldName);
|
||||
|
||||
/** Returns the XML field of the named attribute in the XML element matching the elementID.
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@param fieldName is the attribute to return
|
||||
@return the attribute matching the fieldName, or null if the element can't be found
|
||||
*/
|
||||
const SkMemberInfo* getField(const char* elementID, const char* fieldName);
|
||||
|
||||
/** Returns the value type coresponding to the element's attribute.
|
||||
The value type matches the XML schema: and may be kField_BooleanType, kField_ScalarType, etc.
|
||||
@param field is a value returned by getField
|
||||
@return the attribute type, or 0 if the element can't be found
|
||||
*/
|
||||
SkFieldType getFieldType(const SkMemberInfo* field);
|
||||
|
||||
/** Returns the value type coresponding to the element's attribute.
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@param fieldName specifies the name of the attribute
|
||||
@return the attribute type, or 0 if the element can't be found
|
||||
*/
|
||||
SkFieldType getFieldType(const char* elementID, const char* fieldName);
|
||||
|
||||
/** Returns the recommended animation interval. Returns zero if no
|
||||
interval is specified.
|
||||
*/
|
||||
SkMSec getInterval();
|
||||
|
||||
/** Returns the partial rectangle to invalidate after drawing. Call after draw() returns
|
||||
kIsPartiallyDifferent to do a mimimal inval(). */
|
||||
void getInvalBounds(SkRect* inval);
|
||||
|
||||
/** Returns the details of any error encountered while parsing the XML.
|
||||
*/
|
||||
const SkXMLParserError* getParserError();
|
||||
|
||||
/** Returns the details of any error encountered while parsing the XML as string.
|
||||
*/
|
||||
const char* getParserErrorString();
|
||||
|
||||
/** Returns the scalar value of the specified element's attribute
|
||||
@param element is a value returned by getElement
|
||||
@param field is a value returned by getField
|
||||
@return the integer value to retrieve, or SK_NaN32 if not found
|
||||
*/
|
||||
int32_t getInt(const SkDisplayable* element, const SkMemberInfo* field);
|
||||
|
||||
/** Returns the scalar value of the specified element's attribute
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@param fieldName specifies the name of the attribute
|
||||
@return the integer value to retrieve, or SK_NaN32 if not found
|
||||
*/
|
||||
int32_t getInt(const char* elementID, const char* fieldName);
|
||||
|
||||
/** Returns the scalar value of the specified element's attribute
|
||||
@param element is a value returned by getElement
|
||||
@param field is a value returned by getField
|
||||
@return the scalar value to retrieve, or SK_ScalarNaN if not found
|
||||
*/
|
||||
SkScalar getScalar(const SkDisplayable* element, const SkMemberInfo* field);
|
||||
|
||||
/** Returns the scalar value of the specified element's attribute
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@param fieldName specifies the name of the attribute
|
||||
@return the scalar value to retrieve, or SK_ScalarNaN if not found
|
||||
*/
|
||||
SkScalar getScalar(const char* elementID, const char* fieldName);
|
||||
|
||||
/** Returns the string value of the specified element's attribute
|
||||
@param element is a value returned by getElement
|
||||
@param field is a value returned by getField
|
||||
@return the string value to retrieve, or null if not found
|
||||
*/
|
||||
const char* getString(const SkDisplayable* element, const SkMemberInfo* field);
|
||||
|
||||
/** Returns the string value of the specified element's attribute
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@param fieldName specifies the name of the attribute
|
||||
@return the string value to retrieve, or null if not found
|
||||
*/
|
||||
const char* getString(const char* elementID, const char* fieldName);
|
||||
|
||||
/** Gets the file default directory of the URL base path set explicitly or by reading the last URL. */
|
||||
const char* getURIBase();
|
||||
|
||||
/** Resets the animator to a newly created state with no animation data. */
|
||||
void initialize();
|
||||
|
||||
/** Experimental. Resets any active animations so that the next time passed is treated as
|
||||
time zero. */
|
||||
void reset();
|
||||
|
||||
/** Sets the scalar value of the specified element's attribute
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@param fieldName specifies the name of the attribute
|
||||
@param array is the c-style array of integers
|
||||
@param count is the length of the array
|
||||
@return true if the value was set successfully
|
||||
*/
|
||||
bool setArrayInt(const char* elementID, const char* fieldName, const int* array, int count);
|
||||
|
||||
/** Sets the scalar value of the specified element's attribute
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@param fieldName specifies the name of the attribute
|
||||
@param array is the c-style array of strings
|
||||
@param count is the length of the array
|
||||
@return true if the value was set successfully
|
||||
*/
|
||||
bool setArrayString(const char* elementID, const char* fieldName, const char** array, int count);
|
||||
|
||||
/** Sets the scalar value of the specified element's attribute
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@param fieldName specifies the name of the attribute
|
||||
@param data the integer value to set
|
||||
@return true if the value was set successfully
|
||||
*/
|
||||
bool setInt(const char* elementID, const char* fieldName, int32_t data);
|
||||
|
||||
/** Sets the scalar value of the specified element's attribute
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@param fieldName specifies the name of the attribute
|
||||
@param data the scalar value to set
|
||||
@return true if the value was set successfully
|
||||
*/
|
||||
bool setScalar(const char* elementID, const char* fieldName, SkScalar data);
|
||||
|
||||
/** Sets the string value of the specified element's attribute
|
||||
@param elementID is the value of the id attribute in the XML of this element
|
||||
@param fieldName specifies the name of the attribute
|
||||
@param data the string value to set
|
||||
@return true if the value was set successfully
|
||||
*/
|
||||
bool setString(const char* elementID, const char* fieldName, const char* data);
|
||||
|
||||
/** Sets the file default directory of the URL base path
|
||||
@param path the directory path
|
||||
*/
|
||||
void setURIBase(const char* path);
|
||||
|
||||
typedef void* Handler;
|
||||
// This guy needs to be exported to java, so don't make it virtual
|
||||
void setHostHandler(Handler handler) {
|
||||
this->onSetHostHandler(handler);
|
||||
}
|
||||
|
||||
/** \class Timeline
|
||||
Returns current time to animator. To return a custom timeline, create a child
|
||||
class and override the getMSecs method.
|
||||
*/
|
||||
class Timeline {
|
||||
public:
|
||||
virtual ~Timeline() {}
|
||||
|
||||
/** Returns the current time in milliseconds */
|
||||
virtual SkMSec getMSecs() const = 0;
|
||||
};
|
||||
|
||||
/** Sets a user class to return the current time to the animator.
|
||||
Optional; if not called, the system clock will be used by calling SkTime::GetMSecs instead.
|
||||
@param callBack the time function
|
||||
*/
|
||||
void setTimeline(const Timeline& );
|
||||
|
||||
static void Init(bool runUnitTests);
|
||||
static void Term();
|
||||
|
||||
/** The event sink events generated by the animation are posted to.
|
||||
Screenplay also posts an inval event to this event sink after processing an
|
||||
event to force a redraw.
|
||||
@param target the event sink id
|
||||
*/
|
||||
void setHostEventSinkID(SkEventSinkID hostID);
|
||||
SkEventSinkID getHostEventSinkID() const;
|
||||
|
||||
// helper
|
||||
void setHostEventSink(SkEventSink* sink) {
|
||||
this->setHostEventSinkID(sink ? sink->getSinkID() : 0);
|
||||
}
|
||||
|
||||
virtual void setJavaOwner(Handler owner);
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
virtual void eventDone(const SkEvent& evt);
|
||||
virtual bool isTrackingEvents();
|
||||
static bool NoLeaks();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void onSetHostHandler(Handler handler);
|
||||
virtual void onEventPost(SkEvent*, SkEventSinkID);
|
||||
virtual void onEventPostTime(SkEvent*, SkEventSinkID, SkMSec time);
|
||||
|
||||
private:
|
||||
// helper functions for setters
|
||||
bool setArray(SkDisplayable* element, const SkMemberInfo* field, SkTypedArray array);
|
||||
bool setArray(const char* elementID, const char* fieldName, SkTypedArray array);
|
||||
bool setInt(SkDisplayable* element, const SkMemberInfo* field, int32_t data);
|
||||
bool setScalar(SkDisplayable* element, const SkMemberInfo* field, SkScalar data);
|
||||
bool setString(SkDisplayable* element, const SkMemberInfo* field, const char* data);
|
||||
|
||||
virtual bool onEvent(const SkEvent&);
|
||||
SkAnimateMaker* fMaker;
|
||||
friend class SkAnimateMaker;
|
||||
friend class SkAnimatorScript;
|
||||
friend class SkAnimatorScript2;
|
||||
friend class SkApply;
|
||||
friend class SkDisplayMovie;
|
||||
friend class SkDisplayType;
|
||||
friend class SkPost;
|
||||
friend class SkXMLAnimatorWriter;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkAnimatorView_DEFINED
|
||||
#define SkAnimatorView_DEFINED
|
||||
|
||||
#include "SkView.h"
|
||||
#include "SkAnimator.h"
|
||||
|
||||
class SkAnimatorView : public SkView {
|
||||
public:
|
||||
SkAnimatorView();
|
||||
virtual ~SkAnimatorView();
|
||||
|
||||
SkAnimator* getAnimator() const { return fAnimator; }
|
||||
|
||||
bool decodeFile(const char path[]);
|
||||
bool decodeMemory(const void* buffer, size_t size);
|
||||
bool decodeStream(SkStream* stream);
|
||||
|
||||
protected:
|
||||
// overrides
|
||||
virtual bool onEvent(const SkEvent&);
|
||||
virtual void onDraw(SkCanvas*);
|
||||
virtual void onInflate(const SkDOM&, const SkDOM::Node*);
|
||||
|
||||
private:
|
||||
SkAnimator* fAnimator;
|
||||
|
||||
typedef SkView INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkApplication_DEFINED
|
||||
#define SkApplication_DEFINED
|
||||
|
||||
class SkOSWindow;
|
||||
|
||||
extern SkOSWindow* create_sk_window(void* hwnd);
|
||||
extern void application_init();
|
||||
extern void application_term();
|
||||
|
||||
#endif // SkApplication_DEFINED
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkAvoidXfermode_DEFINED
|
||||
#define SkAvoidXfermode_DEFINED
|
||||
|
||||
#include "SkXfermode.h"
|
||||
|
||||
/** \class SkAvoidXfermode
|
||||
|
||||
This xfermode will draw the src everywhere except on top of the specified
|
||||
color.
|
||||
*/
|
||||
class SkAvoidXfermode : public SkXfermode {
|
||||
public:
|
||||
enum Mode {
|
||||
kAvoidColor_Mode, //!< draw everywhere except on the opColor
|
||||
kTargetColor_Mode //!< draw only on top of the opColor
|
||||
};
|
||||
|
||||
/** This xfermode will draw the src everywhere except on top of the opColor
|
||||
or, depending on the Mode, draw only on top of the opColor.
|
||||
@param opColor the color to avoid (or to target depending on Mode).
|
||||
note: the alpha in opColor is ignored
|
||||
@param tolerance How closely we compare a pixel to the opColor.
|
||||
0 - only operate if exact match
|
||||
255 - maximum gradation (blending) based on how
|
||||
similar the pixel is to our opColor (max tolerance)
|
||||
@param mode If we should avoid or target the opColor
|
||||
*/
|
||||
SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode);
|
||||
|
||||
// overrides from SkXfermode
|
||||
virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
|
||||
const SkAlpha aa[]);
|
||||
virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
|
||||
const SkAlpha aa[]);
|
||||
virtual void xfer4444(uint16_t dst[], const SkPMColor src[], int count,
|
||||
const SkAlpha aa[]);
|
||||
virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count,
|
||||
const SkAlpha aa[]);
|
||||
|
||||
// overrides from SkFlattenable
|
||||
virtual Factory getFactory();
|
||||
virtual void flatten(SkFlattenableWriteBuffer&);
|
||||
|
||||
protected:
|
||||
SkAvoidXfermode(SkFlattenableReadBuffer&);
|
||||
|
||||
private:
|
||||
SkColor fOpColor;
|
||||
uint32_t fDistMul; // x.14
|
||||
Mode fMode;
|
||||
|
||||
static SkFlattenable* Create(SkFlattenableReadBuffer&);
|
||||
|
||||
typedef SkXfermode INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkBGViewArtist_DEFINED
|
||||
#define SkBGViewArtist_DEFINED
|
||||
|
||||
#include "SkView.h"
|
||||
#include "SkPaint.h"
|
||||
|
||||
class SkBGViewArtist : public SkView::Artist {
|
||||
public:
|
||||
SkBGViewArtist(SkColor c = SK_ColorWHITE);
|
||||
virtual ~SkBGViewArtist();
|
||||
|
||||
const SkPaint& paint() const { return fPaint; }
|
||||
SkPaint& paint() { return fPaint; }
|
||||
|
||||
protected:
|
||||
// overrides
|
||||
virtual void onDraw(SkView*, SkCanvas*);
|
||||
virtual void onInflate(const SkDOM&, const SkDOM::Node*);
|
||||
|
||||
private:
|
||||
SkPaint fPaint;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkBML_WXMLParser_DEFINED
|
||||
#define SkBML_WXMLParser_DEFINED
|
||||
|
||||
#include "SkString.h"
|
||||
#include "SkXMLParser.h"
|
||||
|
||||
class SkStream;
|
||||
class SkWStream;
|
||||
|
||||
class BML_WXMLParser : public SkXMLParser {
|
||||
public:
|
||||
BML_WXMLParser(SkWStream& writer);
|
||||
virtual ~BML_WXMLParser();
|
||||
static void Write(SkStream& s, const char filename[]);
|
||||
|
||||
/** @cond UNIT_TEST */
|
||||
SkDEBUGCODE(static void UnitTest();)
|
||||
/** @endcond */
|
||||
private:
|
||||
virtual bool onAddAttribute(const char name[], const char value[]);
|
||||
virtual bool onEndElement(const char name[]);
|
||||
virtual bool onStartElement(const char name[]);
|
||||
BML_WXMLParser& operator=(const BML_WXMLParser& src);
|
||||
#ifdef SK_DEBUG
|
||||
int fElemsCount, fElemsReused;
|
||||
int fAttrsCount, fNamesReused, fValuesReused;
|
||||
#endif
|
||||
SkWStream& fWriter;
|
||||
char* fElems[256];
|
||||
char* fAttrNames[256];
|
||||
char* fAttrValues[256];
|
||||
|
||||
// important that these are U8, so we get automatic wrap-around
|
||||
U8 fNextElem, fNextAttrName, fNextAttrValue;
|
||||
};
|
||||
|
||||
#endif // SkBML_WXMLParser_DEFINED
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkBML_XMLParser_DEFINED
|
||||
#define SkBML_XMLParser_DEFINED
|
||||
|
||||
class SkStream;
|
||||
class SkWStream;
|
||||
class SkXMLParser;
|
||||
class SkXMLWriter;
|
||||
|
||||
class BML_XMLParser {
|
||||
public:
|
||||
/** Read the byte XML stream and write the decompressed XML.
|
||||
*/
|
||||
static void Read(SkStream& s, SkXMLWriter& writer);
|
||||
/** Read the byte XML stream and write the decompressed XML into a writable stream.
|
||||
*/
|
||||
static void Read(SkStream& s, SkWStream& output);
|
||||
/** Read the byte XML stream and write the decompressed XML into an XML parser.
|
||||
*/
|
||||
static void Read(SkStream& s, SkXMLParser& output);
|
||||
};
|
||||
|
||||
#endif // SkBML_XMLParser_DEFINED
|
||||
|
||||
@@ -1,684 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkBitmap_DEFINED
|
||||
#define SkBitmap_DEFINED
|
||||
|
||||
#include "Sk64.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkPoint.h"
|
||||
#include "SkRefCnt.h"
|
||||
|
||||
#if defined(SK_BUILD_FOR_MAC)
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
struct SkIRect;
|
||||
class SkColorTable;
|
||||
class SkPaint;
|
||||
class SkPixelRef;
|
||||
class SkRegion;
|
||||
class SkFlattenableReadBuffer;
|
||||
class SkFlattenableWriteBuffer;
|
||||
|
||||
/** \class SkBitmap
|
||||
|
||||
The SkBitmap class specifies a raster bitmap. A bitmap has an integer width
|
||||
and height, and a format (config), and a pointer to the actual pixels.
|
||||
Bitmaps can be drawn into a SkCanvas, but they are also used to specify the target
|
||||
of a SkCanvas' drawing operations.
|
||||
*/
|
||||
class SkBitmap {
|
||||
public:
|
||||
class Allocator;
|
||||
|
||||
enum Config {
|
||||
kNo_Config, //!< bitmap has not been configured
|
||||
kA1_Config, //!< 1-bit per pixel, (0 is transparent, 1 is opaque)
|
||||
kA8_Config, //!< 8-bits per pixel, with only alpha specified (0 is transparent, 0xFF is opaque)
|
||||
kIndex8_Config, //!< 8-bits per pixel, using SkColorTable to specify the colors
|
||||
kRGB_565_Config, //!< 16-bits per pixel, (see SkColorPriv.h for packing)
|
||||
kARGB_4444_Config, //!< 16-bits per pixel, (see SkColorPriv.h for packing)
|
||||
kARGB_8888_Config, //!< 32-bits per pixel, (see SkColorPriv.h for packing)
|
||||
kRLE_Index8_Config,
|
||||
|
||||
kConfigCount
|
||||
};
|
||||
|
||||
/** Default construct creates a bitmap with zero width and height, and no pixels.
|
||||
Its config is set to kNo_Config.
|
||||
*/
|
||||
SkBitmap();
|
||||
/** Constructor initializes the new bitmap by copying the src bitmap. All fields are copied,
|
||||
but ownership of the pixels remains with the src bitmap.
|
||||
*/
|
||||
SkBitmap(const SkBitmap& src);
|
||||
/** Decrements our (shared) pixel ownership if needed.
|
||||
*/
|
||||
~SkBitmap();
|
||||
|
||||
/** Copies the src bitmap into this bitmap. Ownership of the src bitmap's pixels remains
|
||||
with the src bitmap.
|
||||
*/
|
||||
SkBitmap& operator=(const SkBitmap& src);
|
||||
/** Swap the fields of the two bitmaps. This routine is guaranteed to never fail or throw.
|
||||
*/
|
||||
// This method is not exported to java.
|
||||
void swap(SkBitmap& other);
|
||||
|
||||
/** Return true iff the bitmap has empty dimensions.
|
||||
*/
|
||||
bool empty() const { return 0 == fWidth || 0 == fHeight; }
|
||||
|
||||
/** Return true iff the bitmap has no pixels nor a pixelref. Note: this can
|
||||
return true even if the dimensions of the bitmap are > 0 (see empty()).
|
||||
*/
|
||||
bool isNull() const { return NULL == fPixels && NULL == fPixelRef; }
|
||||
|
||||
/** Return the config for the bitmap.
|
||||
*/
|
||||
Config config() const { return (Config)fConfig; }
|
||||
/** DEPRECATED, use config()
|
||||
*/
|
||||
Config getConfig() const { return this->config(); }
|
||||
/** Return the bitmap's width, in pixels.
|
||||
*/
|
||||
int width() const { return fWidth; }
|
||||
/** Return the bitmap's height, in pixels.
|
||||
*/
|
||||
int height() const { return fHeight; }
|
||||
/** Return the number of bytes between subsequent rows of the bitmap.
|
||||
*/
|
||||
int rowBytes() const { return fRowBytes; }
|
||||
|
||||
/** Return the shift amount per pixel (i.e. 0 for 1-byte per pixel, 1 for
|
||||
2-bytes per pixel configs, 2 for 4-bytes per pixel configs). Return 0
|
||||
for configs that are not at least 1-byte per pixel (e.g. kA1_Config
|
||||
or kNo_Config)
|
||||
*/
|
||||
int shiftPerPixel() const { return fBytesPerPixel >> 1; }
|
||||
|
||||
/** Return the number of bytes per pixel based on the config. If the config
|
||||
does not have at least 1 byte per (e.g. kA1_Config) then 0 is returned.
|
||||
*/
|
||||
int bytesPerPixel() const { return fBytesPerPixel; }
|
||||
|
||||
/** Return the rowbytes expressed as a number of pixels (like width and
|
||||
height). Note, for 1-byte per pixel configs like kA8_Config, this will
|
||||
return the same as rowBytes(). Is undefined for configs that are less
|
||||
than 1-byte per pixel (e.g. kA1_Config)
|
||||
*/
|
||||
int rowBytesAsPixels() const { return fRowBytes >> (fBytesPerPixel >> 1); }
|
||||
|
||||
/** Return the address of the pixels for this SkBitmap.
|
||||
*/
|
||||
void* getPixels() const { return fPixels; }
|
||||
|
||||
/** Return the byte size of the pixels, based on the height and rowBytes.
|
||||
Note this truncates the result to 32bits. Call getSize64() to detect
|
||||
if the real size exceeds 32bits.
|
||||
*/
|
||||
size_t getSize() const { return fHeight * fRowBytes; }
|
||||
|
||||
/** Return the byte size of the pixels, based on the height and rowBytes.
|
||||
This routine is slightly slower than getSize(), but does not truncate
|
||||
the answer to 32bits.
|
||||
*/
|
||||
Sk64 getSize64() const {
|
||||
Sk64 size;
|
||||
size.setMul(fHeight, fRowBytes);
|
||||
return size;
|
||||
}
|
||||
|
||||
/** Returns true if the bitmap is opaque (has no translucent/transparent pixels).
|
||||
*/
|
||||
bool isOpaque() const;
|
||||
/** Specify if this bitmap's pixels are all opaque or not. Is only meaningful for configs
|
||||
that support per-pixel alpha (RGB32, A1, A8).
|
||||
*/
|
||||
void setIsOpaque(bool);
|
||||
|
||||
/** Reset the bitmap to its initial state (see default constructor). If we are a (shared)
|
||||
owner of the pixels, that ownership is decremented.
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/** Given a config and a width, this computes the optimal rowBytes value. This is called automatically
|
||||
if you pass 0 for rowBytes to setConfig().
|
||||
*/
|
||||
static int ComputeRowBytes(Config c, int width);
|
||||
|
||||
/** Return the bytes-per-pixel for the specified config. If the config is
|
||||
not at least 1-byte per pixel, return 0, including for kNo_Config.
|
||||
*/
|
||||
static int ComputeBytesPerPixel(Config c);
|
||||
|
||||
/** Return the shift-per-pixel for the specified config. If the config is
|
||||
not at least 1-byte per pixel, return 0, including for kNo_Config.
|
||||
*/
|
||||
static int ComputeShiftPerPixel(Config c) {
|
||||
return ComputeBytesPerPixel(c) >> 1;
|
||||
}
|
||||
|
||||
static Sk64 ComputeSize64(Config, int width, int height);
|
||||
static size_t ComputeSize(Config, int width, int height);
|
||||
|
||||
/** Set the bitmap's config and dimensions. If rowBytes is 0, then
|
||||
ComputeRowBytes() is called to compute the optimal value. This resets
|
||||
any pixel/colortable ownership, just like reset().
|
||||
*/
|
||||
void setConfig(Config, int width, int height, int rowBytes = 0);
|
||||
/** Use this to assign a new pixel address for an existing bitmap. This
|
||||
will automatically release any pixelref previously installed. Only call
|
||||
this if you are handling ownership/lifetime of the pixel memory.
|
||||
|
||||
If the bitmap retains a reference to the colortable (assuming it is
|
||||
not null) it will take care of incrementing the reference count.
|
||||
|
||||
@param pixels Address for the pixels, managed by the caller.
|
||||
@param ctable ColorTable (or null) that matches the specified pixels
|
||||
*/
|
||||
void setPixels(void* p, SkColorTable* ctable = NULL);
|
||||
|
||||
/** Use the standard HeapAllocator to create the pixelref that manages the
|
||||
pixel memory. It will be sized based on the current width/height/config.
|
||||
If this is called multiple times, a new pixelref object will be created
|
||||
each time.
|
||||
|
||||
If the bitmap retains a reference to the colortable (assuming it is
|
||||
not null) it will take care of incrementing the reference count.
|
||||
|
||||
@param ctable ColorTable (or null) to use with the pixels that will
|
||||
be allocated. Only used if config == Index8_Config
|
||||
@return true if the allocation succeeds. If not the pixelref field of
|
||||
the bitmap will be unchanged.
|
||||
*/
|
||||
bool allocPixels(SkColorTable* ctable = NULL) {
|
||||
return this->allocPixels(NULL, ctable);
|
||||
}
|
||||
|
||||
/** Use the specified Allocator to create the pixelref that manages the
|
||||
pixel memory. It will be sized based on the current width/height/config.
|
||||
If this is called multiple times, a new pixelref object will be created
|
||||
each time.
|
||||
|
||||
If the bitmap retains a reference to the colortable (assuming it is
|
||||
not null) it will take care of incrementing the reference count.
|
||||
|
||||
@param allocator The Allocator to use to create a pixelref that can
|
||||
manage the pixel memory for the current
|
||||
width/height/config. If allocator is NULL, the standard
|
||||
HeapAllocator will be used.
|
||||
@param ctable ColorTable (or null) to use with the pixels that will
|
||||
be allocated. Only used if config == Index8_Config.
|
||||
If it is non-null and the config is not Index8, it will
|
||||
be ignored.
|
||||
@return true if the allocation succeeds. If not the pixelref field of
|
||||
the bitmap will be unchanged.
|
||||
*/
|
||||
bool allocPixels(Allocator* allocator, SkColorTable* ctable);
|
||||
|
||||
/** Return the current pixelref object, of any
|
||||
*/
|
||||
SkPixelRef* pixelRef() const { return fPixelRef; }
|
||||
/** Return the offset into the pixelref, if any. Will return 0 if there is
|
||||
no pixelref installed.
|
||||
*/
|
||||
size_t pixelRefOffset() const { return fPixelRefOffset; }
|
||||
/** Assign a pixelref and optional offset. Pixelrefs are reference counted,
|
||||
so the existing one (if any) will be unref'd and the new one will be
|
||||
ref'd.
|
||||
*/
|
||||
SkPixelRef* setPixelRef(SkPixelRef* pr, size_t offset = 0);
|
||||
|
||||
/** Call this to ensure that the bitmap points to the current pixel address
|
||||
in the pixelref. Balance it with a call to unlockPixels(). These calls
|
||||
are harmless if there is no pixelref.
|
||||
*/
|
||||
void lockPixels() const;
|
||||
/** When you are finished access the pixel memory, call this to balance a
|
||||
previous call to lockPixels(). This allows pixelrefs that implement
|
||||
cached/deferred image decoding to know when there are active clients of
|
||||
a given image.
|
||||
*/
|
||||
void unlockPixels() const;
|
||||
|
||||
/** Call this to be sure that the bitmap is valid enough to be drawn (i.e.
|
||||
it has non-null pixels, and if required by its config, it has a
|
||||
non-null colortable. Returns true if all of the above are met.
|
||||
*/
|
||||
bool readyToDraw() const {
|
||||
return this->getPixels() != NULL &&
|
||||
((this->config() != kIndex8_Config && this->config() != kRLE_Index8_Config) ||
|
||||
fColorTable != NULL);
|
||||
}
|
||||
|
||||
/** Return the bitmap's colortable (if any). Does not affect the colortable's
|
||||
reference count.
|
||||
*/
|
||||
SkColorTable* getColorTable() const { return fColorTable; }
|
||||
|
||||
/** Returns a non-zero, unique value corresponding to the pixels in our
|
||||
pixelref, or 0 if we do not have a pixelref. Each time the pixels are
|
||||
changed (and notifyPixelsChanged is called), a different generation ID
|
||||
will be returned.
|
||||
*/
|
||||
uint32_t getGenerationID() const;
|
||||
|
||||
/** Call this if you have changed the contents of the pixels. This will in-
|
||||
turn cause a different generation ID value to be returned from
|
||||
getGenerationID().
|
||||
*/
|
||||
void notifyPixelsChanged() const;
|
||||
|
||||
/** Initialize the bitmap's pixels with the specified color+alpha, automatically converting into the correct format
|
||||
for the bitmap's config. If the config is kRGB_565_Config, then the alpha value is ignored.
|
||||
If the config is kA8_Config, then the r,g,b parameters are ignored.
|
||||
*/
|
||||
void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const;
|
||||
/** Initialize the bitmap's pixels with the specified color+alpha, automatically converting into the correct format
|
||||
for the bitmap's config. If the config is kRGB_565_Config, then the alpha value is presumed
|
||||
to be 0xFF. If the config is kA8_Config, then the r,g,b parameters are ignored and the
|
||||
pixels are all set to 0xFF.
|
||||
*/
|
||||
void eraseRGB(U8CPU r, U8CPU g, U8CPU b) const {
|
||||
this->eraseARGB(0xFF, r, g, b);
|
||||
}
|
||||
/** Initialize the bitmap's pixels with the specified color, automatically converting into the correct format
|
||||
for the bitmap's config. If the config is kRGB_565_Config, then the color's alpha value is presumed
|
||||
to be 0xFF. If the config is kA8_Config, then only the color's alpha value is used.
|
||||
*/
|
||||
void eraseColor(SkColor c) const {
|
||||
this->eraseARGB(SkColorGetA(c), SkColorGetR(c), SkColorGetG(c),
|
||||
SkColorGetB(c));
|
||||
}
|
||||
|
||||
/** Scroll (a subset of) the contents of this bitmap by dx/dy. If there are
|
||||
no pixels allocated (i.e. getPixels() returns null) the method will
|
||||
still update the inval region (if present).
|
||||
|
||||
@param subset The subset of the bitmap to scroll/move. To scroll the
|
||||
entire contents, specify [0, 0, width, height] or just
|
||||
pass null.
|
||||
@param dx The amount to scroll in X
|
||||
@param dy The amount to scroll in Y
|
||||
@param inval Optional (may be null). Returns the area of the bitmap that
|
||||
was scrolled away. E.g. if dx = dy = 0, then inval would
|
||||
be set to empty. If dx >= width or dy >= height, then
|
||||
inval would be set to the entire bounds of the bitmap.
|
||||
@return true if the scroll was doable. Will return false if the bitmap
|
||||
uses an unsupported config for scrolling (only kA8,
|
||||
kIndex8, kRGB_565, kARGB_4444, kARGB_8888 are supported).
|
||||
If no pixels are present (i.e. getPixels() returns false)
|
||||
inval will still be updated, and true will be returned.
|
||||
*/
|
||||
bool scrollRect(const SkIRect* subset, int dx, int dy,
|
||||
SkRegion* inval = NULL) const;
|
||||
|
||||
/** Returns the address of the specified pixel. This performs a runtime
|
||||
check to know the size of the pixels, and will return the same answer
|
||||
as the corresponding size-specific method (e.g. getAddr16). Since the
|
||||
check happens at runtime, it is much slower than using a size-specific
|
||||
version. Unlike the size-specific methods, this routine also checks if
|
||||
getPixels() returns null, and returns that. The size-specific routines
|
||||
perform a debugging assert that getPixels() is not null, but they do
|
||||
not do any runtime checks.
|
||||
*/
|
||||
void* getAddr(int x, int y) const;
|
||||
|
||||
/** Returns the address of the pixel specified by x,y for 32bit pixels.
|
||||
*/
|
||||
inline uint32_t* getAddr32(int x, int y) const;
|
||||
/** Returns the address of the pixel specified by x,y for 16bit pixels.
|
||||
*/
|
||||
inline uint16_t* getAddr16(int x, int y) const;
|
||||
/** Returns the address of the pixel specified by x,y for 8bit pixels.
|
||||
*/
|
||||
inline uint8_t* getAddr8(int x, int y) const;
|
||||
/** Returns the address of the byte containing the pixel specified by x,y
|
||||
for 1bit pixels.
|
||||
*/
|
||||
inline uint8_t* getAddr1(int x, int y) const;
|
||||
|
||||
/** Returns the color corresponding to the pixel specified by x,y for
|
||||
colortable based bitmaps.
|
||||
*/
|
||||
inline SkPMColor getIndex8Color(int x, int y) const;
|
||||
|
||||
// OS-specific helpers
|
||||
#ifndef SK_USE_WXWIDGETS
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
/** On Windows and PocketPC builds, this will draw the SkBitmap onto the
|
||||
specified HDC
|
||||
*/
|
||||
void drawToHDC(HDC, int left, int top) const;
|
||||
#elif defined(SK_BUILD_FOR_MAC)
|
||||
/** On Mac OS X and Carbon builds, this will draw the SkBitmap onto the
|
||||
specified WindowRef
|
||||
*/
|
||||
void drawToPort(WindowRef, CGContextRef) const;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** Set dst to be a setset of this bitmap. If possible, it will share the
|
||||
pixel memory, and just point into a subset of it. However, if the config
|
||||
does not support this, a local copy will be made and associated with
|
||||
the dst bitmap. If the subset rectangle, intersected with the bitmap's
|
||||
dimensions is empty, or if there is an unsupported config, false will be
|
||||
returned and dst will be untouched.
|
||||
@param dst The bitmap that will be set to a subset of this bitmap
|
||||
@param subset The rectangle of pixels in this bitmap that dst will
|
||||
reference.
|
||||
@return true if the subset copy was successfully made.
|
||||
*/
|
||||
bool extractSubset(SkBitmap* dst, const SkIRect& subset) const;
|
||||
|
||||
/** Tries to make a new bitmap based on the dimensions of this bitmap,
|
||||
setting the new bitmap's config to the one specified, and then copying
|
||||
this bitmap's pixels into the new bitmap. If the conversion is not
|
||||
supported, or the allocator fails, then this method returns false and
|
||||
dst is left unchanged.
|
||||
@param dst The bitmap to be sized and allocated
|
||||
@param c The desired config for dst
|
||||
@param allocator Allocator used to allocate the pixelref for the dst
|
||||
bitmap. If this is null, the standard HeapAllocator
|
||||
will be used.
|
||||
@return true if the copy could be made.
|
||||
*/
|
||||
bool copyTo(SkBitmap* dst, Config c, Allocator* allocator = NULL) const;
|
||||
|
||||
bool hasMipMap() const;
|
||||
void buildMipMap(bool forceRebuild = false);
|
||||
void freeMipMap();
|
||||
|
||||
/** Given scale factors sx, sy, determine the miplevel available in the
|
||||
bitmap, and return it (this is the amount to shift matrix iterators
|
||||
by). If dst is not null, it is set to the correct level.
|
||||
*/
|
||||
int extractMipLevel(SkBitmap* dst, SkFixed sx, SkFixed sy);
|
||||
|
||||
void extractAlpha(SkBitmap* dst) const {
|
||||
this->extractAlpha(dst, NULL, NULL);
|
||||
}
|
||||
|
||||
void extractAlpha(SkBitmap* dst, const SkPaint* paint,
|
||||
SkIPoint* offset) const;
|
||||
|
||||
void flatten(SkFlattenableWriteBuffer&) const;
|
||||
void unflatten(SkFlattenableReadBuffer&);
|
||||
|
||||
SkDEBUGCODE(void validate() const;)
|
||||
|
||||
class Allocator : public SkRefCnt {
|
||||
public:
|
||||
/** Allocate the pixel memory for the bitmap, given its dimensions and
|
||||
config. Return true on success, where success means either setPixels
|
||||
or setPixelRef was called. The pixels need not be locked when this
|
||||
returns. If the config requires a colortable, it also must be
|
||||
installed via setColorTable. If false is returned, the bitmap and
|
||||
colortable should be left unchanged.
|
||||
*/
|
||||
virtual bool allocPixelRef(SkBitmap*, SkColorTable*) = 0;
|
||||
};
|
||||
|
||||
/** Subclass of Allocator that returns a pixelref that allocates its pixel
|
||||
memory from the heap. This is the default Allocator invoked by
|
||||
allocPixels().
|
||||
*/
|
||||
class HeapAllocator : public Allocator {
|
||||
public:
|
||||
virtual bool allocPixelRef(SkBitmap*, SkColorTable*);
|
||||
};
|
||||
|
||||
class RLEPixels {
|
||||
public:
|
||||
RLEPixels(int width, int height);
|
||||
virtual ~RLEPixels();
|
||||
|
||||
uint8_t* packedAtY(int y) const {
|
||||
SkASSERT((unsigned)y < (unsigned)fHeight);
|
||||
return fYPtrs[y];
|
||||
}
|
||||
|
||||
// called by subclasses during creation
|
||||
void setPackedAtY(int y, uint8_t* addr) {
|
||||
SkASSERT((unsigned)y < (unsigned)fHeight);
|
||||
fYPtrs[y] = addr;
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t** fYPtrs;
|
||||
int fHeight;
|
||||
};
|
||||
|
||||
private:
|
||||
#ifdef SK_SUPPORT_MIPMAP
|
||||
struct MipMap;
|
||||
mutable MipMap* fMipMap;
|
||||
#endif
|
||||
|
||||
mutable SkPixelRef* fPixelRef;
|
||||
mutable size_t fPixelRefOffset;
|
||||
mutable int fPixelLockCount;
|
||||
// either user-specified (in which case it is not treated as mutable)
|
||||
// or a cache of the returned value from fPixelRef->lockPixels()
|
||||
mutable void* fPixels;
|
||||
mutable SkColorTable* fColorTable; // only meaningful for kIndex8
|
||||
|
||||
enum Flags {
|
||||
kImageIsOpaque_Flag = 0x01
|
||||
};
|
||||
|
||||
uint32_t fRowBytes;
|
||||
uint16_t fWidth, fHeight;
|
||||
uint8_t fConfig;
|
||||
uint8_t fFlags;
|
||||
uint8_t fBytesPerPixel; // based on config
|
||||
|
||||
/* Unreference any pixelrefs or colortables
|
||||
*/
|
||||
void freePixels();
|
||||
void updatePixelsFromRef() const;
|
||||
|
||||
static SkFixed ComputeMipLevel(SkFixed sx, SkFixed dy);
|
||||
};
|
||||
|
||||
/** \class SkColorTable
|
||||
|
||||
SkColorTable holds an array SkPMColors (premultiplied 32-bit colors) used by
|
||||
8-bit bitmaps, where the bitmap bytes are interpreted as indices into the colortable.
|
||||
*/
|
||||
class SkColorTable : public SkRefCnt {
|
||||
public:
|
||||
/** Constructs an empty color table (zero colors).
|
||||
*/
|
||||
explicit SkColorTable(int count);
|
||||
explicit SkColorTable(SkFlattenableReadBuffer&);
|
||||
SkColorTable(const SkPMColor colors[], int count);
|
||||
virtual ~SkColorTable();
|
||||
|
||||
enum Flags {
|
||||
kColorsAreOpaque_Flag = 0x01 //!< if set, all of the colors in the table are opaque (alpha==0xFF)
|
||||
};
|
||||
/** Returns the flag bits for the color table. These can be changed with setFlags().
|
||||
*/
|
||||
unsigned getFlags() const { return fFlags; }
|
||||
/** Set the flags for the color table. See the Flags enum for possible values.
|
||||
*/
|
||||
void setFlags(unsigned flags);
|
||||
|
||||
/** Returns the number of colors in the table.
|
||||
*/
|
||||
int count() const { return fCount; }
|
||||
|
||||
/** Returns the specified color from the table. In the debug build, this asserts that
|
||||
the index is in range (0 <= index < count).
|
||||
*/
|
||||
SkPMColor operator[](int index) const {
|
||||
SkASSERT(fColors != NULL && (unsigned)index < fCount);
|
||||
return fColors[index];
|
||||
}
|
||||
|
||||
/** Specify the number of colors in the color table. This does not initialize the colors
|
||||
to any value, just allocates memory for them. To initialize the values, either call
|
||||
setColors(array, count), or follow setCount(count) with a call to
|
||||
lockColors()/{set the values}/unlockColors(true).
|
||||
*/
|
||||
// void setColors(int count) { this->setColors(NULL, count); }
|
||||
// void setColors(const SkPMColor[], int count);
|
||||
|
||||
/** Return the array of colors for reading and/or writing. This must be
|
||||
balanced by a call to unlockColors(changed?), telling the colortable if
|
||||
the colors were changed during the lock.
|
||||
*/
|
||||
SkPMColor* lockColors() {
|
||||
SkDEBUGCODE(fColorLockCount += 1;)
|
||||
return fColors;
|
||||
}
|
||||
/** Balancing call to lockColors(). If the colors have been changed, pass true.
|
||||
*/
|
||||
void unlockColors(bool changed);
|
||||
|
||||
/** Similar to lockColors(), lock16BitCache() returns the array of
|
||||
RGB16 colors that mirror the 32bit colors. However, this function
|
||||
will return null if kColorsAreOpaque_Flag is not set.
|
||||
Also, unlike lockColors(), the returned array here cannot be modified.
|
||||
*/
|
||||
const uint16_t* lock16BitCache();
|
||||
/** Balancing call to lock16BitCache().
|
||||
*/
|
||||
void unlock16BitCache() {
|
||||
SkASSERT(f16BitCacheLockCount > 0);
|
||||
SkDEBUGCODE(f16BitCacheLockCount -= 1);
|
||||
}
|
||||
|
||||
void flatten(SkFlattenableWriteBuffer&) const;
|
||||
|
||||
private:
|
||||
SkPMColor* fColors;
|
||||
uint16_t* f16BitCache;
|
||||
uint16_t fCount;
|
||||
uint8_t fFlags;
|
||||
SkDEBUGCODE(int fColorLockCount;)
|
||||
SkDEBUGCODE(int f16BitCacheLockCount;)
|
||||
|
||||
void inval16BitCache();
|
||||
};
|
||||
|
||||
class SkAutoLockPixels {
|
||||
public:
|
||||
SkAutoLockPixels(const SkBitmap& bitmap) : fBitmap(bitmap) {
|
||||
bitmap.lockPixels();
|
||||
}
|
||||
~SkAutoLockPixels() {
|
||||
fBitmap.unlockPixels();
|
||||
}
|
||||
|
||||
private:
|
||||
const SkBitmap& fBitmap;
|
||||
};
|
||||
|
||||
/** Helper class that performs the lock/unlockColors calls on a colortable.
|
||||
The destructor will call unlockColors(false) if it has a bitmap's colortable
|
||||
*/
|
||||
class SkAutoLockColors : public SkNoncopyable {
|
||||
public:
|
||||
/** Initialize with no bitmap. Call lockColors(bitmap) to lock bitmap's
|
||||
colortable
|
||||
*/
|
||||
SkAutoLockColors() : fCTable(NULL), fColors(NULL) {}
|
||||
/** Initialize with bitmap, locking its colortable if present
|
||||
*/
|
||||
explicit SkAutoLockColors(const SkBitmap& bm) {
|
||||
fCTable = bm.getColorTable();
|
||||
fColors = fCTable ? fCTable->lockColors() : NULL;
|
||||
}
|
||||
/** Initialize with a colortable (may be null)
|
||||
*/
|
||||
explicit SkAutoLockColors(SkColorTable* ctable) {
|
||||
fCTable = ctable;
|
||||
fColors = ctable ? ctable->lockColors() : NULL;
|
||||
}
|
||||
~SkAutoLockColors() {
|
||||
if (fCTable) {
|
||||
fCTable->unlockColors(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** Return the currently locked colors, or NULL if no bitmap's colortable
|
||||
is currently locked.
|
||||
*/
|
||||
const SkPMColor* colors() const { return fColors; }
|
||||
|
||||
/** If a previous bitmap has been locked by this object, unlock its colors
|
||||
first. If the specified bitmap has a colortable, lock its colors and
|
||||
return them.
|
||||
*/
|
||||
const SkPMColor* lockColors(const SkBitmap& bm) {
|
||||
if (fCTable) {
|
||||
fCTable->unlockColors(false);
|
||||
}
|
||||
fCTable = bm.getColorTable();
|
||||
fColors = fCTable ? fCTable->lockColors() : NULL;
|
||||
return fColors;
|
||||
}
|
||||
|
||||
private:
|
||||
SkColorTable* fCTable;
|
||||
const SkPMColor* fColors;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline uint32_t* SkBitmap::getAddr32(int x, int y) const {
|
||||
SkASSERT(fPixels);
|
||||
SkASSERT(fConfig == kARGB_8888_Config);
|
||||
SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
|
||||
return (uint32_t*)((char*)fPixels + y * fRowBytes + (x << 2));
|
||||
}
|
||||
|
||||
inline uint16_t* SkBitmap::getAddr16(int x, int y) const {
|
||||
SkASSERT(fPixels);
|
||||
SkASSERT(fConfig == kRGB_565_Config || fConfig == kARGB_4444_Config);
|
||||
SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
|
||||
return (uint16_t*)((char*)fPixels + y * fRowBytes + (x << 1));
|
||||
}
|
||||
|
||||
inline uint8_t* SkBitmap::getAddr8(int x, int y) const {
|
||||
SkASSERT(fPixels);
|
||||
SkASSERT(fConfig == kA8_Config || fConfig == kIndex8_Config);
|
||||
SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
|
||||
return (uint8_t*)fPixels + y * fRowBytes + x;
|
||||
}
|
||||
|
||||
inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const {
|
||||
SkASSERT(fPixels);
|
||||
SkASSERT(fConfig == kIndex8_Config);
|
||||
SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
|
||||
SkASSERT(fColorTable);
|
||||
return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)];
|
||||
}
|
||||
|
||||
// returns the address of the byte that contains the x coordinate
|
||||
inline uint8_t* SkBitmap::getAddr1(int x, int y) const {
|
||||
SkASSERT(fPixels);
|
||||
SkASSERT(fConfig == kA1_Config);
|
||||
SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
|
||||
return (uint8_t*)fPixels + y * fRowBytes + (x >> 3);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkBlurDrawLooper_DEFINED
|
||||
#define SkBlurDrawLooper_DEFINED
|
||||
|
||||
#include "SkDrawLooper.h"
|
||||
#include "SkColor.h"
|
||||
|
||||
class SkMaskFilter;
|
||||
|
||||
/** \class SkBlurDrawLooper
|
||||
This class draws a shadow of the object (possibly offset), and then draws
|
||||
the original object in its original position.
|
||||
should there be an option to just draw the shadow/blur layer? webkit?
|
||||
*/
|
||||
class SkBlurDrawLooper : public SkDrawLooper {
|
||||
public:
|
||||
SkBlurDrawLooper(SkScalar radius, SkScalar dx, SkScalar dy, SkColor color);
|
||||
virtual ~SkBlurDrawLooper();
|
||||
|
||||
// overrides from SkDrawLooper
|
||||
virtual void init(SkCanvas*, SkPaint*);
|
||||
virtual bool next();
|
||||
virtual void restore();
|
||||
|
||||
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
|
||||
return SkNEW_ARGS(SkBlurDrawLooper, (buffer));
|
||||
}
|
||||
|
||||
protected:
|
||||
SkBlurDrawLooper(SkFlattenableReadBuffer&);
|
||||
// overrides from SkFlattenable
|
||||
virtual void flatten(SkFlattenableWriteBuffer& );
|
||||
virtual Factory getFactory() { return CreateProc; }
|
||||
|
||||
private:
|
||||
SkCanvas* fCanvas;
|
||||
SkPaint* fPaint;
|
||||
SkMaskFilter* fBlur;
|
||||
SkScalar fDx, fDy;
|
||||
SkColor fBlurColor;
|
||||
SkColor fSavedColor; // remember the original
|
||||
int fSaveCount;
|
||||
|
||||
enum State {
|
||||
kBeforeEdge,
|
||||
kAfterEdge,
|
||||
kDone
|
||||
};
|
||||
State fState;
|
||||
|
||||
typedef SkDrawLooper INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkBlurMaskFilter_DEFINED
|
||||
#define SkBlurMaskFilter_DEFINED
|
||||
|
||||
// we include this since our callers will need to at least be able to ref/unref
|
||||
#include "SkMaskFilter.h"
|
||||
#include "SkScalar.h"
|
||||
|
||||
class SkBlurMaskFilter {
|
||||
public:
|
||||
enum BlurStyle {
|
||||
kNormal_BlurStyle, //!< fuzzy inside and outside
|
||||
kSolid_BlurStyle, //!< solid inside, fuzzy outside
|
||||
kOuter_BlurStyle, //!< nothing inside, fuzzy outside
|
||||
kInner_BlurStyle, //!< fuzzy inside, nothing outside
|
||||
|
||||
kBlurStyleCount
|
||||
};
|
||||
|
||||
/** Create a blur maskfilter.
|
||||
@param radius The radius to extend the blur from the original mask. Must be > 0.
|
||||
@param style The BlurStyle to use
|
||||
@return The new blur maskfilter
|
||||
*/
|
||||
static SkMaskFilter* Create(SkScalar radius, BlurStyle style);
|
||||
|
||||
/** Create an emboss maskfilter
|
||||
@param direction array of 3 scalars [x, y, z] specifying the direction of the light source
|
||||
@param ambient 0...1 amount of ambient light
|
||||
@param specular coefficient for specular highlights (e.g. 8)
|
||||
@param blurRadius amount to blur before applying lighting (e.g. 3)
|
||||
@return the emboss maskfilter
|
||||
*/
|
||||
static SkMaskFilter* CreateEmboss( const SkScalar direction[3],
|
||||
SkScalar ambient, SkScalar specular,
|
||||
SkScalar blurRadius);
|
||||
|
||||
private:
|
||||
SkBlurMaskFilter(); // can't be instantiated
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkBorderView_DEFINED
|
||||
#define SkBorderView_DEFINED
|
||||
|
||||
#include "SkView.h"
|
||||
#include "SkWidgetViews.h"
|
||||
#include "SkAnimator.h"
|
||||
|
||||
class SkBorderView : public SkWidgetView {
|
||||
public:
|
||||
SkBorderView();
|
||||
~SkBorderView();
|
||||
void setSkin(const char skin[]);
|
||||
SkScalar getLeft() const { return fLeft; }
|
||||
SkScalar getRight() const { return fRight; }
|
||||
SkScalar getTop() const { return fTop; }
|
||||
SkScalar getBottom() const { return fBottom; }
|
||||
protected:
|
||||
//overrides
|
||||
virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
|
||||
virtual void onSizeChange();
|
||||
virtual void onDraw(SkCanvas* canvas);
|
||||
virtual bool onEvent(const SkEvent& evt);
|
||||
private:
|
||||
SkAnimator fAnim;
|
||||
SkScalar fLeft, fRight, fTop, fBottom; //margin on each side
|
||||
SkRect fMargin;
|
||||
|
||||
typedef SkWidgetView INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkBounder_DEFINED
|
||||
#define SkBounder_DEFINED
|
||||
|
||||
#include "SkTypes.h"
|
||||
#include "SkRefCnt.h"
|
||||
|
||||
struct SkIRect;
|
||||
struct SkPoint;
|
||||
struct SkRect;
|
||||
class SkPaint;
|
||||
class SkPath;
|
||||
class SkRegion;
|
||||
|
||||
/** \class SkBounder
|
||||
|
||||
Base class for intercepting the device bounds of shapes before they are drawn.
|
||||
Install a subclass of this in your canvas.
|
||||
*/
|
||||
class SkBounder : public SkRefCnt {
|
||||
public:
|
||||
/* Call to perform a clip test before calling onIRect.
|
||||
Returns the result from onIRect.
|
||||
*/
|
||||
bool doIRect(const SkIRect&);
|
||||
|
||||
protected:
|
||||
/** Override in your subclass. This is called with the device bounds of an
|
||||
object (text, geometry, image) just before it is drawn. If your method
|
||||
returns false, the drawing for that shape is aborted. If your method
|
||||
returns true, drawing continues. The bounds your method receives have already
|
||||
been transformed in to device coordinates, and clipped to the current clip.
|
||||
*/
|
||||
virtual bool onIRect(const SkIRect&) = 0;
|
||||
|
||||
/** Called after each shape has been drawn. The default implementation does
|
||||
nothing, but your override could use this notification to signal itself
|
||||
that the offscreen being rendered into needs to be updated to the screen.
|
||||
*/
|
||||
virtual void commit();
|
||||
|
||||
private:
|
||||
bool doHairline(const SkPoint&, const SkPoint&, const SkPaint&);
|
||||
bool doRect(const SkRect&, const SkPaint&);
|
||||
bool doPath(const SkPath&, const SkPaint&, bool doFill);
|
||||
void setClip(const SkRegion* clip) { fClip = clip; }
|
||||
|
||||
const SkRegion* fClip;
|
||||
friend class SkAutoBounderCommit;
|
||||
friend class SkDraw;
|
||||
friend class SkDrawIter;
|
||||
friend struct Draw1Glyph;
|
||||
friend class SkMaskFilter;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Inspired by Rob Johnson's most excellent QuickDraw GX sample code
|
||||
|
||||
#ifndef SkCamera_DEFINED
|
||||
#define SkCamera_DEFINED
|
||||
|
||||
#include "Sk64.h"
|
||||
#include "SkMatrix.h"
|
||||
|
||||
class SkCanvas;
|
||||
|
||||
#ifdef SK_SCALAR_IS_FIXED
|
||||
typedef SkFract SkUnitScalar;
|
||||
#define SK_UnitScalar1 SK_Fract1
|
||||
#define SkUnitScalarMul(a, b) SkFractMul(a, b)
|
||||
#define SkUnitScalarDiv(a, b) SkFractDiv(a, b)
|
||||
#else
|
||||
typedef float SkUnitScalar;
|
||||
#define SK_UnitScalar1 SK_Scalar1
|
||||
#define SkUnitScalarMul(a, b) SkScalarMul(a, b)
|
||||
#define SkUnitScalarDiv(a, b) SkScalarDiv(a, b)
|
||||
#endif
|
||||
|
||||
struct SkUnit3D {
|
||||
SkUnitScalar fX, fY, fZ;
|
||||
|
||||
void set(SkUnitScalar x, SkUnitScalar y, SkUnitScalar z)
|
||||
{
|
||||
fX = x; fY = y; fZ = z;
|
||||
}
|
||||
static SkUnitScalar Dot(const SkUnit3D&, const SkUnit3D&);
|
||||
static void Cross(const SkUnit3D&, const SkUnit3D&, SkUnit3D* cross);
|
||||
};
|
||||
|
||||
struct SkPoint3D {
|
||||
SkScalar fX, fY, fZ;
|
||||
|
||||
void set(SkScalar x, SkScalar y, SkScalar z)
|
||||
{
|
||||
fX = x; fY = y; fZ = z;
|
||||
}
|
||||
SkScalar normalize(SkUnit3D*) const;
|
||||
};
|
||||
typedef SkPoint3D SkVector3D;
|
||||
|
||||
struct SkMatrix3D {
|
||||
SkScalar fMat[3][4];
|
||||
|
||||
void reset();
|
||||
|
||||
void setRow(int row, SkScalar a, SkScalar b, SkScalar c, SkScalar d = 0)
|
||||
{
|
||||
SkASSERT((unsigned)row < 3);
|
||||
fMat[row][0] = a;
|
||||
fMat[row][1] = b;
|
||||
fMat[row][2] = c;
|
||||
fMat[row][3] = d;
|
||||
}
|
||||
|
||||
void setRotateX(SkScalar deg);
|
||||
void setRotateY(SkScalar deg);
|
||||
void setRotateZ(SkScalar deg);
|
||||
void setTranslate(SkScalar x, SkScalar y, SkScalar z);
|
||||
|
||||
void preRotateX(SkScalar deg);
|
||||
void preRotateY(SkScalar deg);
|
||||
void preRotateZ(SkScalar deg);
|
||||
void preTranslate(SkScalar x, SkScalar y, SkScalar z);
|
||||
|
||||
void setConcat(const SkMatrix3D& a, const SkMatrix3D& b);
|
||||
void mapPoint(const SkPoint3D& src, SkPoint3D* dst) const;
|
||||
void mapVector(const SkVector3D& src, SkVector3D* dst) const;
|
||||
|
||||
void mapPoint(SkPoint3D* v) const
|
||||
{
|
||||
this->mapPoint(*v, v);
|
||||
}
|
||||
void mapVector(SkVector3D* v) const
|
||||
{
|
||||
this->mapVector(*v, v);
|
||||
}
|
||||
};
|
||||
|
||||
class SkPatch3D {
|
||||
public:
|
||||
SkPatch3D();
|
||||
|
||||
void reset();
|
||||
void transform(const SkMatrix3D&, SkPatch3D* dst = NULL) const;
|
||||
|
||||
// dot a unit vector with the patch's normal
|
||||
SkScalar dotWith(SkScalar dx, SkScalar dy, SkScalar dz) const;
|
||||
SkScalar dotWith(const SkVector3D& v) const
|
||||
{
|
||||
return this->dotWith(v.fX, v.fY, v.fZ);
|
||||
}
|
||||
|
||||
// depreicated, but still here for animator (for now)
|
||||
void rotate(SkScalar x, SkScalar y, SkScalar z) {}
|
||||
void rotateDegrees(SkScalar x, SkScalar y, SkScalar z) {}
|
||||
|
||||
private:
|
||||
public: // make public for SkDraw3D for now
|
||||
SkVector3D fU, fV;
|
||||
SkPoint3D fOrigin;
|
||||
|
||||
friend class SkCamera3D;
|
||||
};
|
||||
|
||||
class SkCamera3D {
|
||||
public:
|
||||
SkCamera3D();
|
||||
|
||||
void reset();
|
||||
void update();
|
||||
void patchToMatrix(const SkPatch3D&, SkMatrix* matrix) const;
|
||||
|
||||
SkPoint3D fLocation;
|
||||
SkPoint3D fAxis;
|
||||
SkPoint3D fZenith;
|
||||
SkPoint3D fObserver;
|
||||
|
||||
private:
|
||||
mutable SkMatrix fOrientation;
|
||||
mutable bool fNeedToUpdate;
|
||||
|
||||
void doUpdate() const;
|
||||
};
|
||||
|
||||
class Sk3DView : SkNoncopyable {
|
||||
public:
|
||||
Sk3DView();
|
||||
~Sk3DView();
|
||||
|
||||
void save();
|
||||
void restore();
|
||||
|
||||
void translate(SkScalar x, SkScalar y, SkScalar z);
|
||||
void rotateX(SkScalar deg);
|
||||
void rotateY(SkScalar deg);
|
||||
void rotateZ(SkScalar deg);
|
||||
|
||||
void getMatrix(SkMatrix*) const;
|
||||
void applyToCanvas(SkCanvas*) const;
|
||||
|
||||
SkScalar dotWithNormal(SkScalar dx, SkScalar dy, SkScalar dz) const;
|
||||
|
||||
private:
|
||||
struct Rec {
|
||||
Rec* fNext;
|
||||
SkMatrix3D fMatrix;
|
||||
};
|
||||
Rec* fRec;
|
||||
Rec fInitialRec;
|
||||
SkCamera3D fCamera;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,794 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkCanvas_DEFINED
|
||||
#define SkCanvas_DEFINED
|
||||
|
||||
#include "SkTypes.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkDeque.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkPorterDuff.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkRegion.h"
|
||||
#include "SkScalarCompare.h"
|
||||
|
||||
class SkBounder;
|
||||
class SkDevice;
|
||||
class SkDraw;
|
||||
class SkDrawFilter;
|
||||
class SkPicture;
|
||||
|
||||
/** \class SkCanvas
|
||||
|
||||
A Canvas encapsulates all of the state about drawing into a device (bitmap).
|
||||
This includes a reference to the device itself, and a stack of matrix/clip
|
||||
values. For any given draw call (e.g. drawRect), the geometry of the object
|
||||
being drawn is transformed by the concatenation of all the matrices in the
|
||||
stack. The transformed geometry is clipped by the intersection of all of
|
||||
the clips in the stack.
|
||||
|
||||
While the Canvas holds the state of the drawing device, the state (style)
|
||||
of the object being drawn is held by the Paint, which is provided as a
|
||||
parameter to each of the draw() methods. The Paint holds attributes such as
|
||||
color, typeface, textSize, strokeWidth, shader (e.g. gradients, patterns),
|
||||
etc.
|
||||
*/
|
||||
class SkCanvas : public SkRefCnt {
|
||||
public:
|
||||
/** Construct a canvas with the specified bitmap to draw into.
|
||||
@param bitmap Specifies a bitmap for the canvas to draw into. Its
|
||||
structure are copied to the canvas.
|
||||
*/
|
||||
explicit SkCanvas(const SkBitmap& bitmap);
|
||||
/** Construct a canvas with the specified device to draw into.
|
||||
@param device Specifies a device for the canvas to draw into. The
|
||||
device may be null.
|
||||
*/
|
||||
explicit SkCanvas(SkDevice* device = NULL);
|
||||
virtual ~SkCanvas();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** If this subclass of SkCanvas supports GL viewports, return true and set
|
||||
size (if not null) to the size of the viewport. If it is not supported,
|
||||
ignore vp and return false.
|
||||
*/
|
||||
virtual bool getViewport(SkIPoint* size) const;
|
||||
|
||||
/** If this subclass of SkCanvas supports GL viewports, return true and set
|
||||
the viewport to the specified x and y dimensions. If it is not
|
||||
supported, ignore x and y and return false.
|
||||
*/
|
||||
virtual bool setViewport(int x, int y);
|
||||
|
||||
/** Return the canvas' device object, which may be null. The device holds
|
||||
the bitmap of the pixels that the canvas draws into. The reference count
|
||||
of the returned device is not changed by this call.
|
||||
*/
|
||||
SkDevice* getDevice() const;
|
||||
|
||||
/** Specify a device for this canvas to draw into. If it is not null, its
|
||||
reference count is incremented. If the canvas was already holding a
|
||||
device, its reference count is decremented. The new device is returned.
|
||||
*/
|
||||
SkDevice* setDevice(SkDevice* device);
|
||||
|
||||
/** Specify a bitmap for the canvas to draw into. This is a help method for
|
||||
setDevice(), and it creates a device for the bitmap by calling
|
||||
createDevice(). The structure of the bitmap is copied into the device.
|
||||
*/
|
||||
virtual SkDevice* setBitmapDevice(const SkBitmap& bitmap);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
enum SaveFlags {
|
||||
/** save the matrix state, restoring it on restore() */
|
||||
kMatrix_SaveFlag = 0x01,
|
||||
/** save the clip state, restoring it on restore() */
|
||||
kClip_SaveFlag = 0x02,
|
||||
/** the layer needs to support per-pixel alpha */
|
||||
kHasAlphaLayer_SaveFlag = 0x04,
|
||||
/** the layer needs to support 8-bits per color component */
|
||||
kFullColorLayer_SaveFlag = 0x08,
|
||||
/** the layer should clip against the bounds argument */
|
||||
kClipToLayer_SaveFlag = 0x10,
|
||||
|
||||
// helper masks for common choices
|
||||
kMatrixClip_SaveFlag = 0x03,
|
||||
kARGB_NoClipLayer_SaveFlag = 0x0F,
|
||||
kARGB_ClipLayer_SaveFlag = 0x1F
|
||||
};
|
||||
|
||||
/** This call saves the current matrix and clip information, and pushes a
|
||||
copy onto a private stack. Subsequent calls to translate, scale,
|
||||
rotate, skew, concat or clipRect, clipPath all operate on this copy.
|
||||
When the balancing call to restore() is made, this copy is deleted and
|
||||
the previous matrix/clip state is restored.
|
||||
@return The value to pass to restoreToCount() to balance this save()
|
||||
*/
|
||||
virtual int save(SaveFlags flags = kMatrixClip_SaveFlag);
|
||||
|
||||
/** This behaves the same as save(), but in addition it allocates an
|
||||
offscreen bitmap. All drawing calls are directed there, and only when
|
||||
the balancing call to restore() is made is that offscreen transfered to
|
||||
the canvas (or the previous layer). Subsequent calls to translate,
|
||||
scale, rotate, skew, concat or clipRect, clipPath all operate on this
|
||||
copy. When the balancing call to restore() is made, this copy is deleted
|
||||
and the previous matrix/clip state is restored.
|
||||
@param bounds (may be null) the maximum size the offscreen bitmap needs
|
||||
to be (in local coordinates)
|
||||
@param paint (may be null) This is copied, and is applied to the
|
||||
offscreen when restore() is called
|
||||
@param flags LayerFlags
|
||||
@return The value to pass to restoreToCount() to balance this save()
|
||||
*/
|
||||
virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,
|
||||
SaveFlags flags = kARGB_ClipLayer_SaveFlag);
|
||||
|
||||
/** This behaves the same as save(), but in addition it allocates an
|
||||
offscreen bitmap. All drawing calls are directed there, and only when
|
||||
the balancing call to restore() is made is that offscreen transfered to
|
||||
the canvas (or the previous layer). Subsequent calls to translate,
|
||||
scale, rotate, skew, concat or clipRect, clipPath all operate on this
|
||||
copy. When the balancing call to restore() is made, this copy is deleted
|
||||
and the previous matrix/clip state is restored.
|
||||
@param bounds (may be null) the maximum size the offscreen bitmap needs
|
||||
to be (in local coordinates)
|
||||
@param alpha This is applied to the offscreen when restore() is called.
|
||||
@param flags LayerFlags
|
||||
@return The value to pass to restoreToCount() to balance this save()
|
||||
*/
|
||||
int saveLayerAlpha(const SkRect* bounds, U8CPU alpha,
|
||||
SaveFlags flags = kARGB_ClipLayer_SaveFlag);
|
||||
|
||||
/** This call balances a previous call to save(), and is used to remove all
|
||||
modifications to the matrix/clip state since the last save call. It is
|
||||
an error to call restore() more times than save() was called.
|
||||
*/
|
||||
virtual void restore();
|
||||
|
||||
/** Returns the number of matrix/clip states on the SkCanvas' private stack.
|
||||
This will equal # save() calls - # restore() calls.
|
||||
*/
|
||||
int getSaveCount() const;
|
||||
|
||||
/** Efficient way to pop any calls to save() that happened after the save
|
||||
count reached saveCount. It is an error for saveCount to be less than
|
||||
getSaveCount()
|
||||
@param saveCount The number of save() levels to restore from
|
||||
*/
|
||||
void restoreToCount(int saveCount);
|
||||
|
||||
/** Preconcat the current matrix with the specified translation
|
||||
@param dx The distance to translate in X
|
||||
@param dy The distance to translate in Y
|
||||
returns true if the operation succeeded (e.g. did not overflow)
|
||||
*/
|
||||
virtual bool translate(SkScalar dx, SkScalar dy);
|
||||
|
||||
/** Preconcat the current matrix with the specified scale.
|
||||
@param sx The amount to scale in X
|
||||
@param sy The amount to scale in Y
|
||||
returns true if the operation succeeded (e.g. did not overflow)
|
||||
*/
|
||||
virtual bool scale(SkScalar sx, SkScalar sy);
|
||||
|
||||
/** Preconcat the current matrix with the specified rotation.
|
||||
@param degrees The amount to rotate, in degrees
|
||||
returns true if the operation succeeded (e.g. did not overflow)
|
||||
*/
|
||||
virtual bool rotate(SkScalar degrees);
|
||||
|
||||
/** Preconcat the current matrix with the specified skew.
|
||||
@param sx The amount to skew in X
|
||||
@param sy The amount to skew in Y
|
||||
returns true if the operation succeeded (e.g. did not overflow)
|
||||
*/
|
||||
virtual bool skew(SkScalar sx, SkScalar sy);
|
||||
|
||||
/** Preconcat the current matrix with the specified matrix.
|
||||
@param matrix The matrix to preconcatenate with the current matrix
|
||||
@return true if the operation succeeded (e.g. did not overflow)
|
||||
*/
|
||||
virtual bool concat(const SkMatrix& matrix);
|
||||
|
||||
/** Replace the current matrix with a copy of the specified matrix.
|
||||
@param matrix The matrix that will be copied into the current matrix.
|
||||
*/
|
||||
virtual void setMatrix(const SkMatrix& matrix);
|
||||
|
||||
/** Helper for setMatrix(identity). Sets the current matrix to identity.
|
||||
*/
|
||||
void resetMatrix();
|
||||
|
||||
/** Modify the current clip with the specified rectangle.
|
||||
@param rect The rect to intersect with the current clip
|
||||
@param op The region op to apply to the current clip
|
||||
@return true if the canvas' clip is non-empty
|
||||
*/
|
||||
virtual bool clipRect(const SkRect& rect,
|
||||
SkRegion::Op op = SkRegion::kIntersect_Op);
|
||||
|
||||
/** Modify the current clip with the specified path.
|
||||
@param path The path to apply to the current clip
|
||||
@param op The region op to apply to the current clip
|
||||
@return true if the canvas' new clip is non-empty
|
||||
*/
|
||||
virtual bool clipPath(const SkPath& path,
|
||||
SkRegion::Op op = SkRegion::kIntersect_Op);
|
||||
|
||||
/** Modify the current clip with the specified region. Note that unlike
|
||||
clipRect() and clipPath() which transform their arguments by the current
|
||||
matrix, clipRegion() assumes its argument is already in device
|
||||
coordinates, and so no transformation is performed.
|
||||
@param deviceRgn The region to apply to the current clip
|
||||
@param op The region op to apply to the current clip
|
||||
@return true if the canvas' new clip is non-empty
|
||||
*/
|
||||
virtual bool clipRegion(const SkRegion& deviceRgn,
|
||||
SkRegion::Op op = SkRegion::kIntersect_Op);
|
||||
|
||||
/** Helper for clipRegion(rgn, kReplace_Op). Sets the current clip to the
|
||||
specified region. This does not intersect or in any other way account
|
||||
for the existing clip region.
|
||||
@param deviceRgn The region to copy into the current clip.
|
||||
@return true if the new clip region is non-empty
|
||||
*/
|
||||
bool setClipRegion(const SkRegion& deviceRgn) {
|
||||
return this->clipRegion(deviceRgn, SkRegion::kReplace_Op);
|
||||
}
|
||||
|
||||
/** Enum describing how to treat edges when performing quick-reject tests
|
||||
of a geometry against the current clip. Treating them as antialiased
|
||||
(kAA_EdgeType) will take into account the extra pixels that may be drawn
|
||||
if the edge does not lie exactly on a device pixel boundary (after being
|
||||
transformed by the current matrix).
|
||||
*/
|
||||
enum EdgeType {
|
||||
/** Treat the edges as B&W (not antialiased) for the purposes of testing
|
||||
against the current clip
|
||||
*/
|
||||
kBW_EdgeType,
|
||||
/** Treat the edges as antialiased for the purposes of testing
|
||||
against the current clip
|
||||
*/
|
||||
kAA_EdgeType
|
||||
};
|
||||
|
||||
/** Return true if the specified rectangle, after being transformed by the
|
||||
current matrix, would lie completely outside of the current clip. Call
|
||||
this to check if an area you intend to draw into is clipped out (and
|
||||
therefore you can skip making the draw calls).
|
||||
@param rect the rect to compare with the current clip
|
||||
@param et specifies how to treat the edges (see EdgeType)
|
||||
@return true if the rect (transformed by the canvas' matrix) does not
|
||||
intersect with the canvas' clip
|
||||
*/
|
||||
bool quickReject(const SkRect& rect, EdgeType et) const;
|
||||
|
||||
/** Return true if the specified path, after being transformed by the
|
||||
current matrix, would lie completely outside of the current clip. Call
|
||||
this to check if an area you intend to draw into is clipped out (and
|
||||
therefore you can skip making the draw calls). Note, for speed it may
|
||||
return false even if the path itself might not intersect the clip
|
||||
(i.e. the bounds of the path intersects, but the path does not).
|
||||
@param path The path to compare with the current clip
|
||||
@param et specifies how to treat the edges (see EdgeType)
|
||||
@return true if the path (transformed by the canvas' matrix) does not
|
||||
intersect with the canvas' clip
|
||||
*/
|
||||
bool quickReject(const SkPath& path, EdgeType et) const;
|
||||
|
||||
/** Return true if the horizontal band specified by top and bottom is
|
||||
completely clipped out. This is a conservative calculation, meaning
|
||||
that it is possible that if the method returns false, the band may still
|
||||
in fact be clipped out, but the converse is not true. If this method
|
||||
returns true, then the band is guaranteed to be clipped out.
|
||||
@param top The top of the horizontal band to compare with the clip
|
||||
@param bottom The bottom of the horizontal and to compare with the clip
|
||||
@return true if the horizontal band is completely clipped out (i.e. does
|
||||
not intersect the current clip)
|
||||
*/
|
||||
bool quickRejectY(SkScalar top, SkScalar bottom, EdgeType et) const;
|
||||
|
||||
/** Return the bounds of the current clip (in local coordinates) in the
|
||||
bounds parameter, and return true if it is non-empty. This can be useful
|
||||
in a way similar to quickReject, in that it tells you that drawing
|
||||
outside of these bounds will be clipped out.
|
||||
*/
|
||||
bool getClipBounds(SkRect* bounds, EdgeType et = kAA_EdgeType) const;
|
||||
|
||||
/** Fill the entire canvas' bitmap (restricted to the current clip) with the
|
||||
specified ARGB color, using the specified PorterDuff mode.
|
||||
@param a the alpha component (0..255) of the color to fill the canvas
|
||||
@param r the red component (0..255) of the color to fill the canvas
|
||||
@param g the green component (0..255) of the color to fill the canvas
|
||||
@param b the blue component (0..255) of the color to fill the canvas
|
||||
@param mode the mode to apply the color in (defaults to SrcOver)
|
||||
*/
|
||||
void drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b,
|
||||
SkPorterDuff::Mode mode = SkPorterDuff::kSrcOver_Mode);
|
||||
|
||||
/** Fill the entire canvas' bitmap (restricted to the current clip) with the
|
||||
specified color and porter-duff xfermode.
|
||||
@param color the color to draw with
|
||||
@param mode the mode to apply the color in (defaults to SrcOver)
|
||||
*/
|
||||
void drawColor(SkColor color,
|
||||
SkPorterDuff::Mode mode = SkPorterDuff::kSrcOver_Mode);
|
||||
|
||||
/** Fill the entire canvas' bitmap (restricted to the current clip) with the
|
||||
specified paint.
|
||||
@param paint The paint used to fill the canvas
|
||||
*/
|
||||
virtual void drawPaint(const SkPaint& paint);
|
||||
|
||||
enum PointMode {
|
||||
/** drawPoints draws each point separately */
|
||||
kPoints_PointMode,
|
||||
/** drawPoints draws each pair of points as a line segment */
|
||||
kLines_PointMode,
|
||||
/** drawPoints draws the array of points as a polygon */
|
||||
kPolygon_PointMode
|
||||
};
|
||||
|
||||
/** Draw a series of points, interpreted based on the PointMode mode. For
|
||||
all modes, the count parameter is interpreted as the total number of
|
||||
points. For kLine mode, count/2 line segments are drawn.
|
||||
For kPoint mode, each point is drawn centered at its coordinate, and its
|
||||
size is specified by the paint's stroke-width. It draws as a square,
|
||||
unless the paint's cap-type is round, in which the points are drawn as
|
||||
circles.
|
||||
For kLine mode, each pair of points is drawn as a line segment,
|
||||
respecting the paint's settings for cap/join/width.
|
||||
For kPolygon mode, the entire array is drawn as a series of connected
|
||||
line segments.
|
||||
Note that, while similar, kLine and kPolygon modes draw slightly
|
||||
differently than the equivalent path built with a series of moveto,
|
||||
lineto calls, in that the path will draw all of its contours at once,
|
||||
with no interactions if contours intersect each other (think XOR
|
||||
xfermode). drawPoints always draws each element one at a time.
|
||||
@param mode PointMode specifying how to draw the array of points.
|
||||
@param count The number of points in the array
|
||||
@param pts Array of points to draw
|
||||
@param paint The paint used to draw the points
|
||||
*/
|
||||
virtual void drawPoints(PointMode mode, size_t count, const SkPoint pts[],
|
||||
const SkPaint& paint);
|
||||
|
||||
/** Helper method for drawing a single point. See drawPoints() for a more
|
||||
details.
|
||||
*/
|
||||
void drawPoint(SkScalar x, SkScalar y, const SkPaint& paint);
|
||||
|
||||
/** Draws a single pixel in the specified color.
|
||||
@param x The X coordinate of which pixel to draw
|
||||
@param y The Y coordiante of which pixel to draw
|
||||
@param color The color to draw
|
||||
*/
|
||||
void drawPoint(SkScalar x, SkScalar y, SkColor color);
|
||||
|
||||
/** Draw a line segment with the specified start and stop x,y coordinates,
|
||||
using the specified paint. NOTE: since a line is always "framed", the
|
||||
paint's Style is ignored.
|
||||
@param x0 The x-coordinate of the start point of the line
|
||||
@param y0 The y-coordinate of the start point of the line
|
||||
@param x1 The x-coordinate of the end point of the line
|
||||
@param y1 The y-coordinate of the end point of the line
|
||||
@param paint The paint used to draw the line
|
||||
*/
|
||||
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1,
|
||||
const SkPaint& paint);
|
||||
|
||||
/** Draw the specified rectangle using the specified paint. The rectangle
|
||||
will be filled or stroked based on the Style in the paint.
|
||||
@param rect The rect to be drawn
|
||||
@param paint The paint used to draw the rect
|
||||
*/
|
||||
virtual void drawRect(const SkRect& rect, const SkPaint& paint);
|
||||
|
||||
/** Draw the specified rectangle using the specified paint. The rectangle
|
||||
will be filled or framed based on the Style in the paint.
|
||||
@param rect The rect to be drawn
|
||||
@param paint The paint used to draw the rect
|
||||
*/
|
||||
void drawIRect(const SkIRect& rect, const SkPaint& paint)
|
||||
{
|
||||
SkRect r;
|
||||
r.set(rect); // promotes the ints to scalars
|
||||
this->drawRect(r, paint);
|
||||
}
|
||||
|
||||
/** Draw the specified rectangle using the specified paint. The rectangle
|
||||
will be filled or framed based on the Style in the paint.
|
||||
@param left The left side of the rectangle to be drawn
|
||||
@param top The top side of the rectangle to be drawn
|
||||
@param right The right side of the rectangle to be drawn
|
||||
@param bottom The bottom side of the rectangle to be drawn
|
||||
@param paint The paint used to draw the rect
|
||||
*/
|
||||
void drawRectCoords(SkScalar left, SkScalar top, SkScalar right,
|
||||
SkScalar bottom, const SkPaint& paint);
|
||||
|
||||
/** Draw the specified oval using the specified paint. The oval will be
|
||||
filled or framed based on the Style in the paint.
|
||||
@param oval The rectangle bounds of the oval to be drawn
|
||||
@param paint The paint used to draw the oval
|
||||
*/
|
||||
void drawOval(const SkRect& oval, const SkPaint&);
|
||||
|
||||
/** Draw the specified circle using the specified paint. If radius is <= 0,
|
||||
then nothing will be drawn. The circle will be filled
|
||||
or framed based on the Style in the paint.
|
||||
@param cx The x-coordinate of the center of the cirle to be drawn
|
||||
@param cy The y-coordinate of the center of the cirle to be drawn
|
||||
@param radius The radius of the cirle to be drawn
|
||||
@param paint The paint used to draw the circle
|
||||
*/
|
||||
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius,
|
||||
const SkPaint& paint);
|
||||
|
||||
/** Draw the specified arc, which will be scaled to fit inside the
|
||||
specified oval. If the sweep angle is >= 360, then the oval is drawn
|
||||
completely. Note that this differs slightly from SkPath::arcTo, which
|
||||
treats the sweep angle mod 360.
|
||||
@param oval The bounds of oval used to define the shape of the arc
|
||||
@param startAngle Starting angle (in degrees) where the arc begins
|
||||
@param sweepAngle Sweep angle (in degrees) measured clockwise
|
||||
@param useCenter true means include the center of the oval. For filling
|
||||
this will draw a wedge. False means just use the arc.
|
||||
@param paint The paint used to draw the arc
|
||||
*/
|
||||
void drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
|
||||
bool useCenter, const SkPaint& paint);
|
||||
|
||||
/** Draw the specified round-rect using the specified paint. The round-rect
|
||||
will be filled or framed based on the Style in the paint.
|
||||
@param rect The rectangular bounds of the roundRect to be drawn
|
||||
@param rx The x-radius of the oval used to round the corners
|
||||
@param ry The y-radius of the oval used to round the corners
|
||||
@param paint The paint used to draw the roundRect
|
||||
*/
|
||||
void drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry,
|
||||
const SkPaint& paint);
|
||||
|
||||
/** Draw the specified path using the specified paint. The path will be
|
||||
filled or framed based on the Style in the paint.
|
||||
@param path The path to be drawn
|
||||
@param paint The paint used to draw the path
|
||||
*/
|
||||
virtual void drawPath(const SkPath& path, const SkPaint& paint);
|
||||
|
||||
/** Draw the specified bitmap, with its top/left corner at (x,y), using the
|
||||
specified paint, transformed by the current matrix. Note: if the paint
|
||||
contains a maskfilter that generates a mask which extends beyond the
|
||||
bitmap's original width/height, then the bitmap will be drawn as if it
|
||||
were in a Shader with CLAMP mode. Thus the color outside of the original
|
||||
width/height will be the edge color replicated.
|
||||
@param bitmap The bitmap to be drawn
|
||||
@param left The position of the left side of the bitmap being drawn
|
||||
@param top The position of the top side of the bitmap being drawn
|
||||
@param paint The paint used to draw the bitmap, or NULL
|
||||
*/
|
||||
virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
|
||||
const SkPaint* paint = NULL);
|
||||
|
||||
/** Draw the specified bitmap, with the specified matrix applied (before the
|
||||
canvas' matrix is applied).
|
||||
@param bitmap The bitmap to be drawn
|
||||
@param src Optional: specify the subset of the bitmap to be drawn
|
||||
@param dst The destination rectangle where the scaled/translated
|
||||
image will be drawn
|
||||
@param paint The paint used to draw the bitmap, or NULL
|
||||
*/
|
||||
virtual void drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
|
||||
const SkRect& dst, const SkPaint* paint = NULL);
|
||||
|
||||
virtual void drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
|
||||
const SkPaint* paint = NULL);
|
||||
|
||||
/** Draw the specified bitmap, with its top/left corner at (x,y),
|
||||
NOT transformed by the current matrix. Note: if the paint
|
||||
contains a maskfilter that generates a mask which extends beyond the
|
||||
bitmap's original width/height, then the bitmap will be drawn as if it
|
||||
were in a Shader with CLAMP mode. Thus the color outside of the original
|
||||
width/height will be the edge color replicated.
|
||||
@param bitmap The bitmap to be drawn
|
||||
@param left The position of the left side of the bitmap being drawn
|
||||
@param top The position of the top side of the bitmap being drawn
|
||||
@param paint The paint used to draw the bitmap, or NULL
|
||||
*/
|
||||
virtual void drawSprite(const SkBitmap& bitmap, int left, int top,
|
||||
const SkPaint* paint = NULL);
|
||||
|
||||
/** Draw the text, with origin at (x,y), using the specified paint.
|
||||
The origin is interpreted based on the Align setting in the paint.
|
||||
@param text The text to be drawn
|
||||
@param byteLength The number of bytes to read from the text parameter
|
||||
@param x The x-coordinate of the origin of the text being drawn
|
||||
@param y The y-coordinate of the origin of the text being drawn
|
||||
@param paint The paint used for the text (e.g. color, size, style)
|
||||
*/
|
||||
virtual void drawText(const void* text, size_t byteLength, SkScalar x,
|
||||
SkScalar y, const SkPaint& paint);
|
||||
|
||||
/** Draw the text, with each character/glyph origin specified by the pos[]
|
||||
array. The origin is interpreted by the Align setting in the paint.
|
||||
@param text The text to be drawn
|
||||
@param byteLength The number of bytes to read from the text parameter
|
||||
@param pos Array of positions, used to position each character
|
||||
@param paint The paint used for the text (e.g. color, size, style)
|
||||
*/
|
||||
virtual void drawPosText(const void* text, size_t byteLength,
|
||||
const SkPoint pos[], const SkPaint& paint);
|
||||
|
||||
/** Draw the text, with each character/glyph origin specified by the x
|
||||
coordinate taken from the xpos[] array, and the y from the constY param.
|
||||
The origin is interpreted by the Align setting in the paint.
|
||||
@param text The text to be drawn
|
||||
@param byteLength The number of bytes to read from the text parameter
|
||||
@param xpos Array of x-positions, used to position each character
|
||||
@param constY The shared Y coordinate for all of the positions
|
||||
@param paint The paint used for the text (e.g. color, size, style)
|
||||
*/
|
||||
virtual void drawPosTextH(const void* text, size_t byteLength,
|
||||
const SkScalar xpos[], SkScalar constY,
|
||||
const SkPaint& paint);
|
||||
|
||||
/** Draw the text, with origin at (x,y), using the specified paint, along
|
||||
the specified path. The paint's Align setting determins where along the
|
||||
path to start the text.
|
||||
@param text The text to be drawn
|
||||
@param byteLength The number of bytes to read from the text parameter
|
||||
@param path The path the text should follow for its baseline
|
||||
@param hOffset The distance along the path to add to the text's
|
||||
starting position
|
||||
@param vOffset The distance above(-) or below(+) the path to
|
||||
position the text
|
||||
@param paint The paint used for the text
|
||||
*/
|
||||
void drawTextOnPathHV(const void* text, size_t byteLength,
|
||||
const SkPath& path, SkScalar hOffset,
|
||||
SkScalar vOffset, const SkPaint& paint);
|
||||
|
||||
/** Draw the text, with origin at (x,y), using the specified paint, along
|
||||
the specified path. The paint's Align setting determins where along the
|
||||
path to start the text.
|
||||
@param text The text to be drawn
|
||||
@param byteLength The number of bytes to read from the text parameter
|
||||
@param path The path the text should follow for its baseline
|
||||
@param matrix (may be null) Applied to the text before it is
|
||||
mapped onto the path
|
||||
@param paint The paint used for the text
|
||||
*/
|
||||
virtual void drawTextOnPath(const void* text, size_t byteLength,
|
||||
const SkPath& path, const SkMatrix* matrix,
|
||||
const SkPaint& paint);
|
||||
|
||||
/** Draw the picture into this canvas. This method effective brackets the
|
||||
playback of the picture's draw calls with save/restore, so the state
|
||||
of this canvas will be unchanged after this call. This contrasts with
|
||||
the more immediate method SkPicture::draw(), which does not bracket
|
||||
the canvas with save/restore, thus the canvas may be left in a changed
|
||||
state after the call.
|
||||
@param picture The recorded drawing commands to playback into this
|
||||
canvas.
|
||||
*/
|
||||
virtual void drawPicture(SkPicture& picture);
|
||||
|
||||
enum VertexMode {
|
||||
kTriangles_VertexMode,
|
||||
kTriangleStrip_VertexMode,
|
||||
kTriangleFan_VertexMode
|
||||
};
|
||||
|
||||
/** Draw the array of vertices, interpreted as triangles (based on mode).
|
||||
@param vmode How to interpret the array of vertices
|
||||
@param vertexCount The number of points in the vertices array (and
|
||||
corresponding texs and colors arrays if non-null)
|
||||
@param vertices Array of vertices for the mesh
|
||||
@param texs May be null. If not null, specifies the coordinate
|
||||
in texture space for each vertex.
|
||||
@param colors May be null. If not null, specifies a color for each
|
||||
vertex, to be interpolated across the triangle.
|
||||
@param xmode Used if both texs and colors are present. In this
|
||||
case the colors are combined with the texture using mode,
|
||||
before being drawn using the paint. If mode is null, then
|
||||
the porter-duff MULTIPLY mode is used.
|
||||
@param indices If not null, array of indices to reference into the
|
||||
vertex (texs, colors) array.
|
||||
@param indexCount number of entries in the indices array (if not null)
|
||||
@param paint Specifies the shader/texture if present.
|
||||
*/
|
||||
virtual void drawVertices(VertexMode vmode, int vertexCount,
|
||||
const SkPoint vertices[], const SkPoint texs[],
|
||||
const SkColor colors[], SkXfermode* xmode,
|
||||
const uint16_t indices[], int indexCount,
|
||||
const SkPaint& paint);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Get the current bounder object.
|
||||
The bounder's reference count is unchaged.
|
||||
@return the canva's bounder (or NULL).
|
||||
*/
|
||||
SkBounder* getBounder() const { return fBounder; }
|
||||
|
||||
/** Set a new bounder (or NULL).
|
||||
Pass NULL to clear any previous bounder.
|
||||
As a convenience, the parameter passed is also returned.
|
||||
If a previous bounder exists, its reference count is decremented.
|
||||
If bounder is not NULL, its reference count is incremented.
|
||||
@param bounder the new bounder (or NULL) to be installed in the canvas
|
||||
@return the set bounder object
|
||||
*/
|
||||
virtual SkBounder* setBounder(SkBounder* bounder);
|
||||
|
||||
/** Get the current filter object. The filter's reference count is not
|
||||
affected. The filter is part of the state this is affected by
|
||||
save/restore.
|
||||
@return the canvas' filter (or NULL).
|
||||
*/
|
||||
SkDrawFilter* getDrawFilter() const;
|
||||
|
||||
/** Set the new filter (or NULL). Pass NULL to clear any existing filter.
|
||||
As a convenience, the parameter is returned. If an existing filter
|
||||
exists, its refcnt is decrement. If the new filter is not null, its
|
||||
refcnt is incremented. The filter is part of the state this is affected
|
||||
by save/restore.
|
||||
@param filter the new filter (or NULL)
|
||||
@return the new filter
|
||||
*/
|
||||
virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Return the current matrix on the canvas.
|
||||
This does not account for the translate in any of the devices.
|
||||
@return The current matrix on the canvas.
|
||||
*/
|
||||
const SkMatrix& getTotalMatrix() const;
|
||||
|
||||
/** Return the current device clip (concatenation of all clip calls).
|
||||
This does not account for the translate in any of the devices.
|
||||
@return the current device clip (concatenation of all clip calls).
|
||||
*/
|
||||
const SkRegion& getTotalClip() const;
|
||||
|
||||
/** May be overridden by subclasses. This returns a compatible device
|
||||
for this canvas, with the specified config/width/height. If isOpaque
|
||||
is true, then the underlying bitmap is optimized to assume that every
|
||||
pixel will be drawn to, and thus it does not need to clear the alpha
|
||||
channel ahead of time (assuming the specified config supports per-pixel
|
||||
alpha.) If isOpaque is false, then the bitmap should clear its alpha
|
||||
channel.
|
||||
*/
|
||||
virtual SkDevice* createDevice(SkBitmap::Config, int width, int height,
|
||||
bool isOpaque, bool isForLayer);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** After calling saveLayer(), there can be any number of devices that make
|
||||
up the top-most drawing area. LayerIter can be used to iterate through
|
||||
those devices. Note that the iterator is only valid until the next API
|
||||
call made on the canvas. Ownership of all pointers in the iterator stays
|
||||
with the canvas, so none of them should be modified or deleted.
|
||||
*/
|
||||
class LayerIter /*: SkNoncopyable*/ {
|
||||
public:
|
||||
/** Initialize iterator with canvas, and set values for 1st device */
|
||||
LayerIter(SkCanvas*, bool skipEmptyClips);
|
||||
~LayerIter();
|
||||
|
||||
/** Return true if the iterator is done */
|
||||
bool done() const { return fDone; }
|
||||
/** Cycle to the next device */
|
||||
void next();
|
||||
|
||||
// These reflect the current device in the iterator
|
||||
|
||||
SkDevice* device() const;
|
||||
const SkMatrix& matrix() const;
|
||||
const SkRegion& clip() const;
|
||||
const SkPaint& paint() const;
|
||||
int x() const;
|
||||
int y() const;
|
||||
|
||||
private:
|
||||
// used to embed the SkDrawIter object directly in our instance, w/o
|
||||
// having to expose that class def to the public. There is an assert
|
||||
// in our constructor to ensure that fStorage is large enough
|
||||
// (though needs to be a compile-time-assert!). We use intptr_t to work
|
||||
// safely with 32 and 64 bit machines (to ensure the storage is enough)
|
||||
intptr_t fStorage[12];
|
||||
class SkDrawIter* fImpl; // this points at fStorage
|
||||
SkPaint fDefaultPaint;
|
||||
bool fDone;
|
||||
};
|
||||
|
||||
protected:
|
||||
// all of the drawBitmap variants call this guy
|
||||
virtual void commonDrawBitmap(const SkBitmap&, const SkMatrix& m,
|
||||
const SkPaint& paint);
|
||||
|
||||
private:
|
||||
class MCRec;
|
||||
|
||||
SkDeque fMCStack;
|
||||
// points to top of stack
|
||||
MCRec* fMCRec;
|
||||
// the first N recs that can fit here mean we won't call malloc
|
||||
uint32_t fMCRecStorage[32];
|
||||
|
||||
SkBounder* fBounder;
|
||||
|
||||
void prepareForDeviceDraw(SkDevice*);
|
||||
|
||||
bool fDeviceCMDirty; // cleared by updateDeviceCMCache()
|
||||
void updateDeviceCMCache();
|
||||
|
||||
friend class SkDrawIter; // needs setupDrawForLayerDevice()
|
||||
|
||||
SkDevice* init(SkDevice*);
|
||||
void internalDrawBitmap(const SkBitmap&, const SkMatrix& m,
|
||||
const SkPaint* paint);
|
||||
void drawDevice(SkDevice*, int x, int y, const SkPaint*);
|
||||
// shared by save() and saveLayer()
|
||||
int internalSave(SaveFlags flags);
|
||||
void internalRestore();
|
||||
|
||||
/* These maintain a cache of the clip bounds in local coordinates,
|
||||
(converted to 2s-compliment if floats are slow).
|
||||
*/
|
||||
mutable SkRectCompareType fLocalBoundsCompareType;
|
||||
mutable bool fLocalBoundsCompareTypeDirty;
|
||||
|
||||
const SkRectCompareType& getLocalClipBoundsCompareType() const {
|
||||
if (fLocalBoundsCompareTypeDirty) {
|
||||
this->computeLocalClipBoundsCompareType();
|
||||
fLocalBoundsCompareTypeDirty = false;
|
||||
}
|
||||
return fLocalBoundsCompareType;
|
||||
}
|
||||
void computeLocalClipBoundsCompareType() const;
|
||||
};
|
||||
|
||||
/** Stack helper class to automatically call restoreToCount() on the canvas
|
||||
when this object goes out of scope. Use this to guarantee that the canvas
|
||||
is restored to a known state.
|
||||
*/
|
||||
class SkAutoCanvasRestore : SkNoncopyable {
|
||||
public:
|
||||
SkAutoCanvasRestore(SkCanvas* canvas, bool doSave) : fCanvas(canvas) {
|
||||
SkASSERT(canvas);
|
||||
fSaveCount = canvas->getSaveCount();
|
||||
if (doSave) {
|
||||
canvas->save();
|
||||
}
|
||||
}
|
||||
~SkAutoCanvasRestore() {
|
||||
fCanvas->restoreToCount(fSaveCount);
|
||||
}
|
||||
|
||||
private:
|
||||
SkCanvas* fCanvas;
|
||||
int fSaveCount;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,155 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkColor_DEFINED
|
||||
#define SkColor_DEFINED
|
||||
|
||||
#include "SkScalar.h"
|
||||
|
||||
/** \file SkColor.h
|
||||
|
||||
Types and macros for colors
|
||||
*/
|
||||
|
||||
/** 8-bit type for an alpha value. 0xFF is 100% opaque, 0x00 is 100% transparent.
|
||||
*/
|
||||
typedef uint8_t SkAlpha;
|
||||
/** 32 bit ARGB color value, not premultiplied. The color components are always in
|
||||
a known order. This is different from SkPMColor, which has its bytes in a configuration
|
||||
dependent order, to match the format of kARGB32 bitmaps. SkColor is the type used to
|
||||
specify colors in SkPaint and in gradients.
|
||||
*/
|
||||
typedef uint32_t SkColor;
|
||||
|
||||
/** Return a SkColor value from 8 bit component values
|
||||
*/
|
||||
static inline SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
|
||||
{
|
||||
SkASSERT(a <= 255 && r <= 255 && g <= 255 && b <= 255);
|
||||
|
||||
return (a << 24) | (r << 16) | (g << 8) | (b << 0);
|
||||
}
|
||||
|
||||
/** Return a SkColor value from 8 bit component values, with an implied value
|
||||
of 0xFF for alpha (fully opaque)
|
||||
*/
|
||||
#define SkColorSetRGB(r, g, b) SkColorSetARGB(0xFF, r, g, b)
|
||||
|
||||
/** return the alpha byte from a SkColor value */
|
||||
#define SkColorGetA(color) (((color) >> 24) & 0xFF)
|
||||
/** return the red byte from a SkColor value */
|
||||
#define SkColorGetR(color) (((color) >> 16) & 0xFF)
|
||||
/** return the green byte from a SkColor value */
|
||||
#define SkColorGetG(color) (((color) >> 8) & 0xFF)
|
||||
/** return the blue byte from a SkColor value */
|
||||
#define SkColorGetB(color) (((color) >> 0) & 0xFF)
|
||||
|
||||
static inline SkColor SkColorSetA(SkColor c, U8CPU a) {
|
||||
return (c & 0x00FFFFFF) | (a << 24);
|
||||
}
|
||||
|
||||
// common colors
|
||||
|
||||
#define SK_ColorBLACK 0xFF000000 //!< black SkColor value
|
||||
#define SK_ColorDKGRAY 0xFF444444 //!< dark gray SkColor value
|
||||
#define SK_ColorGRAY 0xFF888888 //!< gray SkColor value
|
||||
#define SK_ColorLTGRAY 0xFFCCCCCC //!< light gray SkColor value
|
||||
#define SK_ColorWHITE 0xFFFFFFFF //!< white SkColor value
|
||||
|
||||
#define SK_ColorRED 0xFFFF0000 //!< red SkColor value
|
||||
#define SK_ColorGREEN 0xFF00FF00 //!< green SkColor value
|
||||
#define SK_ColorBLUE 0xFF0000FF //!< blue SkColor value
|
||||
#define SK_ColorYELLOW 0xFFFFFF00 //!< yellow SkColor value
|
||||
#define SK_ColorCYAN 0xFF00FFFF //!< cyan SkColor value
|
||||
#define SK_ColorMAGENTA 0xFFFF00FF //!< magenta SkColor value
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Convert RGB components to HSV.
|
||||
hsv[0] is Hue [0 .. 360)
|
||||
hsv[1] is Saturation [0...1]
|
||||
hsv[2] is Value [0...1]
|
||||
@param red red component value [0..255]
|
||||
@param green green component value [0..255]
|
||||
@param blue blue component value [0..255]
|
||||
@param hsv 3 element array which holds the resulting HSV components.
|
||||
*/
|
||||
void SkRGBToHSV(U8CPU red, U8CPU green, U8CPU blue, SkScalar hsv[3]);
|
||||
|
||||
/** Convert the argb color to its HSV components.
|
||||
hsv[0] is Hue [0 .. 360)
|
||||
hsv[1] is Saturation [0...1]
|
||||
hsv[2] is Value [0...1]
|
||||
@param color the argb color to convert. Note: the alpha component is ignored.
|
||||
@param hsv 3 element array which holds the resulting HSV components.
|
||||
*/
|
||||
static inline void SkColorToHSV(SkColor color, SkScalar hsv[3])
|
||||
{
|
||||
SkRGBToHSV(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color), hsv);
|
||||
}
|
||||
|
||||
/** Convert HSV components to an ARGB color. The alpha component is passed through unchanged.
|
||||
hsv[0] is Hue [0 .. 360)
|
||||
hsv[1] is Saturation [0...1]
|
||||
hsv[2] is Value [0...1]
|
||||
If hsv values are out of range, they are pinned.
|
||||
@param alpha the alpha component of the returned argb color.
|
||||
@param hsv 3 element array which holds the input HSV components.
|
||||
@return the resulting argb color
|
||||
*/
|
||||
SkColor SkHSVToColor(U8CPU alpha, const SkScalar hsv[3]);
|
||||
|
||||
/** Convert HSV components to an ARGB color. The alpha component set to 0xFF.
|
||||
hsv[0] is Hue [0 .. 360)
|
||||
hsv[1] is Saturation [0...1]
|
||||
hsv[2] is Value [0...1]
|
||||
If hsv values are out of range, they are pinned.
|
||||
@param hsv 3 element array which holds the input HSV components.
|
||||
@return the resulting argb color
|
||||
*/
|
||||
static inline SkColor SkHSVToColor(const SkScalar hsv[3])
|
||||
{
|
||||
return SkHSVToColor(0xFF, hsv);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** 32 bit ARGB color value, premultiplied. The byte order for this value is
|
||||
configuration dependent, matching the format of kARGB32 bitmaps. This is different
|
||||
from SkColor, which is nonpremultiplied, and is always in the same byte order.
|
||||
*/
|
||||
typedef uint32_t SkPMColor;
|
||||
|
||||
/** Return a SkPMColor value from unpremultiplied 8 bit component values
|
||||
*/
|
||||
SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
|
||||
/** Return a SkPMColor value from a SkColor value. This is done by multiplying the color
|
||||
components by the color's alpha, and by arranging the bytes in a configuration
|
||||
dependent order, to match the format of kARGB32 bitmaps.
|
||||
*/
|
||||
SkPMColor SkPreMultiplyColor(SkColor c);
|
||||
|
||||
/** Define a function pointer type for combining two premultiplied colors
|
||||
*/
|
||||
typedef SkPMColor (*SkXfermodeProc)(SkPMColor src, SkPMColor dst);
|
||||
|
||||
/** Define a function pointer type for combining a premultiplied src color
|
||||
and a 16bit device color.
|
||||
*/
|
||||
typedef uint16_t (*SkXfermodeProc16)(SkPMColor src, uint16_t dst);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkColorFilter_DEFINED
|
||||
#define SkColorFilter_DEFINED
|
||||
|
||||
#include "SkColor.h"
|
||||
#include "SkFlattenable.h"
|
||||
#include "SkPorterDuff.h"
|
||||
|
||||
class SkColorFilter : public SkFlattenable {
|
||||
public:
|
||||
/** Called with a scanline of colors, as if there was a shader installed.
|
||||
The implementation writes out its filtered version into result[].
|
||||
Note: shader and result may be the same buffer.
|
||||
@param src array of colors, possibly generated by a shader
|
||||
@param count the number of entries in the src[] and result[] arrays
|
||||
@param result written by the filter
|
||||
*/
|
||||
virtual void filterSpan(const SkPMColor src[], int count,
|
||||
SkPMColor result[]) = 0;
|
||||
/** Called with a scanline of colors, as if there was a shader installed.
|
||||
The implementation writes out its filtered version into result[].
|
||||
Note: shader and result may be the same buffer.
|
||||
@param src array of colors, possibly generated by a shader
|
||||
@param count the number of entries in the src[] and result[] arrays
|
||||
@param result written by the filter
|
||||
*/
|
||||
virtual void filterSpan16(const uint16_t shader[], int count,
|
||||
uint16_t result[]);
|
||||
|
||||
enum Flags {
|
||||
/** If set the filter methods will not change the alpha channel of the
|
||||
colors.
|
||||
*/
|
||||
kAlphaUnchanged_Flag = 0x01,
|
||||
/** If set, this subclass implements filterSpan16(). If this flag is
|
||||
set, then kAlphaUnchanged_Flag must also be set.
|
||||
*/
|
||||
kHasFilter16_Flag = 0x02
|
||||
};
|
||||
|
||||
/** Returns the flags for this filter. Override in subclasses to return
|
||||
custom flags.
|
||||
*/
|
||||
virtual uint32_t getFlags() { return 0; }
|
||||
|
||||
/** Create a colorfilter that uses the specified color and porter-duff mode.
|
||||
If porterDuffMode is DST, this function will return NULL (since that
|
||||
mode will have no effect on the result).
|
||||
@param srcColor The source color used with the specified mode
|
||||
@param mode The porter-duff mode that is applied to each color in
|
||||
the colorfilter's filterSpan[16,32] methods
|
||||
@return colorfilter object that applies the src color and porter-duff
|
||||
mode, or NULL if the mode will have no effect.
|
||||
*/
|
||||
static SkColorFilter* CreatePorterDuffFilter(SkColor srcColor,
|
||||
SkPorterDuff::Mode mode);
|
||||
|
||||
/** Create a colorfilter that calls through to the specified procs to
|
||||
filter the colors. The SkXfermodeProc parameter must be non-null, but
|
||||
the SkXfermodeProc16 is optional, and may be null.
|
||||
*/
|
||||
static SkColorFilter* CreatXfermodeProcFilter(SkColor srcColor,
|
||||
SkXfermodeProc proc,
|
||||
SkXfermodeProc16 proc16 = NULL);
|
||||
|
||||
/** Create a colorfilter that multiplies the RGB channels by one color, and
|
||||
then adds a second color, pinning the result for each component to
|
||||
[0..255]. The alpha components of the mul and add arguments
|
||||
are ignored.
|
||||
*/
|
||||
static SkColorFilter* CreateLightingFilter(SkColor mul, SkColor add);
|
||||
|
||||
protected:
|
||||
SkColorFilter() {}
|
||||
SkColorFilter(SkFlattenableReadBuffer& rb) : INHERITED(rb) {}
|
||||
|
||||
private:
|
||||
typedef SkFlattenable INHERITED;
|
||||
};
|
||||
|
||||
#include "SkShader.h"
|
||||
|
||||
class SkFilterShader : public SkShader {
|
||||
public:
|
||||
SkFilterShader(SkShader* shader, SkColorFilter* filter);
|
||||
virtual ~SkFilterShader();
|
||||
|
||||
// override
|
||||
virtual uint32_t getFlags();
|
||||
virtual bool setContext(const SkBitmap& device, const SkPaint& paint,
|
||||
const SkMatrix& matrix);
|
||||
virtual void shadeSpan(int x, int y, SkPMColor result[], int count);
|
||||
virtual void shadeSpan16(int x, int y, uint16_t result[], int count);
|
||||
virtual void beginSession();
|
||||
virtual void endSession();
|
||||
|
||||
protected:
|
||||
SkFilterShader(SkFlattenableReadBuffer& );
|
||||
virtual void flatten(SkFlattenableWriteBuffer& );
|
||||
virtual Factory getFactory() { return CreateProc; }
|
||||
private:
|
||||
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
|
||||
return SkNEW_ARGS(SkFilterShader, (buffer)); }
|
||||
SkShader* fShader;
|
||||
SkColorFilter* fFilter;
|
||||
|
||||
typedef SkShader INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkColorMatrix_DEFINED
|
||||
#define SkColorMatrix_DEFINED
|
||||
|
||||
#include "SkScalar.h"
|
||||
|
||||
class SkColorMatrix {
|
||||
public:
|
||||
SkScalar fMat[20];
|
||||
|
||||
void setIdentity();
|
||||
void setScale(SkScalar rScale, SkScalar gScale, SkScalar bScale,
|
||||
SkScalar aScale = SK_Scalar1);
|
||||
void preScale(SkScalar rScale, SkScalar gScale, SkScalar bScale,
|
||||
SkScalar aScale = SK_Scalar1);
|
||||
void postScale(SkScalar rScale, SkScalar gScale, SkScalar bScale,
|
||||
SkScalar aScale = SK_Scalar1);
|
||||
|
||||
enum Axis {
|
||||
kR_Axis = 0,
|
||||
kG_Axis = 1,
|
||||
kB_Axis = 2
|
||||
};
|
||||
void setRotate(Axis, SkScalar degrees);
|
||||
void setSinCos(Axis, SkScalar sine, SkScalar cosine);
|
||||
void preRotate(Axis, SkScalar degrees);
|
||||
void postRotate(Axis, SkScalar degrees);
|
||||
|
||||
void setConcat(const SkColorMatrix& a, const SkColorMatrix& b);
|
||||
void preConcat(const SkColorMatrix& mat) { this->setConcat(*this, mat); }
|
||||
void postConcat(const SkColorMatrix& mat) { this->setConcat(mat, *this); }
|
||||
|
||||
void setSaturation(SkScalar sat);
|
||||
void setRGB2YUV();
|
||||
void setYUV2RGB();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkColorMatrixFilter_DEFINED
|
||||
#define SkColorMatrixFilter_DEFINED
|
||||
|
||||
#include "SkColorFilter.h"
|
||||
#include "SkColorMatrix.h"
|
||||
|
||||
class SkColorMatrixFilter : public SkColorFilter {
|
||||
public:
|
||||
SkColorMatrixFilter();
|
||||
explicit SkColorMatrixFilter(const SkColorMatrix&);
|
||||
SkColorMatrixFilter(const SkScalar array[20]);
|
||||
|
||||
void setMatrix(const SkColorMatrix&);
|
||||
void setArray(const SkScalar array[20]);
|
||||
|
||||
// overrides from SkColorFilter
|
||||
virtual void filterSpan(const SkPMColor src[], int count, SkPMColor[]);
|
||||
virtual void filterSpan16(const uint16_t src[], int count, uint16_t[]);
|
||||
virtual uint32_t getFlags();
|
||||
|
||||
// overrides for SkFlattenable
|
||||
virtual void flatten(SkFlattenableWriteBuffer& buffer);
|
||||
|
||||
struct State {
|
||||
int32_t fArray[20];
|
||||
int fShift;
|
||||
int32_t fResult[4];
|
||||
};
|
||||
|
||||
protected:
|
||||
// overrides for SkFlattenable
|
||||
virtual Factory getFactory();
|
||||
|
||||
SkColorMatrixFilter(SkFlattenableReadBuffer& buffer);
|
||||
|
||||
private:
|
||||
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer);
|
||||
|
||||
typedef void (*Proc)(State*, unsigned r, unsigned g, unsigned b,
|
||||
unsigned a);
|
||||
|
||||
Proc fProc;
|
||||
State fState;
|
||||
uint32_t fFlags;
|
||||
|
||||
void setup(const SkScalar array[20]);
|
||||
|
||||
typedef SkColorFilter INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,657 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkColorPriv_DEFINED
|
||||
#define SkColorPriv_DEFINED
|
||||
|
||||
// turn this own for extra debug checking when blending onto 565
|
||||
#ifdef SK_DEBUG
|
||||
#define CHECK_FOR_565_OVERFLOW
|
||||
#endif
|
||||
|
||||
#include "SkColor.h"
|
||||
#include "SkMath.h"
|
||||
|
||||
/** Turn 0..255 into 0..256 by adding 1 at the half-way point. Used to turn a
|
||||
byte into a scale value, so that we can say scale * value >> 8 instead of
|
||||
alpha * value / 255.
|
||||
|
||||
In debugging, asserts that alpha is 0..255
|
||||
*/
|
||||
inline unsigned SkAlpha255To256(U8CPU alpha) {
|
||||
SkASSERT(SkToU8(alpha) == alpha);
|
||||
return alpha + (alpha >> 7);
|
||||
}
|
||||
|
||||
/** Multiplify value by 0..256, and shift the result down 8
|
||||
(i.e. return (value * alpha256) >> 8)
|
||||
*/
|
||||
#define SkAlphaMul(value, alpha256) (SkMulS16(value, alpha256) >> 8)
|
||||
|
||||
// The caller may want negative values, so keep all params signed (int)
|
||||
// so we don't accidentally slip into unsigned math and lose the sign
|
||||
// extension when we shift (in SkAlphaMul)
|
||||
inline int SkAlphaBlend(int src, int dst, int scale256) {
|
||||
SkASSERT((unsigned)scale256 <= 256);
|
||||
return dst + SkAlphaMul(src - dst, scale256);
|
||||
}
|
||||
|
||||
#define SK_R16_BITS 5
|
||||
#define SK_G16_BITS 6
|
||||
#define SK_B16_BITS 5
|
||||
|
||||
#define SK_R16_SHIFT (SK_B16_BITS + SK_G16_BITS)
|
||||
#define SK_G16_SHIFT (SK_B16_BITS)
|
||||
#define SK_B16_SHIFT 0
|
||||
|
||||
#define SK_R16_MASK ((1 << SK_R16_BITS) - 1)
|
||||
#define SK_G16_MASK ((1 << SK_G16_BITS) - 1)
|
||||
#define SK_B16_MASK ((1 << SK_B16_BITS) - 1)
|
||||
|
||||
#define SkGetPackedR16(color) (((unsigned)(color) >> SK_R16_SHIFT) & SK_R16_MASK)
|
||||
#define SkGetPackedG16(color) (((unsigned)(color) >> SK_G16_SHIFT) & SK_G16_MASK)
|
||||
#define SkGetPackedB16(color) (((unsigned)(color) >> SK_B16_SHIFT) & SK_B16_MASK)
|
||||
|
||||
#define SkR16Assert(r) SkASSERT((unsigned)(r) <= SK_R16_MASK)
|
||||
#define SkG16Assert(g) SkASSERT((unsigned)(g) <= SK_G16_MASK)
|
||||
#define SkB16Assert(b) SkASSERT((unsigned)(b) <= SK_B16_MASK)
|
||||
|
||||
inline uint16_t SkPackRGB16(unsigned r, unsigned g, unsigned b) {
|
||||
SkASSERT(r <= SK_R16_MASK);
|
||||
SkASSERT(g <= SK_G16_MASK);
|
||||
SkASSERT(b <= SK_B16_MASK);
|
||||
|
||||
return SkToU16((r << SK_R16_SHIFT) | (g << SK_G16_SHIFT) | (b << SK_B16_SHIFT));
|
||||
}
|
||||
|
||||
#define SK_R16_MASK_IN_PLACE (SK_R16_MASK << SK_R16_SHIFT)
|
||||
#define SK_G16_MASK_IN_PLACE (SK_G16_MASK << SK_G16_SHIFT)
|
||||
#define SK_B16_MASK_IN_PLACE (SK_B16_MASK << SK_B16_SHIFT)
|
||||
|
||||
/** Expand the 16bit color into a 32bit value that can be scaled all at once
|
||||
by a value up to 32. Used in conjunction with SkCompact_rgb_16.
|
||||
*/
|
||||
inline uint32_t SkExpand_rgb_16(U16CPU c) {
|
||||
SkASSERT(c == (uint16_t)c);
|
||||
|
||||
return ((c & SK_G16_MASK_IN_PLACE) << 16) | (c & ~SK_G16_MASK_IN_PLACE);
|
||||
}
|
||||
|
||||
/** Compress an expanded value (from SkExpand_rgb_16) back down to a 16bit
|
||||
color value. The computation yields only 16bits of valid data, but we claim
|
||||
to return 32bits, so that the compiler won't generate extra instructions to
|
||||
"clean" the top 16bits. However, the top 16 can contain garbage, so it is
|
||||
up to the caller to safely ignore them.
|
||||
*/
|
||||
inline U16CPU SkCompact_rgb_16(uint32_t c) {
|
||||
return ((c >> 16) & SK_G16_MASK_IN_PLACE) | (c & ~SK_G16_MASK_IN_PLACE);
|
||||
}
|
||||
|
||||
/** Scale the 16bit color value by the 0..256 scale parameter.
|
||||
The computation yields only 16bits of valid data, but we claim
|
||||
to return 32bits, so that the compiler won't generate extra instructions to
|
||||
"clean" the top 16bits.
|
||||
*/
|
||||
inline U16CPU SkAlphaMulRGB16(U16CPU c, unsigned scale) {
|
||||
return SkCompact_rgb_16(SkExpand_rgb_16(c) * (scale >> 3) >> 5);
|
||||
}
|
||||
|
||||
// this helper explicitly returns a clean 16bit value (but slower)
|
||||
#define SkAlphaMulRGB16_ToU16(c, s) (uint16_t)SkAlphaMulRGB16(c, s)
|
||||
|
||||
/** Blend src and dst 16bit colors by the 0..256 scale parameter.
|
||||
The computation yields only 16bits of valid data, but we claim
|
||||
to return 32bits, so that the compiler won't generate extra instructions to
|
||||
"clean" the top 16bits.
|
||||
*/
|
||||
inline U16CPU SkBlendRGB16(U16CPU src, U16CPU dst, int srcScale) {
|
||||
SkASSERT((unsigned)srcScale <= 256);
|
||||
|
||||
srcScale >>= 3;
|
||||
|
||||
uint32_t src32 = SkExpand_rgb_16(src);
|
||||
uint32_t dst32 = SkExpand_rgb_16(dst);
|
||||
return SkCompact_rgb_16(dst32 + ((src32 - dst32) * srcScale >> 5));
|
||||
}
|
||||
|
||||
inline void SkBlendRGB16(const uint16_t src[], uint16_t dst[],
|
||||
int srcScale, int count) {
|
||||
SkASSERT(count > 0);
|
||||
SkASSERT((unsigned)srcScale <= 256);
|
||||
|
||||
srcScale >>= 3;
|
||||
|
||||
do {
|
||||
uint32_t src32 = SkExpand_rgb_16(*src++);
|
||||
uint32_t dst32 = SkExpand_rgb_16(*dst);
|
||||
*dst++ = SkCompact_rgb_16(dst32 + ((src32 - dst32) * srcScale >> 5));
|
||||
} while (--count > 0);
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
static inline U16CPU SkRGB16Add(U16CPU a, U16CPU b) {
|
||||
SkASSERT(SkGetPackedR16(a) + SkGetPackedR16(b) <= SK_R16_MASK);
|
||||
SkASSERT(SkGetPackedG16(a) + SkGetPackedG16(b) <= SK_G16_MASK);
|
||||
SkASSERT(SkGetPackedB16(a) + SkGetPackedB16(b) <= SK_B16_MASK);
|
||||
|
||||
return a + b;
|
||||
}
|
||||
#else
|
||||
#define SkRGB16Add(a, b) ((a) + (b))
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define SK_A32_BITS 8
|
||||
#define SK_R32_BITS 8
|
||||
#define SK_G32_BITS 8
|
||||
#define SK_B32_BITS 8
|
||||
|
||||
/* we check to see if the SHIFT value has already been defined (SkUserConfig.h)
|
||||
if not, we define it ourself to some default values. We default to OpenGL
|
||||
order (in memory: r,g,b,a)
|
||||
*/
|
||||
#ifndef SK_A32_SHIFT
|
||||
#ifdef SK_CPU_BENDIAN
|
||||
#define SK_R32_SHIFT 24
|
||||
#define SK_G32_SHIFT 16
|
||||
#define SK_B32_SHIFT 8
|
||||
#define SK_A32_SHIFT 0
|
||||
#else
|
||||
#define SK_R32_SHIFT 0
|
||||
#define SK_G32_SHIFT 8
|
||||
#define SK_B32_SHIFT 16
|
||||
#define SK_A32_SHIFT 24
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SK_A32_MASK ((1 << SK_A32_BITS) - 1)
|
||||
#define SK_R32_MASK ((1 << SK_R32_BITS) - 1)
|
||||
#define SK_G32_MASK ((1 << SK_G32_BITS) - 1)
|
||||
#define SK_B32_MASK ((1 << SK_B32_BITS) - 1)
|
||||
|
||||
#define SkGetPackedA32(packed) ((uint32_t)((packed) << (24 - SK_A32_SHIFT)) >> 24)
|
||||
#define SkGetPackedR32(packed) ((uint32_t)((packed) << (24 - SK_R32_SHIFT)) >> 24)
|
||||
#define SkGetPackedG32(packed) ((uint32_t)((packed) << (24 - SK_G32_SHIFT)) >> 24)
|
||||
#define SkGetPackedB32(packed) ((uint32_t)((packed) << (24 - SK_B32_SHIFT)) >> 24)
|
||||
|
||||
#define SkA32Assert(a) SkASSERT((unsigned)(a) <= SK_A32_MASK)
|
||||
#define SkR32Assert(r) SkASSERT((unsigned)(r) <= SK_R32_MASK)
|
||||
#define SkG32Assert(g) SkASSERT((unsigned)(g) <= SK_G32_MASK)
|
||||
#define SkB32Assert(b) SkASSERT((unsigned)(b) <= SK_B32_MASK)
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
inline void SkPMColorAssert(SkPMColor c) {
|
||||
unsigned a = SkGetPackedA32(c);
|
||||
unsigned r = SkGetPackedR32(c);
|
||||
unsigned g = SkGetPackedG32(c);
|
||||
unsigned b = SkGetPackedB32(c);
|
||||
|
||||
SkA32Assert(a);
|
||||
SkASSERT(r <= a);
|
||||
SkASSERT(g <= a);
|
||||
SkASSERT(b <= a);
|
||||
}
|
||||
#else
|
||||
#define SkPMColorAssert(c)
|
||||
#endif
|
||||
|
||||
inline SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
|
||||
SkA32Assert(a);
|
||||
SkASSERT(r <= a);
|
||||
SkASSERT(g <= a);
|
||||
SkASSERT(b <= a);
|
||||
|
||||
return (a << SK_A32_SHIFT) | (r << SK_R32_SHIFT) |
|
||||
(g << SK_G32_SHIFT) | (b << SK_B32_SHIFT);
|
||||
}
|
||||
|
||||
extern const uint32_t gMask_00FF00FF;
|
||||
|
||||
inline uint32_t SkAlphaMulQ(uint32_t c, unsigned scale) {
|
||||
uint32_t mask = gMask_00FF00FF;
|
||||
// uint32_t mask = 0xFF00FF;
|
||||
|
||||
uint32_t rb = ((c & mask) * scale) >> 8;
|
||||
uint32_t ag = ((c >> 8) & mask) * scale;
|
||||
return (rb & mask) | (ag & ~mask);
|
||||
}
|
||||
|
||||
inline SkPMColor SkPMSrcOver(SkPMColor src, SkPMColor dst) {
|
||||
return src + SkAlphaMulQ(dst, SkAlpha255To256(255 - SkGetPackedA32(src)));
|
||||
}
|
||||
|
||||
inline SkPMColor SkBlendARGB32(SkPMColor src, SkPMColor dst, U8CPU aa) {
|
||||
SkASSERT((unsigned)aa <= 255);
|
||||
|
||||
unsigned src_scale = SkAlpha255To256(aa);
|
||||
unsigned dst_scale = SkAlpha255To256(255 - SkAlphaMul(SkGetPackedA32(src), src_scale));
|
||||
|
||||
return SkAlphaMulQ(src, src_scale) + SkAlphaMulQ(dst, dst_scale);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Convert a 32bit pixel to a 16bit pixel (no dither)
|
||||
|
||||
#define SkR32ToR16_MACRO(r) ((unsigned)(r) >> (SK_R32_BITS - SK_R16_BITS))
|
||||
#define SkG32ToG16_MACRO(g) ((unsigned)(g) >> (SK_G32_BITS - SK_G16_BITS))
|
||||
#define SkB32ToB16_MACRO(b) ((unsigned)(b) >> (SK_B32_BITS - SK_B16_BITS))
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
inline unsigned SkR32ToR16(unsigned r)
|
||||
{
|
||||
SkR32Assert(r);
|
||||
return SkR32ToR16_MACRO(r);
|
||||
}
|
||||
inline unsigned SkG32ToG16(unsigned g)
|
||||
{
|
||||
SkG32Assert(g);
|
||||
return SkG32ToG16_MACRO(g);
|
||||
}
|
||||
inline unsigned SkB32ToB16(unsigned b)
|
||||
{
|
||||
SkB32Assert(b);
|
||||
return SkB32ToB16_MACRO(b);
|
||||
}
|
||||
#else
|
||||
#define SkR32ToR16(r) SkR32ToR16_MACRO(r)
|
||||
#define SkG32ToG16(g) SkG32ToG16_MACRO(g)
|
||||
#define SkB32ToB16(b) SkB32ToB16_MACRO(b)
|
||||
#endif
|
||||
|
||||
#define SkPacked32ToR16(c) (((unsigned)(c) >> (SK_R32_SHIFT + SK_R32_BITS - SK_R16_BITS)) & SK_R16_MASK)
|
||||
#define SkPacked32ToG16(c) (((unsigned)(c) >> (SK_G32_SHIFT + SK_G32_BITS - SK_G16_BITS)) & SK_G16_MASK)
|
||||
#define SkPacked32ToB16(c) (((unsigned)(c) >> (SK_B32_SHIFT + SK_B32_BITS - SK_B16_BITS)) & SK_B16_MASK)
|
||||
|
||||
inline U16CPU SkPixel32ToPixel16(SkPMColor c)
|
||||
{
|
||||
unsigned r = ((c >> (SK_R32_SHIFT + (8 - SK_R16_BITS))) & SK_R16_MASK) << SK_R16_SHIFT;
|
||||
unsigned g = ((c >> (SK_G32_SHIFT + (8 - SK_G16_BITS))) & SK_G16_MASK) << SK_G16_SHIFT;
|
||||
unsigned b = ((c >> (SK_B32_SHIFT + (8 - SK_B16_BITS))) & SK_B16_MASK) << SK_B16_SHIFT;
|
||||
return r | g | b;
|
||||
}
|
||||
|
||||
inline U16CPU SkPack888ToRGB16(U8CPU r, U8CPU g, U8CPU b)
|
||||
{
|
||||
return (SkR32ToR16(r) << SK_R16_SHIFT) |
|
||||
(SkG32ToG16(g) << SK_G16_SHIFT) |
|
||||
(SkB32ToB16(b) << SK_B16_SHIFT);
|
||||
}
|
||||
|
||||
#define SkPixel32ToPixel16_ToU16(src) SkToU16(SkPixel32ToPixel16(src))
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Fast dither from 32->16
|
||||
|
||||
#define SkShouldDitherXY(x, y) (((x) ^ (y)) & 1)
|
||||
|
||||
inline uint16_t SkDitherPack888ToRGB16(U8CPU r, U8CPU g, U8CPU b)
|
||||
{
|
||||
r = ((r << 1) - ((r >> (8 - SK_R16_BITS) << (8 - SK_R16_BITS)) | (r >> SK_R16_BITS))) >> (8 - SK_R16_BITS);
|
||||
g = ((g << 1) - ((g >> (8 - SK_G16_BITS) << (8 - SK_G16_BITS)) | (g >> SK_G16_BITS))) >> (8 - SK_G16_BITS);
|
||||
b = ((b << 1) - ((b >> (8 - SK_B16_BITS) << (8 - SK_B16_BITS)) | (b >> SK_B16_BITS))) >> (8 - SK_B16_BITS);
|
||||
|
||||
return SkPackRGB16(r, g, b);
|
||||
}
|
||||
|
||||
inline uint16_t SkDitherPixel32ToPixel16(SkPMColor c)
|
||||
{
|
||||
return SkDitherPack888ToRGB16(SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c));
|
||||
}
|
||||
|
||||
/* Return c in expanded_rgb_16 format, but also scaled up by 32 (5 bits)
|
||||
It is now suitable for combining with a scaled expanded_rgb_16 color
|
||||
as in SkSrcOver32To16().
|
||||
We must do this 565 high-bit replication, in order for the subsequent add
|
||||
to saturate properly (and not overflow). If we take the 8 bits as is, it is
|
||||
possible to overflow.
|
||||
*/
|
||||
inline uint32_t SkPMColorToExpanded16x5(SkPMColor c)
|
||||
{
|
||||
unsigned sr = SkPacked32ToR16(c);
|
||||
unsigned sg = SkPacked32ToG16(c);
|
||||
unsigned sb = SkPacked32ToB16(c);
|
||||
|
||||
sr = (sr << 5) | sr;
|
||||
sg = (sg << 5) | (sg >> 1);
|
||||
sb = (sb << 5) | sb;
|
||||
return (sr << 11) | (sg << 21) | (sb << 0);
|
||||
}
|
||||
|
||||
/* SrcOver the 32bit src color with the 16bit dst, returning a 16bit value
|
||||
(with dirt in the high 16bits, so caller beware).
|
||||
*/
|
||||
inline U16CPU SkSrcOver32To16(SkPMColor src, uint16_t dst) {
|
||||
unsigned sr = SkGetPackedR32(src);
|
||||
unsigned sg = SkGetPackedG32(src);
|
||||
unsigned sb = SkGetPackedB32(src);
|
||||
|
||||
unsigned dr = SkGetPackedR16(dst);
|
||||
unsigned dg = SkGetPackedG16(dst);
|
||||
unsigned db = SkGetPackedB16(dst);
|
||||
|
||||
unsigned isa = 255 - SkGetPackedA32(src);
|
||||
|
||||
dr = (sr + SkMul16ShiftRound(dr, isa, SK_R16_BITS)) >> (8 - SK_R16_BITS);
|
||||
dg = (sg + SkMul16ShiftRound(dg, isa, SK_G16_BITS)) >> (8 - SK_G16_BITS);
|
||||
db = (sb + SkMul16ShiftRound(db, isa, SK_B16_BITS)) >> (8 - SK_B16_BITS);
|
||||
|
||||
return SkPackRGB16(dr, dg, db);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Convert a 16bit pixel to a 32bit pixel
|
||||
|
||||
inline unsigned SkR16ToR32(unsigned r)
|
||||
{
|
||||
return (r << (8 - SK_R16_BITS)) | (r >> (2 * SK_R16_BITS - 8));
|
||||
}
|
||||
inline unsigned SkG16ToG32(unsigned g)
|
||||
{
|
||||
return (g << (8 - SK_G16_BITS)) | (g >> (2 * SK_G16_BITS - 8));
|
||||
}
|
||||
inline unsigned SkB16ToB32(unsigned b)
|
||||
{
|
||||
return (b << (8 - SK_B16_BITS)) | (b >> (2 * SK_B16_BITS - 8));
|
||||
}
|
||||
|
||||
#define SkPacked16ToR32(c) SkR16ToR32(SkGetPackedR16(c))
|
||||
#define SkPacked16ToG32(c) SkG16ToG32(SkGetPackedG16(c))
|
||||
#define SkPacked16ToB32(c) SkB16ToB32(SkGetPackedB16(c))
|
||||
|
||||
inline SkPMColor SkPixel16ToPixel32(U16CPU src)
|
||||
{
|
||||
SkASSERT(src == SkToU16(src));
|
||||
|
||||
unsigned r = SkPacked16ToR32(src);
|
||||
unsigned g = SkPacked16ToG32(src);
|
||||
unsigned b = SkPacked16ToB32(src);
|
||||
|
||||
SkASSERT((r >> (8 - SK_R16_BITS)) == SkGetPackedR16(src));
|
||||
SkASSERT((g >> (8 - SK_G16_BITS)) == SkGetPackedG16(src));
|
||||
SkASSERT((b >> (8 - SK_B16_BITS)) == SkGetPackedB16(src));
|
||||
|
||||
return SkPackARGB32(0xFF, r, g, b);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint16_t SkPMColor16;
|
||||
|
||||
// Put in OpenGL order (r g b a)
|
||||
#define SK_A4444_SHIFT 0
|
||||
#define SK_R4444_SHIFT 12
|
||||
#define SK_G4444_SHIFT 8
|
||||
#define SK_B4444_SHIFT 4
|
||||
|
||||
#define SkA32To4444(a) ((unsigned)(a) >> 4)
|
||||
#define SkR32To4444(r) ((unsigned)(r) >> 4)
|
||||
#define SkG32To4444(g) ((unsigned)(g) >> 4)
|
||||
#define SkB32To4444(b) ((unsigned)(b) >> 4)
|
||||
|
||||
inline U8CPU SkReplicateNibble(unsigned nib)
|
||||
{
|
||||
SkASSERT(nib <= 0xF);
|
||||
return (nib << 4) | nib;
|
||||
}
|
||||
|
||||
#define SkA4444ToA32(a) SkReplicateNibble(a)
|
||||
#define SkR4444ToR32(r) SkReplicateNibble(r)
|
||||
#define SkG4444ToG32(g) SkReplicateNibble(g)
|
||||
#define SkB4444ToB32(b) SkReplicateNibble(b)
|
||||
|
||||
#define SkGetPackedA4444(c) (((unsigned)(c) >> SK_A4444_SHIFT) & 0xF)
|
||||
#define SkGetPackedR4444(c) (((unsigned)(c) >> SK_R4444_SHIFT) & 0xF)
|
||||
#define SkGetPackedG4444(c) (((unsigned)(c) >> SK_G4444_SHIFT) & 0xF)
|
||||
#define SkGetPackedB4444(c) (((unsigned)(c) >> SK_B4444_SHIFT) & 0xF)
|
||||
|
||||
#define SkPacked4444ToA32(c) SkReplicateNibble(SkGetPackedA4444(c))
|
||||
#define SkPacked4444ToR32(c) SkReplicateNibble(SkGetPackedR4444(c))
|
||||
#define SkPacked4444ToG32(c) SkReplicateNibble(SkGetPackedG4444(c))
|
||||
#define SkPacked4444ToB32(c) SkReplicateNibble(SkGetPackedB4444(c))
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
inline void SkPMColor16Assert(U16CPU c)
|
||||
{
|
||||
unsigned a = SkGetPackedA4444(c);
|
||||
unsigned r = SkGetPackedR4444(c);
|
||||
unsigned g = SkGetPackedG4444(c);
|
||||
unsigned b = SkGetPackedB4444(c);
|
||||
|
||||
SkASSERT(a <= 0xF);
|
||||
SkASSERT(r <= a);
|
||||
SkASSERT(g <= a);
|
||||
SkASSERT(b <= a);
|
||||
}
|
||||
#else
|
||||
#define SkPMColor16Assert(c)
|
||||
#endif
|
||||
|
||||
inline unsigned SkAlpha15To16(unsigned a)
|
||||
{
|
||||
SkASSERT(a <= 0xF);
|
||||
return a + (a >> 3);
|
||||
}
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
inline int SkAlphaMul4(int value, int scale)
|
||||
{
|
||||
SkASSERT((unsigned)scale <= 0x10);
|
||||
return value * scale >> 4;
|
||||
}
|
||||
#else
|
||||
#define SkAlphaMul4(value, scale) ((value) * (scale) >> 4)
|
||||
#endif
|
||||
|
||||
inline unsigned SkR4444ToR565(unsigned r)
|
||||
{
|
||||
SkASSERT(r <= 0xF);
|
||||
return (r << (SK_R16_BITS - 4)) | (r >> (8 - SK_R16_BITS));
|
||||
}
|
||||
|
||||
inline unsigned SkG4444ToG565(unsigned g)
|
||||
{
|
||||
SkASSERT(g <= 0xF);
|
||||
return (g << (SK_G16_BITS - 4)) | (g >> (8 - SK_G16_BITS));
|
||||
}
|
||||
|
||||
inline unsigned SkB4444ToB565(unsigned b)
|
||||
{
|
||||
SkASSERT(b <= 0xF);
|
||||
return (b << (SK_B16_BITS - 4)) | (b >> (8 - SK_B16_BITS));
|
||||
}
|
||||
|
||||
inline SkPMColor16 SkPackARGB4444(unsigned a, unsigned r,
|
||||
unsigned g, unsigned b)
|
||||
{
|
||||
SkASSERT(a <= 0xF);
|
||||
SkASSERT(r <= a);
|
||||
SkASSERT(g <= a);
|
||||
SkASSERT(b <= a);
|
||||
|
||||
return (SkPMColor16)((a << SK_A4444_SHIFT) | (r << SK_R4444_SHIFT) |
|
||||
(g << SK_G4444_SHIFT) | (b << SK_B4444_SHIFT));
|
||||
}
|
||||
|
||||
extern const uint16_t gMask_0F0F;
|
||||
|
||||
inline U16CPU SkAlphaMulQ4(U16CPU c, unsigned scale)
|
||||
{
|
||||
SkASSERT(scale <= 16);
|
||||
|
||||
const unsigned mask = 0xF0F; //gMask_0F0F;
|
||||
|
||||
#if 0
|
||||
unsigned rb = ((c & mask) * scale) >> 4;
|
||||
unsigned ag = ((c >> 4) & mask) * scale;
|
||||
return (rb & mask) | (ag & ~mask);
|
||||
#else
|
||||
c = (c & mask) | ((c & (mask << 4)) << 12);
|
||||
c = c * scale >> 4;
|
||||
return (c & mask) | ((c >> 12) & (mask << 4));
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Expand the SkPMColor16 color into a 32bit value that can be scaled all at
|
||||
once by a value up to 16. Used in conjunction with SkCompact_4444.
|
||||
*/
|
||||
inline uint32_t SkExpand_4444(U16CPU c)
|
||||
{
|
||||
SkASSERT(c == (uint16_t)c);
|
||||
|
||||
const unsigned mask = 0xF0F; //gMask_0F0F;
|
||||
return (c & mask) | ((c & ~mask) << 12);
|
||||
}
|
||||
|
||||
/** Compress an expanded value (from SkExpand_4444) back down to a SkPMColor16.
|
||||
NOTE: this explicitly does not clean the top 16 bits (which may be garbage).
|
||||
It does this for speed, since if it is being written directly to 16bits of
|
||||
memory, the top 16bits will be ignored. Casting the result to uint16_t here
|
||||
would add 2 more instructions, slow us down. It is up to the caller to
|
||||
perform the cast if needed.
|
||||
*/
|
||||
inline U16CPU SkCompact_4444(uint32_t c)
|
||||
{
|
||||
const unsigned mask = 0xF0F; //gMask_0F0F;
|
||||
return (c & mask) | ((c >> 12) & ~mask);
|
||||
}
|
||||
|
||||
inline uint16_t SkSrcOver4444To16(SkPMColor16 s, uint16_t d)
|
||||
{
|
||||
unsigned sa = SkGetPackedA4444(s);
|
||||
unsigned sr = SkR4444ToR565(SkGetPackedR4444(s));
|
||||
unsigned sg = SkG4444ToG565(SkGetPackedG4444(s));
|
||||
unsigned sb = SkB4444ToB565(SkGetPackedB4444(s));
|
||||
|
||||
// To avoid overflow, we have to clear the low bit of the synthetic sg
|
||||
// if the src alpha is <= 7.
|
||||
// to see why, try blending 0x4444 on top of 565-white and watch green
|
||||
// overflow (sum == 64)
|
||||
sg &= ~(~(sa >> 3) & 1);
|
||||
|
||||
unsigned scale = SkAlpha15To16(15 - sa);
|
||||
unsigned dr = SkAlphaMul4(SkGetPackedR16(d), scale);
|
||||
unsigned dg = SkAlphaMul4(SkGetPackedG16(d), scale);
|
||||
unsigned db = SkAlphaMul4(SkGetPackedB16(d), scale);
|
||||
|
||||
#if 0
|
||||
if (sg + dg > 63) {
|
||||
SkDebugf("---- SkSrcOver4444To16 src=%x dst=%x scale=%d, sg=%d dg=%d\n", s, d, scale, sg, dg);
|
||||
}
|
||||
#endif
|
||||
return SkPackRGB16(sr + dr, sg + dg, sb + db);
|
||||
}
|
||||
|
||||
inline uint16_t SkBlend4444To16(SkPMColor16 src, uint16_t dst, int scale16)
|
||||
{
|
||||
SkASSERT((unsigned)scale16 <= 16);
|
||||
|
||||
return SkSrcOver4444To16(SkAlphaMulQ4(src, scale16), dst);
|
||||
}
|
||||
|
||||
inline uint16_t SkBlend4444(SkPMColor16 src, SkPMColor16 dst, int scale16)
|
||||
{
|
||||
SkASSERT((unsigned)scale16 <= 16);
|
||||
|
||||
uint32_t src32 = SkExpand_4444(src) * scale16;
|
||||
// the scaled srcAlpha is the bottom byte
|
||||
#ifdef SK_DEBUG
|
||||
{
|
||||
unsigned srcA = SkGetPackedA4444(src) * scale16;
|
||||
SkASSERT(srcA == (src32 & 0xFF));
|
||||
}
|
||||
#endif
|
||||
unsigned dstScale = SkAlpha255To256(255 - (src32 & 0xFF)) >> 4;
|
||||
uint32_t dst32 = SkExpand_4444(dst) * dstScale;
|
||||
return SkCompact_4444((src32 + dst32) >> 4);
|
||||
}
|
||||
|
||||
inline SkPMColor SkPixel4444ToPixel32(U16CPU c)
|
||||
{
|
||||
uint32_t d = (SkGetPackedA4444(c) << SK_A32_SHIFT) |
|
||||
(SkGetPackedR4444(c) << SK_R32_SHIFT) |
|
||||
(SkGetPackedG4444(c) << SK_G32_SHIFT) |
|
||||
(SkGetPackedB4444(c) << SK_B32_SHIFT);
|
||||
return d | (d << 4);
|
||||
}
|
||||
|
||||
inline SkPMColor16 SkPixel32ToPixel4444(SkPMColor c)
|
||||
{
|
||||
return (((c >> (SK_A32_SHIFT + 4)) & 0xF) << SK_A4444_SHIFT) |
|
||||
(((c >> (SK_R32_SHIFT + 4)) & 0xF) << SK_R4444_SHIFT) |
|
||||
(((c >> (SK_G32_SHIFT + 4)) & 0xF) << SK_G4444_SHIFT) |
|
||||
(((c >> (SK_B32_SHIFT + 4)) & 0xF) << SK_B4444_SHIFT);
|
||||
}
|
||||
|
||||
// cheap 2x2 dither
|
||||
inline SkPMColor16 SkDitherARGB32To4444(U8CPU a, U8CPU r,
|
||||
U8CPU g, U8CPU b)
|
||||
{
|
||||
a = ((a << 1) - ((a >> 4 << 4) | (a >> 4))) >> 4;
|
||||
r = ((r << 1) - ((r >> 4 << 4) | (r >> 4))) >> 4;
|
||||
g = ((g << 1) - ((g >> 4 << 4) | (g >> 4))) >> 4;
|
||||
b = ((b << 1) - ((b >> 4 << 4) | (b >> 4))) >> 4;
|
||||
|
||||
return SkPackARGB4444(a, r, g, b);
|
||||
}
|
||||
|
||||
inline SkPMColor16 SkDitherPixel32To4444(SkPMColor c)
|
||||
{
|
||||
return SkDitherARGB32To4444(SkGetPackedA32(c), SkGetPackedR32(c),
|
||||
SkGetPackedG32(c), SkGetPackedB32(c));
|
||||
}
|
||||
|
||||
/* Assumes 16bit is in standard RGBA order.
|
||||
Transforms a normal ARGB_8888 into the same byte order as
|
||||
expanded ARGB_4444, but keeps each component 8bits
|
||||
*/
|
||||
inline uint32_t SkExpand_8888(SkPMColor c)
|
||||
{
|
||||
return (((c >> SK_R32_SHIFT) & 0xFF) << 24) |
|
||||
(((c >> SK_G32_SHIFT) & 0xFF) << 8) |
|
||||
(((c >> SK_B32_SHIFT) & 0xFF) << 16) |
|
||||
(((c >> SK_A32_SHIFT) & 0xFF) << 0);
|
||||
}
|
||||
|
||||
/* Undo the operation of SkExpand_8888, turning the argument back into
|
||||
a SkPMColor.
|
||||
*/
|
||||
inline SkPMColor SkCompact_8888(uint32_t c)
|
||||
{
|
||||
return (((c >> 24) & 0xFF) << SK_R32_SHIFT) |
|
||||
(((c >> 8) & 0xFF) << SK_G32_SHIFT) |
|
||||
(((c >> 16) & 0xFF) << SK_B32_SHIFT) |
|
||||
(((c >> 0) & 0xFF) << SK_A32_SHIFT);
|
||||
}
|
||||
|
||||
/* Like SkExpand_8888, this transforms a pmcolor into the expanded 4444 format,
|
||||
but this routine just keeps the high 4bits of each component in the low
|
||||
4bits of the result (just like a newly expanded PMColor16).
|
||||
*/
|
||||
inline uint32_t SkExpand32_4444(SkPMColor c)
|
||||
{
|
||||
return (((c >> (SK_R32_SHIFT + 4)) & 0xF) << 24) |
|
||||
(((c >> (SK_G32_SHIFT + 4)) & 0xF) << 8) |
|
||||
(((c >> (SK_B32_SHIFT + 4)) & 0xF) << 16) |
|
||||
(((c >> (SK_A32_SHIFT + 4)) & 0xF) << 0);
|
||||
}
|
||||
|
||||
// takes two values and alternamtes them as part of a memset16
|
||||
// used for cheap 2x2 dithering when the colors are opaque
|
||||
void sk_dither_memset16(uint16_t dst[], uint16_t value, uint16_t other, int n);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkColorShader_DEFINED
|
||||
#define SkColorShader_DEFINED
|
||||
|
||||
#include "SkShader.h"
|
||||
|
||||
/** \class SkColorShader
|
||||
A Shader that represents a single color. In general, this effect can be
|
||||
accomplished by just using the color field on the paint, but if an
|
||||
actual shader object is needed, this provides that feature.
|
||||
*/
|
||||
class SkColorShader : public SkShader {
|
||||
public:
|
||||
/** Create a ColorShader that will inherit its color from the Paint
|
||||
at draw time.
|
||||
*/
|
||||
SkColorShader() : fInheritColor(true) {}
|
||||
/** Create a ColorShader that ignores the color in the paint, and uses the
|
||||
specified color. Note: like all shaders, at draw time the paint's alpha
|
||||
will be respected, and is applied to the specified color.
|
||||
*/
|
||||
SkColorShader(SkColor c) : fColor(c), fInheritColor(false) {}
|
||||
|
||||
virtual uint32_t getFlags();
|
||||
virtual uint8_t getSpan16Alpha() const;
|
||||
virtual bool setContext(const SkBitmap& device, const SkPaint& paint,
|
||||
const SkMatrix& matrix);
|
||||
virtual void shadeSpan(int x, int y, SkPMColor span[], int count);
|
||||
virtual void shadeSpan16(int x, int y, uint16_t span[], int count);
|
||||
virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count);
|
||||
|
||||
protected:
|
||||
SkColorShader(SkFlattenableReadBuffer& );
|
||||
virtual void flatten(SkFlattenableWriteBuffer& );
|
||||
virtual Factory getFactory() { return CreateProc; }
|
||||
private:
|
||||
static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
|
||||
return SkNEW_ARGS(SkColorShader, (buffer));
|
||||
}
|
||||
SkColor fColor; // ignored if fInheritColor is true
|
||||
SkPMColor fPMColor; // cached after setContext()
|
||||
uint16_t fColor16; // cached after setContext()
|
||||
SkBool8 fInheritColor;
|
||||
|
||||
typedef SkShader INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkCornerPathEffect_DEFINED
|
||||
#define SkCornerPathEffect_DEFINED
|
||||
|
||||
#include "SkPathEffect.h"
|
||||
|
||||
/** \class SkCornerPathEffect
|
||||
|
||||
SkCornerPathEffect is a subclass of SkPathEffect that can turn sharp corners
|
||||
into various treatments (e.g. rounded corners)
|
||||
*/
|
||||
class SkCornerPathEffect : public SkPathEffect {
|
||||
public:
|
||||
/** radius must be > 0 to have an effect. It specifies the distance from each corner
|
||||
that should be "rounded".
|
||||
*/
|
||||
SkCornerPathEffect(SkScalar radius);
|
||||
virtual ~SkCornerPathEffect();
|
||||
|
||||
// overrides for SkPathEffect
|
||||
// This method is not exported to java.
|
||||
virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
|
||||
|
||||
// overrides for SkFlattenable
|
||||
// This method is not exported to java.
|
||||
virtual Factory getFactory();
|
||||
// This method is not exported to java.
|
||||
virtual void flatten(SkFlattenableWriteBuffer&);
|
||||
|
||||
protected:
|
||||
SkCornerPathEffect(SkFlattenableReadBuffer&);
|
||||
|
||||
private:
|
||||
SkScalar fRadius;
|
||||
|
||||
static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
|
||||
|
||||
// illegal
|
||||
SkCornerPathEffect(const SkCornerPathEffect&);
|
||||
SkCornerPathEffect& operator=(const SkCornerPathEffect&);
|
||||
|
||||
typedef SkPathEffect INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkCullPoints_DEFINED
|
||||
#define SkCullPoints_DEFINED
|
||||
|
||||
#include "SkRect.h"
|
||||
|
||||
class SkCullPoints {
|
||||
public:
|
||||
SkCullPoints();
|
||||
SkCullPoints(const SkIRect& r);
|
||||
|
||||
void reset(const SkIRect& r);
|
||||
|
||||
/** Start a contour at (x,y). Follow this with call(s) to lineTo(...)
|
||||
*/
|
||||
void moveTo(int x, int y);
|
||||
|
||||
enum LineToResult {
|
||||
kNo_Result, //!< line segment was completely clipped out
|
||||
kLineTo_Result, //!< path.lineTo(pts[1]);
|
||||
kMoveToLineTo_Result //!< path.moveTo(pts[0]); path.lineTo(pts[1]);
|
||||
};
|
||||
/** Connect a line to the previous call to lineTo (or moveTo).
|
||||
*/
|
||||
LineToResult lineTo(int x, int y, SkIPoint pts[2]);
|
||||
|
||||
private:
|
||||
SkIRect fR; // the caller's rectangle
|
||||
SkIPoint fAsQuad[4]; // cache of fR as 4 points
|
||||
SkIPoint fPrevPt; // private state
|
||||
LineToResult fPrevResult; // private state
|
||||
|
||||
bool sect_test(int x0, int y0, int x1, int y1) const;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class SkPath;
|
||||
|
||||
/** \class SkCullPointsPath
|
||||
|
||||
Similar to SkCullPoints, but this class handles the return values
|
||||
from lineTo, and automatically builds a SkPath with the result(s).
|
||||
*/
|
||||
class SkCullPointsPath {
|
||||
public:
|
||||
SkCullPointsPath();
|
||||
SkCullPointsPath(const SkIRect& r, SkPath* dst);
|
||||
|
||||
void reset(const SkIRect& r, SkPath* dst);
|
||||
|
||||
void moveTo(int x, int y);
|
||||
void lineTo(int x, int y);
|
||||
|
||||
private:
|
||||
SkCullPoints fCP;
|
||||
SkPath* fPath;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkDOM_DEFINED
|
||||
#define SkDOM_DEFINED
|
||||
|
||||
#include "SkChunkAlloc.h"
|
||||
#include "SkMath.h"
|
||||
#include "SkScalar.h"
|
||||
#include "SkTemplates.h"
|
||||
|
||||
struct SkDOMNode;
|
||||
struct SkDOMAttr;
|
||||
|
||||
class SkDOM {
|
||||
public:
|
||||
SkDOM();
|
||||
~SkDOM();
|
||||
|
||||
typedef SkDOMNode Node;
|
||||
typedef SkDOMAttr Attr;
|
||||
|
||||
/** Returns null on failure
|
||||
*/
|
||||
const Node* build(const char doc[], size_t len);
|
||||
const Node* copy(const SkDOM& dom, const Node* node);
|
||||
|
||||
const Node* getRootNode() const;
|
||||
|
||||
enum Type {
|
||||
kElement_Type,
|
||||
kText_Type
|
||||
};
|
||||
Type getType(const Node*) const;
|
||||
|
||||
const char* getName(const Node*) const;
|
||||
const Node* getFirstChild(const Node*, const char elem[] = NULL) const;
|
||||
const Node* getNextSibling(const Node*, const char elem[] = NULL) const;
|
||||
|
||||
const char* findAttr(const Node*, const char attrName[]) const;
|
||||
const Attr* getFirstAttr(const Node*) const;
|
||||
const Attr* getNextAttr(const Node*, const Attr*) const;
|
||||
const char* getAttrName(const Node*, const Attr*) const;
|
||||
const char* getAttrValue(const Node*, const Attr*) const;
|
||||
|
||||
// helpers for walking children
|
||||
int countChildren(const Node* node, const char elem[] = NULL) const;
|
||||
|
||||
// helpers for calling SkParse
|
||||
bool findS32(const Node*, const char name[], int32_t* value) const;
|
||||
bool findScalars(const Node*, const char name[], SkScalar value[], int count) const;
|
||||
bool findHex(const Node*, const char name[], uint32_t* value) const;
|
||||
bool findBool(const Node*, const char name[], bool*) const;
|
||||
int findList(const Node*, const char name[], const char list[]) const;
|
||||
|
||||
bool findScalar(const Node* node, const char name[], SkScalar value[]) const
|
||||
{
|
||||
return this->findScalars(node, name, value, 1);
|
||||
}
|
||||
|
||||
bool hasAttr(const Node*, const char name[], const char value[]) const;
|
||||
bool hasS32(const Node*, const char name[], int32_t value) const;
|
||||
bool hasScalar(const Node*, const char name[], SkScalar value) const;
|
||||
bool hasHex(const Node*, const char name[], uint32_t value) const;
|
||||
bool hasBool(const Node*, const char name[], bool value) const;
|
||||
|
||||
class AttrIter {
|
||||
public:
|
||||
AttrIter(const class SkDOM&, const Node*);
|
||||
const char* next(const char** value);
|
||||
private:
|
||||
const Attr* fAttr;
|
||||
const Attr* fStop;
|
||||
};
|
||||
|
||||
SkDEBUGCODE(void dump(const Node* node = NULL, int tabLevel = 0) const;)
|
||||
SkDEBUGCODE(static void UnitTest();)
|
||||
|
||||
private:
|
||||
SkChunkAlloc fAlloc;
|
||||
Node* fRoot;
|
||||
friend class AttrIter;
|
||||
friend class SkDOMParser;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SkDashPathEffect_DEFINED
|
||||
#define SkDashPathEffect_DEFINED
|
||||
|
||||
#include "SkPathEffect.h"
|
||||
|
||||
/** \class SkDashPathEffect
|
||||
|
||||
SkDashPathEffect is a subclass of SkPathEffect that implements dashing
|
||||
*/
|
||||
class SkDashPathEffect : public SkPathEffect {
|
||||
public:
|
||||
/** The intervals array must contain an even number of entries (>=2), with the even
|
||||
indices specifying the "on" intervals, and the odd indices specifying the "off"
|
||||
intervals. phase is an offset into the intervals array (mod the sum of all of the
|
||||
intervals).
|
||||
Note: only affects framed paths
|
||||
*/
|
||||
SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase, bool scaleToFit = false);
|
||||
virtual ~SkDashPathEffect();
|
||||
|
||||
// overrides for SkPathEffect
|
||||
// This method is not exported to java.
|
||||
virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
|
||||
|
||||
// overrides for SkFlattenable
|
||||
// This method is not exported to java.
|
||||
virtual Factory getFactory();
|
||||
// This method is not exported to java.
|
||||
virtual void flatten(SkFlattenableWriteBuffer&);
|
||||
|
||||
protected:
|
||||
SkDashPathEffect(SkFlattenableReadBuffer&);
|
||||
|
||||
private:
|
||||
SkScalar* fIntervals;
|
||||
int32_t fCount;
|
||||
// computed from phase
|
||||
SkScalar fInitialDashLength;
|
||||
int32_t fInitialDashIndex;
|
||||
SkScalar fIntervalLength;
|
||||
bool fScaleToFit;
|
||||
|
||||
static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
|
||||
|
||||
typedef SkPathEffect INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário