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

Side by Side Diff: cc/gl_renderer.cc

Issue 11412255: cc: Use skia::RefPtr in place of raw pointers and SkAutoTUnref. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add webkit Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/gl_renderer.h" 5 #include "cc/gl_renderer.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 renderer->context()->flush(); 393 renderer->context()->flush();
394 394
395 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc eTexture->id()); 395 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc eTexture->id());
396 396
397 // Wrap the source texture in a Ganesh platform texture. 397 // Wrap the source texture in a Ganesh platform texture.
398 GrPlatformTextureDesc platformTextureDescription; 398 GrPlatformTextureDesc platformTextureDescription;
399 platformTextureDescription.fWidth = sourceTexture->size().width(); 399 platformTextureDescription.fWidth = sourceTexture->size().width();
400 platformTextureDescription.fHeight = sourceTexture->size().height(); 400 platformTextureDescription.fHeight = sourceTexture->size().height();
401 platformTextureDescription.fConfig = kSkia8888_GrPixelConfig; 401 platformTextureDescription.fConfig = kSkia8888_GrPixelConfig;
402 platformTextureDescription.fTextureHandle = lock.textureId(); 402 platformTextureDescription.fTextureHandle = lock.textureId();
403 SkAutoTUnref<GrTexture> texture(grContext->createPlatformTexture(platformTex tureDescription)); 403 skia::RefPtr<GrTexture> texture = skia::AdoptRef(grContext->createPlatformTe xture(platformTextureDescription));
404 404
405 // Place the platform texture inside an SkBitmap. 405 // Place the platform texture inside an SkBitmap.
406 SkBitmap source; 406 SkBitmap source;
407 source.setConfig(SkBitmap::kARGB_8888_Config, sourceTexture->size().width(), sourceTexture->size().height()); 407 source.setConfig(SkBitmap::kARGB_8888_Config, sourceTexture->size().width(), sourceTexture->size().height());
408 source.setPixelRef(new SkGrPixelRef(texture.get()))->unref(); 408 skia::RefPtr<SkGrPixelRef> pixelRef = skia::AdoptRef(new SkGrPixelRef(textur e.get()));
409 source.setPixelRef(pixelRef.get());
409 410
410 // Create a scratch texture for backing store. 411 // Create a scratch texture for backing store.
411 GrTextureDesc desc; 412 GrTextureDesc desc;
412 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; 413 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
413 desc.fSampleCnt = 0; 414 desc.fSampleCnt = 0;
414 desc.fWidth = source.width(); 415 desc.fWidth = source.width();
415 desc.fHeight = source.height(); 416 desc.fHeight = source.height();
416 desc.fConfig = kSkia8888_GrPixelConfig; 417 desc.fConfig = kSkia8888_GrPixelConfig;
417 GrAutoScratchTexture scratchTexture(grContext, desc, GrContext::kExact_Scrat chTexMatch); 418 GrAutoScratchTexture scratchTexture(grContext, desc, GrContext::kExact_Scrat chTexMatch);
418 SkAutoTUnref<GrTexture> backingStore(scratchTexture.detach()); 419 skia::RefPtr<GrTexture> backingStore = skia::AdoptRef(scratchTexture.detach( ));
419 420
420 // Create a device and canvas using that backing store. 421 // Create a device and canvas using that backing store.
421 SkGpuDevice device(grContext, backingStore.get()); 422 SkGpuDevice device(grContext, backingStore.get());
422 SkCanvas canvas(&device); 423 SkCanvas canvas(&device);
423 424
424 // Draw the source bitmap through the filter to the canvas. 425 // Draw the source bitmap through the filter to the canvas.
425 SkPaint paint; 426 SkPaint paint;
426 paint.setImageFilter(filter); 427 paint.setImageFilter(filter);
427 canvas.clear(0x0); 428 canvas.clear(0x0);
428 canvas.drawSprite(source, 0, 0, &paint); 429 canvas.drawSprite(source, 0, 0, &paint);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 527
527 gfx::Transform contentsDeviceTransformInverse = MathUtil::inverse(contentsDe viceTransform); 528 gfx::Transform contentsDeviceTransformInverse = MathUtil::inverse(contentsDe viceTransform);
528 scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters( 529 scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters(
529 frame, quad, renderPass->background_filters, 530 frame, quad, renderPass->background_filters,
530 contentsDeviceTransform, contentsDeviceTransformInverse); 531 contentsDeviceTransform, contentsDeviceTransformInverse);
531 532
532 // FIXME: Cache this value so that we don't have to do it for both the surfa ce and its replica. 533 // FIXME: Cache this value so that we don't have to do it for both the surfa ce and its replica.
533 // Apply filters to the contents texture. 534 // Apply filters to the contents texture.
534 SkBitmap filterBitmap; 535 SkBitmap filterBitmap;
535 if (renderPass->filter) { 536 if (renderPass->filter) {
536 filterBitmap = applyImageFilter(this, renderPass->filter, contentsTextur e, m_client->hasImplThread()); 537 filterBitmap = applyImageFilter(this, renderPass->filter.get(), contents Texture, m_client->hasImplThread());
537 } else { 538 } else {
538 filterBitmap = applyFilters(this, renderPass->filters, contentsTexture, m_client->hasImplThread()); 539 filterBitmap = applyFilters(this, renderPass->filters, contentsTexture, m_client->hasImplThread());
539 } 540 }
540 scoped_ptr<ResourceProvider::ScopedReadLockGL> contentsResourceLock; 541 scoped_ptr<ResourceProvider::ScopedReadLockGL> contentsResourceLock;
541 unsigned contentsTextureId = 0; 542 unsigned contentsTextureId = 0;
542 if (filterBitmap.getTexture()) { 543 if (filterBitmap.getTexture()) {
543 GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTextur e()); 544 GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTextur e());
544 contentsTextureId = texture->getTextureHandle(); 545 contentsTextureId = texture->getTextureHandle();
545 } else { 546 } else {
546 contentsResourceLock = make_scoped_ptr(new ResourceProvider::ScopedReadL ockGL(m_resourceProvider, contentsTexture->id())); 547 contentsResourceLock = make_scoped_ptr(new ResourceProvider::ScopedReadL ockGL(m_resourceProvider, contentsTexture->id()));
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 1626
1626 releaseRenderPassTextures(); 1627 releaseRenderPassTextures();
1627 } 1628 }
1628 1629
1629 bool GLRenderer::isContextLost() 1630 bool GLRenderer::isContextLost()
1630 { 1631 {
1631 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); 1632 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR);
1632 } 1633 }
1633 1634
1634 } // namespace cc 1635 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698