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

Side by Side Diff: cc/software_renderer.cc

Issue 11348371: cc: Move WebCompositorOutputSurface and related classes into cc/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: forlanding6 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
« no previous file with comments | « cc/software_renderer.h ('k') | cc/software_renderer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/software_renderer.h" 5 #include "cc/software_renderer.h"
6 6
7 #include <public/WebCompositorSoftwareOutputDevice.h>
8 #include <public/WebImage.h> 7 #include <public/WebImage.h>
9 #include <public/WebSize.h>
10 8
11 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
12 #include "cc/debug_border_draw_quad.h" 10 #include "cc/debug_border_draw_quad.h"
13 #include "cc/math_util.h" 11 #include "cc/math_util.h"
14 #include "cc/render_pass_draw_quad.h" 12 #include "cc/render_pass_draw_quad.h"
13 #include "cc/software_output_device.h"
15 #include "cc/solid_color_draw_quad.h" 14 #include "cc/solid_color_draw_quad.h"
16 #include "cc/texture_draw_quad.h" 15 #include "cc/texture_draw_quad.h"
17 #include "cc/tile_draw_quad.h" 16 #include "cc/tile_draw_quad.h"
18 #include "third_party/skia/include/core/SkCanvas.h" 17 #include "third_party/skia/include/core/SkCanvas.h"
19 #include "third_party/skia/include/core/SkColor.h" 18 #include "third_party/skia/include/core/SkColor.h"
20 #include "third_party/skia/include/core/SkMatrix.h" 19 #include "third_party/skia/include/core/SkMatrix.h"
21 #include "third_party/skia/include/core/SkShader.h" 20 #include "third_party/skia/include/core/SkShader.h"
22 #include "third_party/skia/include/effects/SkLayerRasterizer.h" 21 #include "third_party/skia/include/effects/SkLayerRasterizer.h"
23 #include "ui/gfx/rect_conversions.h" 22 #include "ui/gfx/rect_conversions.h"
24 #include "ui/gfx/skia_util.h" 23 #include "ui/gfx/skia_util.h"
25 #include "ui/gfx/transform.h" 24 #include "ui/gfx/transform.h"
26 25
27 using WebKit::WebCompositorSoftwareOutputDevice;
28 using WebKit::WebSize;
29
30 namespace cc { 26 namespace cc {
31 27
32 namespace { 28 namespace {
33 29
34 void toSkMatrix(SkMatrix* flattened, const gfx::Transform& m) 30 void toSkMatrix(SkMatrix* flattened, const gfx::Transform& m)
35 { 31 {
36 // Convert from 4x4 to 3x3 by dropping the third row and column. 32 // Convert from 4x4 to 3x3 by dropping the third row and column.
37 flattened->set(0, SkDoubleToScalar(m.matrix().getDouble(0, 0))); 33 flattened->set(0, SkDoubleToScalar(m.matrix().getDouble(0, 0)));
38 flattened->set(1, SkDoubleToScalar(m.matrix().getDouble(0, 1))); 34 flattened->set(1, SkDoubleToScalar(m.matrix().getDouble(0, 1)));
39 flattened->set(2, SkDoubleToScalar(m.matrix().getDouble(0, 3))); 35 flattened->set(2, SkDoubleToScalar(m.matrix().getDouble(0, 3)));
40 flattened->set(3, SkDoubleToScalar(m.matrix().getDouble(1, 0))); 36 flattened->set(3, SkDoubleToScalar(m.matrix().getDouble(1, 0)));
41 flattened->set(4, SkDoubleToScalar(m.matrix().getDouble(1, 1))); 37 flattened->set(4, SkDoubleToScalar(m.matrix().getDouble(1, 1)));
42 flattened->set(5, SkDoubleToScalar(m.matrix().getDouble(1, 3))); 38 flattened->set(5, SkDoubleToScalar(m.matrix().getDouble(1, 3)));
43 flattened->set(6, SkDoubleToScalar(m.matrix().getDouble(3, 0))); 39 flattened->set(6, SkDoubleToScalar(m.matrix().getDouble(3, 0)));
44 flattened->set(7, SkDoubleToScalar(m.matrix().getDouble(3, 1))); 40 flattened->set(7, SkDoubleToScalar(m.matrix().getDouble(3, 1)));
45 flattened->set(8, SkDoubleToScalar(m.matrix().getDouble(3, 3))); 41 flattened->set(8, SkDoubleToScalar(m.matrix().getDouble(3, 3)));
46 } 42 }
47 43
48 bool isScaleAndTranslate(const SkMatrix& matrix) 44 bool isScaleAndTranslate(const SkMatrix& matrix)
49 { 45 {
50 return SkScalarNearlyZero(matrix[SkMatrix::kMSkewX]) && 46 return SkScalarNearlyZero(matrix[SkMatrix::kMSkewX]) &&
51 SkScalarNearlyZero(matrix[SkMatrix::kMSkewY]) && 47 SkScalarNearlyZero(matrix[SkMatrix::kMSkewY]) &&
52 SkScalarNearlyZero(matrix[SkMatrix::kMPersp0]) && 48 SkScalarNearlyZero(matrix[SkMatrix::kMPersp0]) &&
53 SkScalarNearlyZero(matrix[SkMatrix::kMPersp1]) && 49 SkScalarNearlyZero(matrix[SkMatrix::kMPersp1]) &&
54 SkScalarNearlyZero(matrix[SkMatrix::kMPersp2] - 1.0f); 50 SkScalarNearlyZero(matrix[SkMatrix::kMPersp2] - 1.0f);
55 } 51 }
56 52
57 } // anonymous namespace 53 } // anonymous namespace
58 54
59 scoped_ptr<SoftwareRenderer> SoftwareRenderer::create(RendererClient* client, Re sourceProvider* resourceProvider, WebCompositorSoftwareOutputDevice* outputDevic e) 55 scoped_ptr<SoftwareRenderer> SoftwareRenderer::create(RendererClient* client, Re sourceProvider* resourceProvider, SoftwareOutputDevice* outputDevice)
60 { 56 {
61 return make_scoped_ptr(new SoftwareRenderer(client, resourceProvider, output Device)); 57 return make_scoped_ptr(new SoftwareRenderer(client, resourceProvider, output Device));
62 } 58 }
63 59
64 SoftwareRenderer::SoftwareRenderer(RendererClient* client, ResourceProvider* res ourceProvider, WebCompositorSoftwareOutputDevice* outputDevice) 60 SoftwareRenderer::SoftwareRenderer(RendererClient* client, ResourceProvider* res ourceProvider, SoftwareOutputDevice* outputDevice)
65 : DirectRenderer(client, resourceProvider) 61 : DirectRenderer(client, resourceProvider)
66 , m_visible(true) 62 , m_visible(true)
67 , m_outputDevice(outputDevice) 63 , m_outputDevice(outputDevice)
68 , m_skCurrentCanvas(0) 64 , m_skCurrentCanvas(0)
69 { 65 {
70 m_resourceProvider->setDefaultResourceType(ResourceProvider::Bitmap); 66 m_resourceProvider->setDefaultResourceType(ResourceProvider::Bitmap);
71 67
72 m_capabilities.maxTextureSize = INT_MAX; 68 m_capabilities.maxTextureSize = INT_MAX;
73 m_capabilities.bestTextureFormat = GL_RGBA; 69 m_capabilities.bestTextureFormat = GL_RGBA;
74 m_capabilities.usingSetVisibility = true; 70 m_capabilities.usingSetVisibility = true;
75 // The updater can access bitmaps while the SoftwareRenderer is using them. 71 // The updater can access bitmaps while the SoftwareRenderer is using them.
76 m_capabilities.allowPartialTextureUpdates = true; 72 m_capabilities.allowPartialTextureUpdates = true;
77 73
78 viewportChanged(); 74 viewportChanged();
79 } 75 }
80 76
81 SoftwareRenderer::~SoftwareRenderer() 77 SoftwareRenderer::~SoftwareRenderer()
82 { 78 {
83 } 79 }
84 80
85 const RendererCapabilities& SoftwareRenderer::capabilities() const 81 const RendererCapabilities& SoftwareRenderer::capabilities() const
86 { 82 {
87 return m_capabilities; 83 return m_capabilities;
88 } 84 }
89 85
90 void SoftwareRenderer::viewportChanged() 86 void SoftwareRenderer::viewportChanged()
91 { 87 {
92 m_outputDevice->didChangeViewportSize(WebSize(viewportSize().width(), viewpo rtSize().height())); 88 m_outputDevice->DidChangeViewportSize(viewportSize());
93 } 89 }
94 90
95 void SoftwareRenderer::beginDrawingFrame(DrawingFrame& frame) 91 void SoftwareRenderer::beginDrawingFrame(DrawingFrame& frame)
96 { 92 {
97 TRACE_EVENT0("cc", "SoftwareRenderer::beginDrawingFrame"); 93 TRACE_EVENT0("cc", "SoftwareRenderer::beginDrawingFrame");
98 m_skRootCanvas = make_scoped_ptr(new SkCanvas(m_outputDevice->lock(true)->ge tSkBitmap())); 94 m_skRootCanvas = make_scoped_ptr(new SkCanvas(m_outputDevice->Lock(true)->ge tSkBitmap()));
99 } 95 }
100 96
101 void SoftwareRenderer::finishDrawingFrame(DrawingFrame& frame) 97 void SoftwareRenderer::finishDrawingFrame(DrawingFrame& frame)
102 { 98 {
103 TRACE_EVENT0("cc", "SoftwareRenderer::finishDrawingFrame"); 99 TRACE_EVENT0("cc", "SoftwareRenderer::finishDrawingFrame");
104 m_currentFramebufferLock.reset(); 100 m_currentFramebufferLock.reset();
105 m_skCurrentCanvas = 0; 101 m_skCurrentCanvas = 0;
106 m_skRootCanvas.reset(); 102 m_skRootCanvas.reset();
107 m_outputDevice->unlock(); 103 m_outputDevice->Unlock();
108 } 104 }
109 105
110 bool SoftwareRenderer::flippedFramebuffer() const 106 bool SoftwareRenderer::flippedFramebuffer() const
111 { 107 {
112 return false; 108 return false;
113 } 109 }
114 110
115 void SoftwareRenderer::ensureScissorTestEnabled() 111 void SoftwareRenderer::ensureScissorTestEnabled()
116 { 112 {
117 // Nothing to do here. Current implementation of software rendering has no 113 // Nothing to do here. Current implementation of software rendering has no
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 bool SoftwareRenderer::swapBuffers() 359 bool SoftwareRenderer::swapBuffers()
364 { 360 {
365 if (m_client->hasImplThread()) 361 if (m_client->hasImplThread())
366 m_client->onSwapBuffersComplete(); 362 m_client->onSwapBuffersComplete();
367 return true; 363 return true;
368 } 364 }
369 365
370 void SoftwareRenderer::getFramebufferPixels(void *pixels, const gfx::Rect& rect) 366 void SoftwareRenderer::getFramebufferPixels(void *pixels, const gfx::Rect& rect)
371 { 367 {
372 TRACE_EVENT0("cc", "SoftwareRenderer::getFramebufferPixels"); 368 TRACE_EVENT0("cc", "SoftwareRenderer::getFramebufferPixels");
373 SkBitmap fullBitmap = m_outputDevice->lock(false)->getSkBitmap(); 369 SkBitmap fullBitmap = m_outputDevice->Lock(false)->getSkBitmap();
374 SkBitmap subsetBitmap; 370 SkBitmap subsetBitmap;
375 SkIRect invertRect = SkIRect::MakeXYWH(rect.x(), viewportSize().height() - r ect.bottom(), rect.width(), rect.height()); 371 SkIRect invertRect = SkIRect::MakeXYWH(rect.x(), viewportSize().height() - r ect.bottom(), rect.width(), rect.height());
376 fullBitmap.extractSubset(&subsetBitmap, invertRect); 372 fullBitmap.extractSubset(&subsetBitmap, invertRect);
377 subsetBitmap.copyPixelsTo(pixels, rect.width() * rect.height() * 4, rect.wid th() * 4); 373 subsetBitmap.copyPixelsTo(pixels, rect.width() * rect.height() * 4, rect.wid th() * 4);
378 m_outputDevice->unlock(); 374 m_outputDevice->Unlock();
379 } 375 }
380 376
381 void SoftwareRenderer::setVisible(bool visible) 377 void SoftwareRenderer::setVisible(bool visible)
382 { 378 {
383 if (m_visible == visible) 379 if (m_visible == visible)
384 return; 380 return;
385 m_visible = visible; 381 m_visible = visible;
386 } 382 }
387 383
388 } // namespace cc 384 } // namespace cc
OLDNEW
« no previous file with comments | « cc/software_renderer.h ('k') | cc/software_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698