OLD | NEW |
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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 renderer->context()->flush(); | 394 renderer->context()->flush(); |
395 | 395 |
396 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc
eTexture->id()); | 396 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc
eTexture->id()); |
397 | 397 |
398 // Wrap the source texture in a Ganesh platform texture. | 398 // Wrap the source texture in a Ganesh platform texture. |
399 GrPlatformTextureDesc platformTextureDescription; | 399 GrPlatformTextureDesc platformTextureDescription; |
400 platformTextureDescription.fWidth = sourceTexture->size().width(); | 400 platformTextureDescription.fWidth = sourceTexture->size().width(); |
401 platformTextureDescription.fHeight = sourceTexture->size().height(); | 401 platformTextureDescription.fHeight = sourceTexture->size().height(); |
402 platformTextureDescription.fConfig = kSkia8888_GrPixelConfig; | 402 platformTextureDescription.fConfig = kSkia8888_GrPixelConfig; |
403 platformTextureDescription.fTextureHandle = lock.textureId(); | 403 platformTextureDescription.fTextureHandle = lock.textureId(); |
404 SkAutoTUnref<GrTexture> texture(grContext->createPlatformTexture(platformTex
tureDescription)); | 404 skia::RefPtr<GrTexture> texture = skia::AdoptRef(grContext->createPlatformTe
xture(platformTextureDescription)); |
405 | 405 |
406 // Place the platform texture inside an SkBitmap. | 406 // Place the platform texture inside an SkBitmap. |
407 SkBitmap source; | 407 SkBitmap source; |
408 source.setConfig(SkBitmap::kARGB_8888_Config, sourceTexture->size().width(),
sourceTexture->size().height()); | 408 source.setConfig(SkBitmap::kARGB_8888_Config, sourceTexture->size().width(),
sourceTexture->size().height()); |
409 source.setPixelRef(new SkGrPixelRef(texture.get()))->unref(); | 409 skia::RefPtr<SkGrPixelRef> pixelRef = skia::AdoptRef(new SkGrPixelRef(textur
e.get())); |
| 410 source.setPixelRef(pixelRef.get()); |
410 | 411 |
411 // Create a scratch texture for backing store. | 412 // Create a scratch texture for backing store. |
412 GrTextureDesc desc; | 413 GrTextureDesc desc; |
413 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; | 414 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; |
414 desc.fSampleCnt = 0; | 415 desc.fSampleCnt = 0; |
415 desc.fWidth = source.width(); | 416 desc.fWidth = source.width(); |
416 desc.fHeight = source.height(); | 417 desc.fHeight = source.height(); |
417 desc.fConfig = kSkia8888_GrPixelConfig; | 418 desc.fConfig = kSkia8888_GrPixelConfig; |
418 GrAutoScratchTexture scratchTexture(grContext, desc, GrContext::kExact_Scrat
chTexMatch); | 419 GrAutoScratchTexture scratchTexture(grContext, desc, GrContext::kExact_Scrat
chTexMatch); |
419 SkAutoTUnref<GrTexture> backingStore(scratchTexture.detach()); | 420 skia::RefPtr<GrTexture> backingStore = skia::AdoptRef(scratchTexture.detach(
)); |
420 | 421 |
421 // Create a device and canvas using that backing store. | 422 // Create a device and canvas using that backing store. |
422 SkGpuDevice device(grContext, backingStore.get()); | 423 SkGpuDevice device(grContext, backingStore.get()); |
423 SkCanvas canvas(&device); | 424 SkCanvas canvas(&device); |
424 | 425 |
425 // Draw the source bitmap through the filter to the canvas. | 426 // Draw the source bitmap through the filter to the canvas. |
426 SkPaint paint; | 427 SkPaint paint; |
427 paint.setImageFilter(filter); | 428 paint.setImageFilter(filter); |
428 canvas.clear(0x0); | 429 canvas.clear(0x0); |
429 canvas.drawSprite(source, 0, 0, &paint); | 430 canvas.drawSprite(source, 0, 0, &paint); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 | 528 |
528 gfx::Transform contentsDeviceTransformInverse = MathUtil::inverse(contentsDe
viceTransform); | 529 gfx::Transform contentsDeviceTransformInverse = MathUtil::inverse(contentsDe
viceTransform); |
529 scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters( | 530 scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters( |
530 frame, quad, renderPass->background_filters, | 531 frame, quad, renderPass->background_filters, |
531 contentsDeviceTransform, contentsDeviceTransformInverse); | 532 contentsDeviceTransform, contentsDeviceTransformInverse); |
532 | 533 |
533 // FIXME: Cache this value so that we don't have to do it for both the surfa
ce and its replica. | 534 // FIXME: Cache this value so that we don't have to do it for both the surfa
ce and its replica. |
534 // Apply filters to the contents texture. | 535 // Apply filters to the contents texture. |
535 SkBitmap filterBitmap; | 536 SkBitmap filterBitmap; |
536 if (renderPass->filter) { | 537 if (renderPass->filter) { |
537 filterBitmap = applyImageFilter(this, renderPass->filter, contentsTextur
e, m_client->hasImplThread()); | 538 filterBitmap = applyImageFilter(this, renderPass->filter.get(), contents
Texture, m_client->hasImplThread()); |
538 } else { | 539 } else { |
539 filterBitmap = applyFilters(this, renderPass->filters, contentsTexture,
m_client->hasImplThread()); | 540 filterBitmap = applyFilters(this, renderPass->filters, contentsTexture,
m_client->hasImplThread()); |
540 } | 541 } |
541 scoped_ptr<ResourceProvider::ScopedReadLockGL> contentsResourceLock; | 542 scoped_ptr<ResourceProvider::ScopedReadLockGL> contentsResourceLock; |
542 unsigned contentsTextureId = 0; | 543 unsigned contentsTextureId = 0; |
543 if (filterBitmap.getTexture()) { | 544 if (filterBitmap.getTexture()) { |
544 GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTextur
e()); | 545 GrTexture* texture = reinterpret_cast<GrTexture*>(filterBitmap.getTextur
e()); |
545 contentsTextureId = texture->getTextureHandle(); | 546 contentsTextureId = texture->getTextureHandle(); |
546 } else { | 547 } else { |
547 contentsResourceLock = make_scoped_ptr(new ResourceProvider::ScopedReadL
ockGL(m_resourceProvider, contentsTexture->id())); | 548 contentsResourceLock = make_scoped_ptr(new ResourceProvider::ScopedReadL
ockGL(m_resourceProvider, contentsTexture->id())); |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 | 1754 |
1754 releaseRenderPassTextures(); | 1755 releaseRenderPassTextures(); |
1755 } | 1756 } |
1756 | 1757 |
1757 bool GLRenderer::isContextLost() | 1758 bool GLRenderer::isContextLost() |
1758 { | 1759 { |
1759 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1760 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1760 } | 1761 } |
1761 | 1762 |
1762 } // namespace cc | 1763 } // namespace cc |
OLD | NEW |