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

Side by Side Diff: include/core/SkTemplates.h

Issue 15941025: Add SkData::NewFromFD. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Remove an indentation level. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/core/SkOSFile.h ('k') | src/core/SkData.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkTemplates_DEFINED 10 #ifndef SkTemplates_DEFINED
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 * Returns a pointer to a D which comes byteOffset bytes after S. 57 * Returns a pointer to a D which comes byteOffset bytes after S.
58 */ 58 */
59 template <typename D, typename S> static D* SkTAddOffset(S* ptr, size_t byteOffs et) { 59 template <typename D, typename S> static D* SkTAddOffset(S* ptr, size_t byteOffs et) {
60 // The intermediate char* has the same const-ness as D as this produces bett er error messages. 60 // The intermediate char* has the same const-ness as D as this produces bett er error messages.
61 // This relies on the fact that reinterpret_cast can add constness, but cann ot remove it. 61 // This relies on the fact that reinterpret_cast can add constness, but cann ot remove it.
62 return reinterpret_cast<D*>( 62 return reinterpret_cast<D*>(
63 reinterpret_cast<typename SkTConstType<char, SkTIsConst<D>::value>::type *>(ptr) + byteOffset 63 reinterpret_cast<typename SkTConstType<char, SkTIsConst<D>::value>::type *>(ptr) + byteOffset
64 ); 64 );
65 } 65 }
66 66
67 /** Returns true if the source value 's' will fit in the destination type 'D'. * /
68 template <typename D, typename S> inline bool SkTFitsIn(S s) {
69 return static_cast<D>(s) == s;
70 }
71
67 /** \class SkAutoTCallVProc 72 /** \class SkAutoTCallVProc
68 73
69 Call a function when this goes out of scope. The template uses two 74 Call a function when this goes out of scope. The template uses two
70 parameters, the object, and a function that is to be called in the destructo r. 75 parameters, the object, and a function that is to be called in the destructo r.
71 If detach() is called, the object reference is set to null. If the object 76 If detach() is called, the object reference is set to null. If the object
72 reference is null when the destructor is called, we do not call the 77 reference is null when the destructor is called, we do not call the
73 function. 78 function.
74 */ 79 */
75 template <typename T, void (*P)(T*)> class SkAutoTCallVProc : SkNoncopyable { 80 template <typename T, void (*P)(T*)> class SkAutoTCallVProc : SkNoncopyable {
76 public: 81 public:
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 /** 431 /**
427 * Returns void* because this object does not initialize the 432 * Returns void* because this object does not initialize the
428 * memory. Use placement new for types that require a cons. 433 * memory. Use placement new for types that require a cons.
429 */ 434 */
430 void* get() { return fStorage.get(); } 435 void* get() { return fStorage.get(); }
431 private: 436 private:
432 SkAlignedSStorage<sizeof(T)*N> fStorage; 437 SkAlignedSStorage<sizeof(T)*N> fStorage;
433 }; 438 };
434 439
435 #endif 440 #endif
OLDNEW
« no previous file with comments | « include/core/SkOSFile.h ('k') | src/core/SkData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698