blob: b4bc0199a99e08c657a05a2c11f4346b055f014d [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Skia: include/core/SkUtils.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
<h1>include/core/SkUtils.h</h1><a href="_sk_utils_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Copyright (C) 2006 The Android Open Source Project</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span>
<a name="l00005"></a>00005 <span class="comment"> * you may not use this file except in compliance with the License.</span>
<a name="l00006"></a>00006 <span class="comment"> * You may obtain a copy of the License at</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span>
<a name="l00011"></a>00011 <span class="comment"> * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span>
<a name="l00012"></a>00012 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<a name="l00013"></a>00013 <span class="comment"> * See the License for the specific language governing permissions and</span>
<a name="l00014"></a>00014 <span class="comment"> * limitations under the License.</span>
<a name="l00015"></a>00015 <span class="comment"> */</span>
<a name="l00016"></a>00016
<a name="l00017"></a>00017 <span class="preprocessor">#ifndef SkUtils_DEFINED</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define SkUtils_DEFINED</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;<a class="code" href="_sk_types_8h.html">SkTypes.h</a>&quot;</span>
<a name="l00021"></a>00021
<a name="l00023"></a>00023
<a name="l00029"></a>00029 <span class="keywordtype">void</span> <a class="code" href="_sk_utils_8h.html#a002dc003baee54b54435d8da63c37e79">sk_memset16_portable</a>(uint16_t dst[], uint16_t value, <span class="keywordtype">int</span> count);
<a name="l00030"></a>00030
<a name="l00036"></a>00036 <span class="keywordtype">void</span> <a class="code" href="_sk_utils_8h.html#a86adca75d5d8d6eb9f077658c0c37a87">sk_memset32_portable</a>(uint32_t dst[], uint32_t value, <span class="keywordtype">int</span> count);
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="preprocessor">#ifdef ANDROID</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span><span class="preprocessor"> #include &quot;cutils/memory.h&quot;</span>
<a name="l00040"></a>00040
<a name="l00041"></a>00041 <span class="preprocessor"> #define sk_memset16(dst, value, count) android_memset16(dst, value, (count) &lt;&lt; 1)</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span><span class="preprocessor"> #define sk_memset32(dst, value, count) android_memset32(dst, value, (count) &lt;&lt; 2)</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span>
<a name="l00045"></a>00045 <span class="preprocessor">#ifndef sk_memset16</span>
<a name="l00046"></a><a class="code" href="_sk_utils_8h.html#a0e3001f7398e2b92e05f61dd4e73e8f2">00046</a> <span class="preprocessor"></span><span class="preprocessor"> #define sk_memset16(dst, value, count) sk_memset16_portable(dst, value, count)</span>
<a name="l00047"></a>00047 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span>
<a name="l00049"></a>00049 <span class="preprocessor">#ifndef sk_memset32</span>
<a name="l00050"></a><a class="code" href="_sk_utils_8h.html#a5dad9281749ed4738c99baa286bffb9f">00050</a> <span class="preprocessor"></span><span class="preprocessor"> #define sk_memset32(dst, value, count) sk_memset32_portable(dst, value, count)</span>
<a name="l00051"></a>00051 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00052"></a>00052 <span class="preprocessor"></span>
<a name="l00053"></a>00053
<a name="l00055"></a>00055
<a name="l00056"></a><a class="code" href="_sk_utils_8h.html#a6bb6767bdb87843b548362731820ac97">00056</a> <span class="preprocessor">#define kMaxBytesInUTF8Sequence 4</span>
<a name="l00057"></a>00057 <span class="preprocessor"></span>
<a name="l00058"></a>00058 <span class="preprocessor">#ifdef SK_DEBUG</span>
<a name="l00059"></a>00059 <span class="preprocessor"></span> <span class="keywordtype">int</span> <a class="code" href="_sk_utils_8h.html#a81e0ac851ac7a040352ff9a78e2dc399">SkUTF8_LeadByteToCount</a>(<span class="keywordtype">unsigned</span> c);
<a name="l00060"></a>00060 <span class="preprocessor">#else</span>
<a name="l00061"></a>00061 <span class="preprocessor"></span><span class="preprocessor"> #define SkUTF8_LeadByteToCount(c) ((((0xE5 &lt;&lt; 24) &gt;&gt; ((unsigned)c &gt;&gt; 4 &lt;&lt; 1)) &amp; 3) + 1)</span>
<a name="l00062"></a>00062 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00063"></a>00063 <span class="preprocessor"></span>
<a name="l00064"></a><a class="code" href="_sk_utils_8h.html#ab98ed7dbc7b8e90b74338378430b460d">00064</a> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="_sk_utils_8h.html#ab98ed7dbc7b8e90b74338378430b460d">SkUTF8_CountUTF8Bytes</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> utf8[])
<a name="l00065"></a>00065 {
<a name="l00066"></a>00066 <a class="code" href="_sk_types_8h.html#acc82ca88a67ae7ce95a107a9a4b81123">SkASSERT</a>(utf8);
<a name="l00067"></a>00067 <span class="keywordflow">return</span> <a class="code" href="_sk_utils_8h.html#a81e0ac851ac7a040352ff9a78e2dc399">SkUTF8_LeadByteToCount</a>(*(<span class="keyword">const</span> uint8_t*)utf8);
<a name="l00068"></a>00068 }
<a name="l00069"></a>00069
<a name="l00070"></a>00070 <span class="keywordtype">int</span> <a class="code" href="_sk_utils_8h.html#aaa3c0646e8dcbc1acd542e2afdb81d29">SkUTF8_CountUnichars</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> utf8[]);
<a name="l00071"></a>00071 <span class="keywordtype">int</span> <a class="code" href="_sk_utils_8h.html#aaa3c0646e8dcbc1acd542e2afdb81d29">SkUTF8_CountUnichars</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> utf8[], <span class="keywordtype">size_t</span> byteLength);
<a name="l00072"></a>00072 <a class="code" href="_sk_types_8h.html#a0b73f568570c6560e0a4f2713cb36d06">SkUnichar</a> <a class="code" href="_sk_utils_8h.html#ac64518ca517b92bdcdce6cd5a0a084cc">SkUTF8_ToUnichar</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> utf8[]);
<a name="l00073"></a>00073 <a class="code" href="_sk_types_8h.html#a0b73f568570c6560e0a4f2713cb36d06">SkUnichar</a> <a class="code" href="_sk_utils_8h.html#abb5acde66a3b99025723ba75093da3aa">SkUTF8_NextUnichar</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>**);
<a name="l00074"></a>00074 <a class="code" href="_sk_types_8h.html#a0b73f568570c6560e0a4f2713cb36d06">SkUnichar</a> <a class="code" href="_sk_utils_8h.html#ac0cbcd99e761fdfe86320a186ca50af8">SkUTF8_PrevUnichar</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>**);
<a name="l00075"></a>00075
<a name="l00080"></a>00080 <span class="keywordtype">size_t</span> <a class="code" href="_sk_utils_8h.html#a5f1869cdc37e6bc4ea07a0d57d71b33b">SkUTF8_FromUnichar</a>(<a class="code" href="_sk_types_8h.html#a0b73f568570c6560e0a4f2713cb36d06">SkUnichar</a> uni, <span class="keywordtype">char</span> utf8[] = NULL);
<a name="l00081"></a>00081
<a name="l00083"></a>00083
<a name="l00084"></a><a class="code" href="_sk_utils_8h.html#a11fa7fd96e79c44f4e95f1d4b9621f63">00084</a> <span class="preprocessor">#define SkUTF16_IsHighSurrogate(c) (((c) &amp; 0xFC00) == 0xD800)</span>
<a name="l00085"></a><a class="code" href="_sk_utils_8h.html#abb339617d8ab310151876eee2faa9555">00085</a> <span class="preprocessor"></span><span class="preprocessor">#define SkUTF16_IsLowSurrogate(c) (((c) &amp; 0xFC00) == 0xDC00)</span>
<a name="l00086"></a>00086 <span class="preprocessor"></span>
<a name="l00087"></a>00087 <span class="keywordtype">int</span> <a class="code" href="_sk_utils_8h.html#a1856aca1295ca11fd5e07c442694806c">SkUTF16_CountUnichars</a>(<span class="keyword">const</span> uint16_t utf16[]);
<a name="l00088"></a>00088 <span class="keywordtype">int</span> <a class="code" href="_sk_utils_8h.html#a1856aca1295ca11fd5e07c442694806c">SkUTF16_CountUnichars</a>(<span class="keyword">const</span> uint16_t utf16[],
<a name="l00089"></a>00089 <span class="keywordtype">int</span> numberOf16BitValues);
<a name="l00090"></a>00090 <span class="comment">// returns the current unichar and then moves past it (*p++)</span>
<a name="l00091"></a>00091 <a class="code" href="_sk_types_8h.html#a0b73f568570c6560e0a4f2713cb36d06">SkUnichar</a> <a class="code" href="_sk_utils_8h.html#ac620ec9eed1635bd6555645a945bbb52">SkUTF16_NextUnichar</a>(<span class="keyword">const</span> uint16_t**);
<a name="l00092"></a>00092 <span class="comment">// this guy backs up to the previus unichar value, and returns it (*--p)</span>
<a name="l00093"></a>00093 <a class="code" href="_sk_types_8h.html#a0b73f568570c6560e0a4f2713cb36d06">SkUnichar</a> <a class="code" href="_sk_utils_8h.html#acd921166099fd7c6c32c272bc5d20a00">SkUTF16_PrevUnichar</a>(<span class="keyword">const</span> uint16_t**);
<a name="l00094"></a>00094 <span class="keywordtype">size_t</span> <a class="code" href="_sk_utils_8h.html#a128bb1ac8320f3d7a23760b1fb7159d7">SkUTF16_FromUnichar</a>(<a class="code" href="_sk_types_8h.html#a0b73f568570c6560e0a4f2713cb36d06">SkUnichar</a> uni, uint16_t utf16[] = NULL);
<a name="l00095"></a>00095
<a name="l00096"></a>00096 <span class="keywordtype">size_t</span> <a class="code" href="_sk_utils_8h.html#a6562d10c22c9753af2484340e3450e2b">SkUTF16_ToUTF8</a>(<span class="keyword">const</span> uint16_t utf16[], <span class="keywordtype">int</span> numberOf16BitValues,
<a name="l00097"></a>00097 <span class="keywordtype">char</span> utf8[] = NULL);
<a name="l00098"></a>00098
<a name="l00100"></a>00100
<a name="l00101"></a><a class="code" href="class_sk_auto_trace.html">00101</a> <span class="keyword">class </span><a class="code" href="class_sk_auto_trace.html">SkAutoTrace</a> {
<a name="l00102"></a>00102 <span class="keyword">public</span>:
<a name="l00106"></a><a class="code" href="class_sk_auto_trace.html#af317b8496102275ac7a3d91409f58c8d">00106</a> <a class="code" href="class_sk_auto_trace.html#af317b8496102275ac7a3d91409f58c8d">SkAutoTrace</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> label[]) : fLabel(label) {
<a name="l00107"></a>00107 <a class="code" href="_sk_types_8h.html#a6ce8c418ee09f469724436386871c01e">SkDebugf</a>(<span class="stringliteral">&quot;--- trace: %s Enter\n&quot;</span>, fLabel);
<a name="l00108"></a>00108 }
<a name="l00109"></a><a class="code" href="class_sk_auto_trace.html#a7aa18722e14f1e827505f0499e9e836f">00109</a> <a class="code" href="class_sk_auto_trace.html#a7aa18722e14f1e827505f0499e9e836f">~SkAutoTrace</a>() {
<a name="l00110"></a>00110 <a class="code" href="_sk_types_8h.html#a6ce8c418ee09f469724436386871c01e">SkDebugf</a>(<span class="stringliteral">&quot;--- trace: %s Leave\n&quot;</span>, fLabel);
<a name="l00111"></a>00111 }
<a name="l00112"></a>00112 <span class="keyword">private</span>:
<a name="l00113"></a>00113 <span class="keyword">const</span> <span class="keywordtype">char</span>* fLabel;
<a name="l00114"></a>00114 };
<a name="l00115"></a>00115
<a name="l00117"></a>00117
<a name="l00118"></a><a class="code" href="class_sk_auto_memory_usage_probe.html">00118</a> <span class="keyword">class </span><a class="code" href="class_sk_auto_memory_usage_probe.html">SkAutoMemoryUsageProbe</a> {
<a name="l00119"></a>00119 <span class="keyword">public</span>:
<a name="l00125"></a>00125 <a class="code" href="class_sk_auto_memory_usage_probe.html#aafd2742127e724c232332a894e5407a8">SkAutoMemoryUsageProbe</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> label[]);
<a name="l00126"></a>00126 <a class="code" href="class_sk_auto_memory_usage_probe.html#aaae759521fe9d98f1aab49cfd4fcc2f1">~SkAutoMemoryUsageProbe</a>();
<a name="l00127"></a>00127 <span class="keyword">private</span>:
<a name="l00128"></a>00128 <span class="keyword">const</span> <span class="keywordtype">char</span>* fLabel;
<a name="l00129"></a>00129 <span class="keywordtype">size_t</span> fBytesAllocated;
<a name="l00130"></a>00130 };
<a name="l00131"></a>00131
<a name="l00132"></a>00132 <span class="preprocessor">#endif</span>
<a name="l00133"></a>00133 <span class="preprocessor"></span>
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Tue Oct 20 11:03:40 2009 for Skia by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>