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

Side by Side Diff: src/ports/SkOSFile_win.cpp

Issue 198643004: Fixed cross compilation with mingw. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Patchset with AUTHORS change Created 6 years, 9 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
« no previous file with comments | « include/core/SkPostConfig.h ('k') | src/utils/win/SkHRESULT.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 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkOSFile.h" 8 #include "SkOSFile.h"
9 9
10 #include "SkTFitsIn.h" 10 #include "SkTFitsIn.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 bool sk_fidentical(SkFILE* a, SkFILE* b) { 45 bool sk_fidentical(SkFILE* a, SkFILE* b) {
46 SkFILEID aID, bID; 46 SkFILEID aID, bID;
47 return sk_ino(a, &aID) && sk_ino(b, &bID) 47 return sk_ino(a, &aID) && sk_ino(b, &bID)
48 && aID.fLsbSize == bID.fLsbSize 48 && aID.fLsbSize == bID.fLsbSize
49 && aID.fMsbSize == bID.fMsbSize 49 && aID.fMsbSize == bID.fMsbSize
50 && aID.fVolume == bID.fVolume; 50 && aID.fVolume == bID.fVolume;
51 } 51 }
52 52
53 template <typename HandleType, HandleType InvalidValue, BOOL (WINAPI * Close)(Ha ndleType)> 53 class SkAutoNullKernelHandle : SkNoncopyable {
54 class SkAutoTHandle : SkNoncopyable {
55 public: 54 public:
56 SkAutoTHandle(HandleType handle) : fHandle(handle) { } 55 SkAutoNullKernelHandle(const HANDLE handle) : fHandle(handle) { }
57 ~SkAutoTHandle() { Close(fHandle); } 56 ~SkAutoNullKernelHandle() { CloseHandle(fHandle); }
58 operator HandleType() { return fHandle; } 57 operator HANDLE() const { return fHandle; }
59 bool isValid() { return InvalidValue != fHandle; } 58 bool isValid() const { return NULL != fHandle; }
60 private: 59 private:
61 HandleType fHandle; 60 HANDLE fHandle;
62 }; 61 };
63 typedef SkAutoTHandle<HANDLE, INVALID_HANDLE_VALUE, CloseHandle> SkAutoWinFile; 62 typedef SkAutoNullKernelHandle SkAutoWinMMap;
64 typedef SkAutoTHandle<HANDLE, NULL, CloseHandle> SkAutoWinMMap;
65 63
66 void sk_fmunmap(const void* addr, size_t) { 64 void sk_fmunmap(const void* addr, size_t) {
67 UnmapViewOfFile(addr); 65 UnmapViewOfFile(addr);
68 } 66 }
69 67
70 void* sk_fdmmap(int fileno, size_t* length) { 68 void* sk_fdmmap(int fileno, size_t* length) {
71 HANDLE file = (HANDLE)_get_osfhandle(fileno); 69 HANDLE file = (HANDLE)_get_osfhandle(fileno);
72 if (INVALID_HANDLE_VALUE == file) { 70 if (INVALID_HANDLE_VALUE == file) {
73 return NULL; 71 return NULL;
74 } 72 }
(...skipping 29 matching lines...) Expand all
104 } 102 }
105 103
106 void* sk_fmmap(SkFILE* f, size_t* length) { 104 void* sk_fmmap(SkFILE* f, size_t* length) {
107 int fileno = sk_fileno(f); 105 int fileno = sk_fileno(f);
108 if (fileno < 0) { 106 if (fileno < 0) {
109 return NULL; 107 return NULL;
110 } 108 }
111 109
112 return sk_fdmmap(fileno, length); 110 return sk_fdmmap(fileno, length);
113 } 111 }
OLDNEW
« no previous file with comments | « include/core/SkPostConfig.h ('k') | src/utils/win/SkHRESULT.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698