| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/software_renderer.h" | 7 #include "cc/software_renderer.h" |
| 8 | 8 |
| 9 #include "CCDebugBorderDrawQuad.h" | 9 #include "CCDebugBorderDrawQuad.h" |
| 10 #include "cc/render_pass_draw_quad.h" | 10 #include "cc/render_pass_draw_quad.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 { | 58 { |
| 59 return SkScalarNearlyZero(matrix[SkMatrix::kMSkewX]) && | 59 return SkScalarNearlyZero(matrix[SkMatrix::kMSkewX]) && |
| 60 SkScalarNearlyZero(matrix[SkMatrix::kMSkewY]) && | 60 SkScalarNearlyZero(matrix[SkMatrix::kMSkewY]) && |
| 61 SkScalarNearlyZero(matrix[SkMatrix::kMPersp0]) && | 61 SkScalarNearlyZero(matrix[SkMatrix::kMPersp0]) && |
| 62 SkScalarNearlyZero(matrix[SkMatrix::kMPersp1]) && | 62 SkScalarNearlyZero(matrix[SkMatrix::kMPersp1]) && |
| 63 SkScalarNearlyZero(matrix[SkMatrix::kMPersp2] - 1.0f); | 63 SkScalarNearlyZero(matrix[SkMatrix::kMPersp2] - 1.0f); |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // anonymous namespace | 66 } // anonymous namespace |
| 67 | 67 |
| 68 scoped_ptr<SoftwareRenderer> SoftwareRenderer::create(RendererClient* client, Re
sourceProvider* resourceProvider, WebCompositorSoftwareOutputDevice* outputDevic
e) | 68 scoped_ptr<SoftwareRenderer> SoftwareRenderer::create(RendererClient* client, Re
sourceProvider* resourceProvider, WebCompositorSoftwareOutputDevice* outputDevic
e, bool hasImplThread) |
| 69 { | 69 { |
| 70 return make_scoped_ptr(new SoftwareRenderer(client, resourceProvider, output
Device)); | 70 return make_scoped_ptr(new SoftwareRenderer(client, resourceProvider, output
Device, hasImplThread)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 SoftwareRenderer::SoftwareRenderer(RendererClient* client, ResourceProvider* res
ourceProvider, WebCompositorSoftwareOutputDevice* outputDevice) | 73 SoftwareRenderer::SoftwareRenderer(RendererClient* client, ResourceProvider* res
ourceProvider, WebCompositorSoftwareOutputDevice* outputDevice, bool hasImplThre
ad) |
| 74 : DirectRenderer(client, resourceProvider) | 74 : DirectRenderer(client, resourceProvider) |
| 75 , m_hasImplThread(hasImplThread) |
| 75 , m_visible(true) | 76 , m_visible(true) |
| 76 , m_outputDevice(outputDevice) | 77 , m_outputDevice(outputDevice) |
| 77 , m_skCurrentCanvas(0) | 78 , m_skCurrentCanvas(0) |
| 78 { | 79 { |
| 79 m_resourceProvider->setDefaultResourceType(ResourceProvider::Bitmap); | 80 m_resourceProvider->setDefaultResourceType(ResourceProvider::Bitmap); |
| 80 | 81 |
| 81 m_capabilities.maxTextureSize = INT_MAX; | 82 m_capabilities.maxTextureSize = INT_MAX; |
| 82 m_capabilities.bestTextureFormat = GL_RGBA; | 83 m_capabilities.bestTextureFormat = GL_RGBA; |
| 83 m_capabilities.contextHasCachedFrontBuffer = true; | 84 m_capabilities.contextHasCachedFrontBuffer = true; |
| 84 m_capabilities.usingSetVisibility = true; | 85 m_capabilities.usingSetVisibility = true; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 327 |
| 327 void SoftwareRenderer::drawUnsupportedQuad(const DrawingFrame& frame, const Draw
Quad* quad) | 328 void SoftwareRenderer::drawUnsupportedQuad(const DrawingFrame& frame, const Draw
Quad* quad) |
| 328 { | 329 { |
| 329 m_skCurrentPaint.setColor(SK_ColorMAGENTA); | 330 m_skCurrentPaint.setColor(SK_ColorMAGENTA); |
| 330 m_skCurrentPaint.setAlpha(quad->opacity() * 255); | 331 m_skCurrentPaint.setAlpha(quad->opacity() * 255); |
| 331 m_skCurrentCanvas->drawRect(toSkRect(quadVertexRect()), m_skCurrentPaint); | 332 m_skCurrentCanvas->drawRect(toSkRect(quadVertexRect()), m_skCurrentPaint); |
| 332 } | 333 } |
| 333 | 334 |
| 334 bool SoftwareRenderer::swapBuffers() | 335 bool SoftwareRenderer::swapBuffers() |
| 335 { | 336 { |
| 336 if (Proxy::hasImplThread()) | 337 if (m_hasImplThread) |
| 337 m_client->onSwapBuffersComplete(); | 338 m_client->onSwapBuffersComplete(); |
| 338 return true; | 339 return true; |
| 339 } | 340 } |
| 340 | 341 |
| 341 void SoftwareRenderer::getFramebufferPixels(void *pixels, const IntRect& rect) | 342 void SoftwareRenderer::getFramebufferPixels(void *pixels, const IntRect& rect) |
| 342 { | 343 { |
| 343 SkBitmap fullBitmap = m_outputDevice->lock(false)->getSkBitmap(); | 344 SkBitmap fullBitmap = m_outputDevice->lock(false)->getSkBitmap(); |
| 344 SkBitmap subsetBitmap; | 345 SkBitmap subsetBitmap; |
| 345 SkIRect invertRect = SkIRect::MakeXYWH(rect.x(), viewportSize().height() - r
ect.maxY(), rect.width(), rect.height()); | 346 SkIRect invertRect = SkIRect::MakeXYWH(rect.x(), viewportSize().height() - r
ect.maxY(), rect.width(), rect.height()); |
| 346 fullBitmap.extractSubset(&subsetBitmap, invertRect); | 347 fullBitmap.extractSubset(&subsetBitmap, invertRect); |
| 347 subsetBitmap.copyPixelsTo(pixels, rect.width() * rect.height() * 4, rect.wid
th() * 4); | 348 subsetBitmap.copyPixelsTo(pixels, rect.width() * rect.height() * 4, rect.wid
th() * 4); |
| 348 m_outputDevice->unlock(); | 349 m_outputDevice->unlock(); |
| 349 } | 350 } |
| 350 | 351 |
| 351 void SoftwareRenderer::setVisible(bool visible) | 352 void SoftwareRenderer::setVisible(bool visible) |
| 352 { | 353 { |
| 353 if (m_visible == visible) | 354 if (m_visible == visible) |
| 354 return; | 355 return; |
| 355 m_visible = visible; | 356 m_visible = visible; |
| 356 } | 357 } |
| 357 | 358 |
| 358 } | 359 } |
| OLD | NEW |