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

Side by Side Diff: components/font_service/public/cpp/mapped_font_file.cc

Issue 1923943002: Remove all uses of skia::RefPtr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/font_service/public/cpp/mapped_font_file.h" 5 #include "components/font_service/public/cpp/mapped_font_file.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
11 #include "skia/ext/refptr.h"
12 #include "skia/ext/skia_utils_base.h" 11 #include "skia/ext/skia_utils_base.h"
13 #include "third_party/skia/include/core/SkData.h" 12 #include "third_party/skia/include/core/SkData.h"
13 #include "third_party/skia/include/core/SkRefCnt.h"
14 #include "third_party/skia/include/core/SkStream.h" 14 #include "third_party/skia/include/core/SkStream.h"
15 15
16 namespace font_service { 16 namespace font_service {
17 namespace internal { 17 namespace internal {
18 18
19 MappedFontFile::MappedFontFile(uint32_t font_id) 19 MappedFontFile::MappedFontFile(uint32_t font_id)
20 : font_id_(font_id), observer_(nullptr) {} 20 : font_id_(font_id), observer_(nullptr) {}
21 21
22 bool MappedFontFile::Initialize(base::File file) { 22 bool MappedFontFile::Initialize(base::File file) {
23 base::ThreadRestrictions::ScopedAllowIO allow_mmap; 23 base::ThreadRestrictions::ScopedAllowIO allow_mmap;
24 return mapped_font_file_.Initialize(std::move(file)); 24 return mapped_font_file_.Initialize(std::move(file));
25 } 25 }
26 26
27 SkMemoryStream* MappedFontFile::CreateMemoryStream() { 27 SkMemoryStream* MappedFontFile::CreateMemoryStream() {
28 DCHECK(mapped_font_file_.IsValid()); 28 DCHECK(mapped_font_file_.IsValid());
29 auto data = skia::AdoptRef( 29 sk_sp<SkData> data =
30 SkData::NewWithProc(mapped_font_file_.data(), mapped_font_file_.length(), 30 SkData::MakeWithProc(mapped_font_file_.data(), mapped_font_file_.length(),
31 &MappedFontFile::ReleaseProc, this)); 31 &MappedFontFile::ReleaseProc, this);
32 if (!data) 32 if (!data)
33 return nullptr; 33 return nullptr;
34 AddRef(); 34 AddRef();
35 return new SkMemoryStream(data.get()); 35 return new SkMemoryStream(std::move(data));
36 } 36 }
37 37
38 MappedFontFile::~MappedFontFile() { 38 MappedFontFile::~MappedFontFile() {
39 if (observer_) 39 if (observer_)
40 observer_->OnMappedFontFileDestroyed(this); 40 observer_->OnMappedFontFileDestroyed(this);
41 } 41 }
42 42
43 // static 43 // static
44 void MappedFontFile::ReleaseProc(const void* ptr, void* context) { 44 void MappedFontFile::ReleaseProc(const void* ptr, void* context) {
45 base::ThreadRestrictions::ScopedAllowIO allow_munmap; 45 base::ThreadRestrictions::ScopedAllowIO allow_munmap;
46 static_cast<MappedFontFile*>(context)->Release(); 46 static_cast<MappedFontFile*>(context)->Release();
47 } 47 }
48 48
49 } // namespace internal 49 } // namespace internal
50 } // namespace font_service 50 } // namespace font_service
OLDNEW
« no previous file with comments | « blimp/client/feature/compositor/blimp_context_provider.h ('k') | printing/metafile_skia_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698