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

Side by Side Diff: src/views/mac/SkNSView.mm

Issue 2178353005: Remove use of MakeRenderTargetDirect from view system (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix Mac Created 4 years, 4 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/views/SkWindow.cpp ('k') | tests/ApplyGammaTest.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 2011 Google Inc. 2 * Copyright 2011 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 #import "SkNSView.h" 8 #import "SkNSView.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkSurface.h" 10 #include "SkSurface.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 - (void)freeNativeWind { 127 - (void)freeNativeWind {
128 delete fWind; 128 delete fWind;
129 fWind = nil; 129 fWind = nil;
130 } 130 }
131 131
132 //////////////////////////////////////////////////////////////////////////////// 132 ////////////////////////////////////////////////////////////////////////////////
133 133
134 - (void)drawSkia { 134 - (void)drawSkia {
135 fRedrawRequestPending = false; 135 fRedrawRequestPending = false;
136 if (fWind) { 136 if (fWind) {
137 SkAutoTUnref<SkSurface> surface(fWind->createSurface()); 137 sk_sp<SkSurface> surface(fWind->makeSurface());
138 fWind->draw(surface->getCanvas()); 138 fWind->draw(surface->getCanvas());
139 #ifdef FORCE_REDRAW 139 #ifdef FORCE_REDRAW
140 fWind->inval(NULL); 140 fWind->inval(NULL);
141 #endif 141 #endif
142 } 142 }
143 } 143 }
144 144
145 - (void)setSkTitle:(const char *)title { 145 - (void)setSkTitle:(const char *)title {
146 self.fTitle = [NSString stringWithUTF8String:title]; 146 self.fTitle = [NSString stringWithUTF8String:title];
147 [[self window] setTitle:self.fTitle]; 147 [[self window] setTitle:self.fTitle];
(...skipping 16 matching lines...) Expand all
164 if (!fRedrawRequestPending) { 164 if (!fRedrawRequestPending) {
165 fRedrawRequestPending = true; 165 fRedrawRequestPending = true;
166 [self setNeedsDisplay:YES]; 166 [self setNeedsDisplay:YES];
167 [self performSelector:@selector(drawSkia) withObject:nil afterDelay:0]; 167 [self performSelector:@selector(drawSkia) withObject:nil afterDelay:0];
168 } 168 }
169 } 169 }
170 /////////////////////////////////////////////////////////////////////////////// 170 ///////////////////////////////////////////////////////////////////////////////
171 171
172 #include "SkKey.h" 172 #include "SkKey.h"
173 enum { 173 enum {
174 » SK_MacReturnKey»» = 36, 174 SK_MacReturnKey» » = 36,
175 » SK_MacDeleteKey»» = 51, 175 SK_MacDeleteKey» » = 51,
176 » SK_MacEndKey» » = 119, 176 SK_MacEndKey» » = 119,
177 » SK_MacLeftKey» » = 123, 177 SK_MacLeftKey» » = 123,
178 » SK_MacRightKey» » = 124, 178 SK_MacRightKey» » = 124,
179 » SK_MacDownKey» » = 125, 179 SK_MacDownKey» » = 125,
180 » SK_MacUpKey» » » = 126, 180 SK_MacUpKey»» » = 126,
181 SK_Mac0Key = 0x52, 181 SK_Mac0Key = 0x52,
182 SK_Mac1Key = 0x53, 182 SK_Mac1Key = 0x53,
183 SK_Mac2Key = 0x54, 183 SK_Mac2Key = 0x54,
184 SK_Mac3Key = 0x55, 184 SK_Mac3Key = 0x55,
185 SK_Mac4Key = 0x56, 185 SK_Mac4Key = 0x56,
186 SK_Mac5Key = 0x57, 186 SK_Mac5Key = 0x57,
187 SK_Mac6Key = 0x58, 187 SK_Mac6Key = 0x58,
188 SK_Mac7Key = 0x59, 188 SK_Mac7Key = 0x59,
189 SK_Mac8Key = 0x5b, 189 SK_Mac8Key = 0x5b,
190 SK_Mac9Key = 0x5c 190 SK_Mac9Key = 0x5c
191 }; 191 };
192 192
193 static SkKey raw2key(UInt32 raw) 193 static SkKey raw2key(UInt32 raw)
194 { 194 {
195 » static const struct { 195 static const struct {
196 » » UInt32 fRaw; 196 UInt32 fRaw;
197 » » SkKey fKey; 197 SkKey fKey;
198 » } gKeys[] = { 198 } gKeys[] = {
199 » » { SK_MacUpKey,» » kUp_SkKey» » }, 199 { SK_MacUpKey,» » kUp_SkKey» » },
200 » » { SK_MacDownKey,» kDown_SkKey» » }, 200 { SK_MacDownKey,» kDown_SkKey» » },
201 » » { SK_MacLeftKey,» kLeft_SkKey» » }, 201 { SK_MacLeftKey,» kLeft_SkKey» » },
202 » » { SK_MacRightKey, kRight_SkKey» }, 202 { SK_MacRightKey, kRight_SkKey» },
203 » » { SK_MacReturnKey, kOK_SkKey» » }, 203 { SK_MacReturnKey, kOK_SkKey» » },
204 » » { SK_MacDeleteKey, kBack_SkKey»» }, 204 { SK_MacDeleteKey, kBack_SkKey»» },
205 » » { SK_MacEndKey,»» kEnd_SkKey» » }, 205 { SK_MacEndKey,»» kEnd_SkKey» » },
206 { SK_Mac0Key, k0_SkKey }, 206 { SK_Mac0Key, k0_SkKey },
207 { SK_Mac1Key, k1_SkKey }, 207 { SK_Mac1Key, k1_SkKey },
208 { SK_Mac2Key, k2_SkKey }, 208 { SK_Mac2Key, k2_SkKey },
209 { SK_Mac3Key, k3_SkKey }, 209 { SK_Mac3Key, k3_SkKey },
210 { SK_Mac4Key, k4_SkKey }, 210 { SK_Mac4Key, k4_SkKey },
211 { SK_Mac5Key, k5_SkKey }, 211 { SK_Mac5Key, k5_SkKey },
212 { SK_Mac6Key, k6_SkKey }, 212 { SK_Mac6Key, k6_SkKey },
213 { SK_Mac7Key, k7_SkKey }, 213 { SK_Mac7Key, k7_SkKey },
214 { SK_Mac8Key, k8_SkKey }, 214 { SK_Mac8Key, k8_SkKey },
215 { SK_Mac9Key, k9_SkKey } 215 { SK_Mac9Key, k9_SkKey }
216 » }; 216 };
217 217
218 » for (unsigned i = 0; i < SK_ARRAY_COUNT(gKeys); i++) 218 for (unsigned i = 0; i < SK_ARRAY_COUNT(gKeys); i++)
219 » » if (gKeys[i].fRaw == raw) 219 if (gKeys[i].fRaw == raw)
220 » » » return gKeys[i].fKey; 220 return gKeys[i].fKey;
221 » return kNONE_SkKey; 221 return kNONE_SkKey;
222 } 222 }
223 223
224 - (void)keyDown:(NSEvent *)event { 224 - (void)keyDown:(NSEvent *)event {
225 if (NULL == fWind) 225 if (NULL == fWind)
226 return; 226 return;
227 227
228 SkKey key = raw2key([event keyCode]); 228 SkKey key = raw2key([event keyCode]);
229 if (kNONE_SkKey != key) 229 if (kNONE_SkKey != key)
230 fWind->handleKey(key); 230 fWind->handleKey(key);
231 else{ 231 else{
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 } 421 }
422 422
423 - (void)setVSync:(bool)enable { 423 - (void)setVSync:(bool)enable {
424 if (fGLContext) { 424 if (fGLContext) {
425 GLint interval = enable ? 1 : 0; 425 GLint interval = enable ? 1 : 0;
426 CGLContextObj ctx = (CGLContextObj)[fGLContext CGLContextObj]; 426 CGLContextObj ctx = (CGLContextObj)[fGLContext CGLContextObj];
427 CGLSetParameter(ctx, kCGLCPSwapInterval, &interval); 427 CGLSetParameter(ctx, kCGLCPSwapInterval, &interval);
428 } 428 }
429 } 429 }
430 @end 430 @end
OLDNEW
« no previous file with comments | « src/views/SkWindow.cpp ('k') | tests/ApplyGammaTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698