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

Side by Side Diff: samplecode/SampleApp.cpp

Issue 1890923003: Several fixes for fp 16 rendering: (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Nicer looking clamp Created 4 years, 8 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 | « dm/DM.cpp ('k') | src/gpu/SkGpuDevice.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 #include "SampleApp.h" 8 #include "SampleApp.h"
9 9
10 #include "OverView.h" 10 #include "OverView.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 fCurRenderTarget = nullptr; 287 fCurRenderTarget = nullptr;
288 #endif 288 #endif
289 win->release(); 289 win->release();
290 fBackend = kNone_BackEndType; 290 fBackend = kNone_BackEndType;
291 } 291 }
292 292
293 SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win) override { 293 SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win) override {
294 #if SK_SUPPORT_GPU 294 #if SK_SUPPORT_GPU
295 if (IsGpuDeviceType(dType) && fCurContext) { 295 if (IsGpuDeviceType(dType) && fCurContext) {
296 SkSurfaceProps props(win->getSurfaceProps()); 296 SkSurfaceProps props(win->getSurfaceProps());
297 return SkSurface::MakeRenderTargetDirect(fCurRenderTarget, &props).r elease(); 297 if (kRGBA_F16_SkColorType == win->info().colorType()) {
298 // Need to make an off-screen F16 surface - the current render t arget is
299 // (probably) the wrong format.
300 return SkSurface::MakeRenderTarget(fCurContext, SkBudgeted::kNo, win->info(),
301 fMSAASampleCount, &props).rel ease();
302 } else {
303 return SkSurface::MakeRenderTargetDirect(fCurRenderTarget, &prop s).release();
304 }
298 } 305 }
299 #endif 306 #endif
300 return nullptr; 307 return nullptr;
301 } 308 }
302 309
303 void publishCanvas(SampleWindow::DeviceType dType, 310 void publishCanvas(SampleWindow::DeviceType dType,
304 SkCanvas* canvas, SampleWindow* win) override { 311 SkCanvas* canvas, SampleWindow* win) override {
305 #if SK_SUPPORT_GPU 312 #if SK_SUPPORT_GPU
306 if (fCurContext) { 313 if (fCurContext) {
307 // in case we have queued drawing calls 314 // in case we have queued drawing calls
308 fCurContext->flush(); 315 fCurContext->flush();
309 316
310 if (!IsGpuDeviceType(dType)) { 317 if (!IsGpuDeviceType(dType)) {
311 // need to send the raster bits to the (gpu) window 318 // need to send the raster bits to the (gpu) window
312 const SkBitmap& bm = win->getBitmap(); 319 const SkBitmap& bm = win->getBitmap();
313 fCurRenderTarget->writePixels(0, 0, bm.width(), bm.height(), 320 fCurRenderTarget->writePixels(0, 0, bm.width(), bm.height(),
314 SkImageInfo2GrPixelConfig(bm.colorT ype(), 321 SkImageInfo2GrPixelConfig(bm.colorT ype(),
315 bm.alphaT ype(), 322 bm.alphaT ype(),
316 bm.profil eType(), 323 bm.profil eType(),
317 *fCurCont ext->caps()), 324 *fCurCont ext->caps()),
318 bm.getPixels(), 325 bm.getPixels(),
319 bm.rowBytes(), 326 bm.rowBytes(),
320 GrContext::kFlushWrites_PixelOp); 327 GrContext::kFlushWrites_PixelOp);
328 } else if (kRGBA_F16_SkColorType == win->info().colorType()) {
329 SkBitmap bm;
330 bm.allocPixels(win->info());
331 canvas->readPixels(&bm, 0, 0);
332 fCurRenderTarget->writePixels(0, 0, bm.width(), bm.height(),
333 SkImageInfo2GrPixelConfig(bm.info( ),
334 *fCurCon text->caps()),
335 bm.getPixels(),
336 bm.rowBytes(),
337 GrContext::kFlushWrites_PixelOp);
321 } 338 }
322 } 339 }
323 #endif 340 #endif
324 341
325 win->present(); 342 win->present();
326 } 343 }
327 344
328 void windowSizeChanged(SampleWindow* win) override { 345 void windowSizeChanged(SampleWindow* win) override {
329 #if SK_SUPPORT_GPU 346 #if SK_SUPPORT_GPU
330 if (fCurContext) { 347 if (fCurContext) {
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 #ifdef SK_BUILD_FOR_MAC 2394 #ifdef SK_BUILD_FOR_MAC
2378 setenv("ANDROID_ROOT", "/android/device/data", 0); 2395 setenv("ANDROID_ROOT", "/android/device/data", 0);
2379 #endif 2396 #endif
2380 SkGraphics::Init(); 2397 SkGraphics::Init();
2381 SkEvent::Init(); 2398 SkEvent::Init();
2382 } 2399 }
2383 2400
2384 void application_term() { 2401 void application_term() {
2385 SkEvent::Term(); 2402 SkEvent::Term();
2386 } 2403 }
OLDNEW
« no previous file with comments | « dm/DM.cpp ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698