OLD | NEW |
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 #include "SampleApp.h" | 8 #include "SampleApp.h" |
9 | 9 |
10 #include "OverView.h" | 10 #include "OverView.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 fCurRenderTarget = nullptr; | 284 fCurRenderTarget = nullptr; |
285 #endif | 285 #endif |
286 win->release(); | 286 win->release(); |
287 fBackend = kNone_BackEndType; | 287 fBackend = kNone_BackEndType; |
288 } | 288 } |
289 | 289 |
290 SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win)
override { | 290 SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win)
override { |
291 #if SK_SUPPORT_GPU | 291 #if SK_SUPPORT_GPU |
292 if (IsGpuDeviceType(dType) && fCurContext) { | 292 if (IsGpuDeviceType(dType) && fCurContext) { |
293 SkSurfaceProps props(win->getSurfaceProps()); | 293 SkSurfaceProps props(win->getSurfaceProps()); |
294 return SkSurface::NewRenderTargetDirect(fCurRenderTarget, &props); | 294 return SkSurface::MakeRenderTargetDirect(fCurRenderTarget, &props).r
elease(); |
295 } | 295 } |
296 #endif | 296 #endif |
297 return nullptr; | 297 return nullptr; |
298 } | 298 } |
299 | 299 |
300 void publishCanvas(SampleWindow::DeviceType dType, | 300 void publishCanvas(SampleWindow::DeviceType dType, |
301 SkCanvas* canvas, SampleWindow* win) override { | 301 SkCanvas* canvas, SampleWindow* win) override { |
302 #if SK_SUPPORT_GPU | 302 #if SK_SUPPORT_GPU |
303 if (fCurContext) { | 303 if (fCurContext) { |
304 // in case we have queued drawing calls | 304 // in case we have queued drawing calls |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 } | 1059 } |
1060 | 1060 |
1061 SkSize tile = this->tileSize(); | 1061 SkSize tile = this->tileSize(); |
1062 | 1062 |
1063 if (kNo_Tiling == fTilingMode) { | 1063 if (kNo_Tiling == fTilingMode) { |
1064 this->INHERITED::draw(canvas); // no looping or surfaces needed | 1064 this->INHERITED::draw(canvas); // no looping or surfaces needed |
1065 } else { | 1065 } else { |
1066 const SkScalar w = SkScalarCeilToScalar(tile.width()); | 1066 const SkScalar w = SkScalarCeilToScalar(tile.width()); |
1067 const SkScalar h = SkScalarCeilToScalar(tile.height()); | 1067 const SkScalar h = SkScalarCeilToScalar(tile.height()); |
1068 SkImageInfo info = SkImageInfo::MakeN32Premul(SkScalarTruncToInt(w), SkS
calarTruncToInt(h)); | 1068 SkImageInfo info = SkImageInfo::MakeN32Premul(SkScalarTruncToInt(w), SkS
calarTruncToInt(h)); |
1069 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); | 1069 auto surface(canvas->makeSurface(info)); |
1070 SkCanvas* tileCanvas = surface->getCanvas(); | 1070 SkCanvas* tileCanvas = surface->getCanvas(); |
1071 | 1071 |
1072 for (SkScalar y = 0; y < height(); y += h) { | 1072 for (SkScalar y = 0; y < height(); y += h) { |
1073 for (SkScalar x = 0; x < width(); x += w) { | 1073 for (SkScalar x = 0; x < width(); x += w) { |
1074 SkAutoCanvasRestore acr(tileCanvas, true); | 1074 SkAutoCanvasRestore acr(tileCanvas, true); |
1075 tileCanvas->translate(-x, -y); | 1075 tileCanvas->translate(-x, -y); |
1076 tileCanvas->clear(0); | 1076 tileCanvas->clear(0); |
1077 this->INHERITED::draw(tileCanvas); | 1077 this->INHERITED::draw(tileCanvas); |
1078 surface->draw(canvas, x, y, nullptr); | 1078 surface->draw(canvas, x, y, nullptr); |
1079 } | 1079 } |
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2330 #ifdef SK_BUILD_FOR_MAC | 2330 #ifdef SK_BUILD_FOR_MAC |
2331 setenv("ANDROID_ROOT", "/android/device/data", 0); | 2331 setenv("ANDROID_ROOT", "/android/device/data", 0); |
2332 #endif | 2332 #endif |
2333 SkGraphics::Init(); | 2333 SkGraphics::Init(); |
2334 SkEvent::Init(); | 2334 SkEvent::Init(); |
2335 } | 2335 } |
2336 | 2336 |
2337 void application_term() { | 2337 void application_term() { |
2338 SkEvent::Term(); | 2338 SkEvent::Term(); |
2339 } | 2339 } |
OLD | NEW |