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

Side by Side Diff: src/image/SkSurface_Base.h

Issue 1810813003: update callsites for Make image factories (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: start to take advantage of sk_sp drawImage Created 4 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 | « src/image/SkSurface.cpp ('k') | src/image/SkSurface_Gpu.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 2012 Google Inc. 2 * Copyright 2012 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 #ifndef SkSurface_Base_DEFINED 8 #ifndef SkSurface_Base_DEFINED
9 #define SkSurface_Base_DEFINED 9 #define SkSurface_Base_DEFINED
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 * Called only when we _didn't_ copy-on-write; we assume the copies start m utable. 74 * Called only when we _didn't_ copy-on-write; we assume the copies start m utable.
75 */ 75 */
76 virtual void onRestoreBackingMutability() {} 76 virtual void onRestoreBackingMutability() {}
77 77
78 /** 78 /**
79 * Issue any pending surface IO to the current backend 3D API and resolve an y surface MSAA. 79 * Issue any pending surface IO to the current backend 3D API and resolve an y surface MSAA.
80 */ 80 */
81 virtual void onPrepareForExternalIO() {} 81 virtual void onPrepareForExternalIO() {}
82 82
83 inline SkCanvas* getCachedCanvas(); 83 inline SkCanvas* getCachedCanvas();
84 inline SkImage* refCachedImage(SkBudgeted, ForceUnique); 84 inline sk_sp<SkImage> refCachedImage(SkBudgeted, ForceUnique);
85 85
86 bool hasCachedImage() const { return fCachedImage != nullptr; } 86 bool hasCachedImage() const { return fCachedImage != nullptr; }
87 87
88 // called by SkSurface to compute a new genID 88 // called by SkSurface to compute a new genID
89 uint32_t newGenerationID(); 89 uint32_t newGenerationID();
90 90
91 private: 91 private:
92 SkCanvas* fCachedCanvas; 92 SkCanvas* fCachedCanvas;
93 SkImage* fCachedImage; 93 SkImage* fCachedImage;
94 94
(...skipping 12 matching lines...) Expand all
107 SkCanvas* SkSurface_Base::getCachedCanvas() { 107 SkCanvas* SkSurface_Base::getCachedCanvas() {
108 if (nullptr == fCachedCanvas) { 108 if (nullptr == fCachedCanvas) {
109 fCachedCanvas = this->onNewCanvas(); 109 fCachedCanvas = this->onNewCanvas();
110 if (fCachedCanvas) { 110 if (fCachedCanvas) {
111 fCachedCanvas->setSurfaceBase(this); 111 fCachedCanvas->setSurfaceBase(this);
112 } 112 }
113 } 113 }
114 return fCachedCanvas; 114 return fCachedCanvas;
115 } 115 }
116 116
117 SkImage* SkSurface_Base::refCachedImage(SkBudgeted budgeted, ForceUnique unique) { 117 sk_sp<SkImage> SkSurface_Base::refCachedImage(SkBudgeted budgeted, ForceUnique u nique) {
118 SkImage* snap = fCachedImage; 118 SkImage* snap = fCachedImage;
119 if (kYes_ForceUnique == unique && snap && !snap->unique()) { 119 if (kYes_ForceUnique == unique && snap && !snap->unique()) {
120 snap = nullptr; 120 snap = nullptr;
121 } 121 }
122 if (snap) { 122 if (snap) {
123 return SkRef(snap); 123 return sk_ref_sp(snap);
124 } 124 }
125 ForceCopyMode fcm = (kYes_ForceUnique == unique) ? kYes_ForceCopyMode : 125 ForceCopyMode fcm = (kYes_ForceUnique == unique) ? kYes_ForceCopyMode :
126 kNo_ForceCopyMode; 126 kNo_ForceCopyMode;
127 snap = this->onNewImageSnapshot(budgeted, fcm); 127 snap = this->onNewImageSnapshot(budgeted, fcm);
128 if (kNo_ForceUnique == unique) { 128 if (kNo_ForceUnique == unique) {
129 SkASSERT(!fCachedImage); 129 SkASSERT(!fCachedImage);
130 fCachedImage = SkSafeRef(snap); 130 fCachedImage = SkSafeRef(snap);
131 } 131 }
132 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this); 132 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this);
133 return snap; 133 return sk_sp<SkImage>(snap);
134 } 134 }
135 135
136 #endif 136 #endif
OLDNEW
« no previous file with comments | « src/image/SkSurface.cpp ('k') | src/image/SkSurface_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698