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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 2290903002: Change (Pass)RefPtr<SkXxx> into sk_sp<SkXxx>. (Closed)
Patch Set: Rebasing... Created 4 years, 3 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 /* 1 /*
2 * Copyright (c) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; 421 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback;
422 bool success = false; 422 bool success = false;
423 if (grContext) { 423 if (grContext) {
424 bool forceGpuResult = true; 424 bool forceGpuResult = true;
425 success = prepareTextureMailboxInternal(&textureMailbox, &releaseCallbac k, forceGpuResult); 425 success = prepareTextureMailboxInternal(&textureMailbox, &releaseCallbac k, forceGpuResult);
426 } 426 }
427 if (!success) { 427 if (!success) {
428 // If we can't get a mailbox, return an transparent black ImageBitmap. 428 // If we can't get a mailbox, return an transparent black ImageBitmap.
429 // The only situation this could happen is when two or more calls to tra nsferToImageBitmap are made back-to-back, or when the context gets lost. 429 // The only situation this could happen is when two or more calls to tra nsferToImageBitmap are made back-to-back, or when the context gets lost.
430 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(m_size.width() , m_size.height()); 430 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(m_size.width() , m_size.height());
431 return StaticBitmapImage::create(fromSkSp(surface->makeImageSnapshot())) ; 431 return StaticBitmapImage::create(surface->makeImageSnapshot());
432 } 432 }
433 433
434 DCHECK_EQ(m_size.width(), textureMailbox.size_in_pixels().width()); 434 DCHECK_EQ(m_size.width(), textureMailbox.size_in_pixels().width());
435 DCHECK_EQ(m_size.height(), textureMailbox.size_in_pixels().height()); 435 DCHECK_EQ(m_size.height(), textureMailbox.size_in_pixels().height());
436 436
437 // Make our own textureId that is a reference on the same texture backing be ing used as the front 437 // Make our own textureId that is a reference on the same texture backing be ing used as the front
438 // buffer (which was returned from PrepareTextureMailbox()). 438 // buffer (which was returned from PrepareTextureMailbox()).
439 // We do not need to wait on the sync token in |textureMailbox| since the ma ilbox was produced on 439 // We do not need to wait on the sync token in |textureMailbox| since the ma ilbox was produced on
440 // the same |m_gl| context that we are using here. Similarly, the |releaseCa llback| will run on 440 // the same |m_gl| context that we are using here. Similarly, the |releaseCa llback| will run on
441 // the same context so we don't need to send a sync token for this consume a ction back to it. 441 // the same context so we don't need to send a sync token for this consume a ction back to it.
(...skipping 22 matching lines...) Expand all
464 // We reuse the same mailbox name from above since our texture id was consum ed from it. 464 // We reuse the same mailbox name from above since our texture id was consum ed from it.
465 const auto& skImageMailbox = textureMailbox.mailbox(); 465 const auto& skImageMailbox = textureMailbox.mailbox();
466 // Use the sync token generated after producing the mailbox. Waiting for thi s before trying to use 466 // Use the sync token generated after producing the mailbox. Waiting for thi s before trying to use
467 // the mailbox with some other context will ensure it is valid. We wouldn't need to wait for the 467 // the mailbox with some other context will ensure it is valid. We wouldn't need to wait for the
468 // consume done in this function because the texture id it generated would o nly be valid for the 468 // consume done in this function because the texture id it generated would o nly be valid for the
469 // DrawingBuffer's context anyways. 469 // DrawingBuffer's context anyways.
470 const auto& skImageSyncToken = textureMailbox.sync_token(); 470 const auto& skImageSyncToken = textureMailbox.sync_token();
471 471
472 // TODO(xidachen): Create a small pool of recycled textures from ImageBitmap RenderingContext's 472 // TODO(xidachen): Create a small pool of recycled textures from ImageBitmap RenderingContext's
473 // transferFromImageBitmap, and try to use them in DrawingBuffer. 473 // transferFromImageBitmap, and try to use them in DrawingBuffer.
474 return AcceleratedStaticBitmapImage::create(fromSkSp(skImage), grContextRef, skImageMailbox, skImageSyncToken); 474 return AcceleratedStaticBitmapImage::create(std::move(skImage), grContextRef , skImageMailbox, skImageSyncToken);
475 } 475 }
476 476
477 DrawingBuffer::TextureParameters DrawingBuffer::chromiumImageTextureParameters() 477 DrawingBuffer::TextureParameters DrawingBuffer::chromiumImageTextureParameters()
478 { 478 {
479 #if OS(MACOSX) 479 #if OS(MACOSX)
480 // A CHROMIUM_image backed texture requires a specialized set of parameters 480 // A CHROMIUM_image backed texture requires a specialized set of parameters
481 // on OSX. 481 // on OSX.
482 TextureParameters parameters; 482 TextureParameters parameters;
483 parameters.target = GC3D_TEXTURE_RECTANGLE_ARB; 483 parameters.target = GC3D_TEXTURE_RECTANGLE_ARB;
484 484
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 1228
1229 void DrawingBuffer::restoreTextureBindings() 1229 void DrawingBuffer::restoreTextureBindings()
1230 { 1230 {
1231 // This class potentially modifies the bindings for GL_TEXTURE_2D and 1231 // This class potentially modifies the bindings for GL_TEXTURE_2D and
1232 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since 1232 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since
1233 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. 1233 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE.
1234 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); 1234 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding);
1235 } 1235 }
1236 1236
1237 } // namespace blink 1237 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698