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 <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 renderer->context()->flush(); | 415 renderer->context()->flush(); |
416 | 416 |
417 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc
eTexture->id()); | 417 ResourceProvider::ScopedWriteLockGL lock(renderer->resourceProvider(), sourc
eTexture->id()); |
418 | 418 |
419 // Wrap the source texture in a Ganesh platform texture. | 419 // Wrap the source texture in a Ganesh platform texture. |
420 GrBackendTextureDesc backendTextureDescription; | 420 GrBackendTextureDesc backendTextureDescription; |
421 backendTextureDescription.fWidth = sourceTexture->size().width(); | 421 backendTextureDescription.fWidth = sourceTexture->size().width(); |
422 backendTextureDescription.fHeight = sourceTexture->size().height(); | 422 backendTextureDescription.fHeight = sourceTexture->size().height(); |
423 backendTextureDescription.fConfig = kSkia8888_GrPixelConfig; | 423 backendTextureDescription.fConfig = kSkia8888_GrPixelConfig; |
424 backendTextureDescription.fTextureHandle = lock.textureId(); | 424 backendTextureDescription.fTextureHandle = lock.textureId(); |
| 425 backendTextureDescription.fOrigin = kTopLeft_GrSurfaceOrigin; |
425 skia::RefPtr<GrTexture> texture = skia::AdoptRef(grContext->wrapBackendTextu
re(backendTextureDescription)); | 426 skia::RefPtr<GrTexture> texture = skia::AdoptRef(grContext->wrapBackendTextu
re(backendTextureDescription)); |
426 | 427 |
427 // Place the platform texture inside an SkBitmap. | 428 // Place the platform texture inside an SkBitmap. |
428 SkBitmap source; | 429 SkBitmap source; |
429 source.setConfig(SkBitmap::kARGB_8888_Config, sourceTexture->size().width(),
sourceTexture->size().height()); | 430 source.setConfig(SkBitmap::kARGB_8888_Config, sourceTexture->size().width(),
sourceTexture->size().height()); |
430 skia::RefPtr<SkGrPixelRef> pixelRef = skia::AdoptRef(new SkGrPixelRef(textur
e.get())); | 431 skia::RefPtr<SkGrPixelRef> pixelRef = skia::AdoptRef(new SkGrPixelRef(textur
e.get())); |
431 source.setPixelRef(pixelRef.get()); | 432 source.setPixelRef(pixelRef.get()); |
432 | 433 |
433 // Create a scratch texture for backing store. | 434 // Create a scratch texture for backing store. |
434 GrTextureDesc desc; | 435 GrTextureDesc desc; |
435 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; | 436 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; |
436 desc.fSampleCnt = 0; | 437 desc.fSampleCnt = 0; |
437 desc.fWidth = source.width(); | 438 desc.fWidth = source.width(); |
438 desc.fHeight = source.height(); | 439 desc.fHeight = source.height(); |
439 desc.fConfig = kSkia8888_GrPixelConfig; | 440 desc.fConfig = kSkia8888_GrPixelConfig; |
| 441 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
440 GrAutoScratchTexture scratchTexture(grContext, desc, GrContext::kExact_Scrat
chTexMatch); | 442 GrAutoScratchTexture scratchTexture(grContext, desc, GrContext::kExact_Scrat
chTexMatch); |
441 skia::RefPtr<GrTexture> backingStore = skia::AdoptRef(scratchTexture.detach(
)); | 443 skia::RefPtr<GrTexture> backingStore = skia::AdoptRef(scratchTexture.detach(
)); |
442 | 444 |
443 // Create a device and canvas using that backing store. | 445 // Create a device and canvas using that backing store. |
444 SkGpuDevice device(grContext, backingStore.get()); | 446 SkGpuDevice device(grContext, backingStore.get()); |
445 SkCanvas canvas(&device); | 447 SkCanvas canvas(&device); |
446 | 448 |
447 // Draw the source bitmap through the filter to the canvas. | 449 // Draw the source bitmap through the filter to the canvas. |
448 SkPaint paint; | 450 SkPaint paint; |
449 paint.setImageFilter(filter); | 451 paint.setImageFilter(filter); |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 | 1813 |
1812 releaseRenderPassTextures(); | 1814 releaseRenderPassTextures(); |
1813 } | 1815 } |
1814 | 1816 |
1815 bool GLRenderer::isContextLost() | 1817 bool GLRenderer::isContextLost() |
1816 { | 1818 { |
1817 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1819 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1818 } | 1820 } |
1819 | 1821 |
1820 } // namespace cc | 1822 } // namespace cc |
OLD | NEW |