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

Side by Side Diff: Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp

Issue 7590009: Merge 92255 - Source/WebCore: [Chromium] Use edge-distance method for layer anti-aliasing. (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/835/
Patch Set: Created 9 years, 4 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 20 matching lines...) Expand all
31 31
32 #include "GraphicsContext3D.h" 32 #include "GraphicsContext3D.h"
33 #include "LayerRendererChromium.h" 33 #include "LayerRendererChromium.h"
34 #include "LayerTilerChromium.h" 34 #include "LayerTilerChromium.h"
35 #include "TextStream.h" 35 #include "TextStream.h"
36 #include "cc/CCLayerImpl.h" 36 #include "cc/CCLayerImpl.h"
37 #include "cc/CCTiledLayerImpl.h" 37 #include "cc/CCTiledLayerImpl.h"
38 #include <wtf/CurrentTime.h> 38 #include <wtf/CurrentTime.h>
39 39
40 // Start tiling when the width and height of a layer are larger than this size. 40 // Start tiling when the width and height of a layer are larger than this size.
41 static int maxUntiledSize = 510; 41 static int maxUntiledSize = 512;
42 42
43 // When tiling is enabled, use tiles of this dimension squared. 43 // When tiling is enabled, use tiles of this dimension squared.
44 static int defaultTileSize = 256; 44 static int defaultTileSize = 256;
45 45
46 using namespace std; 46 using namespace std;
47 47
48 namespace WebCore { 48 namespace WebCore {
49 49
50 TiledLayerChromium::TiledLayerChromium(GraphicsLayerChromium* owner) 50 TiledLayerChromium::TiledLayerChromium(GraphicsLayerChromium* owner)
51 : LayerChromium(owner) 51 : LayerChromium(owner)
52 , m_tilingOption(AutoTile) 52 , m_tilingOption(AutoTile)
53 , m_borderTexels(true)
54 { 53 {
55 } 54 }
56 55
57 TiledLayerChromium::~TiledLayerChromium() 56 TiledLayerChromium::~TiledLayerChromium()
58 { 57 {
59 } 58 }
60 59
61 PassRefPtr<CCLayerImpl> TiledLayerChromium::createCCLayerImpl() 60 PassRefPtr<CCLayerImpl> TiledLayerChromium::createCCLayerImpl()
62 { 61 {
63 return CCTiledLayerImpl::create(this, id()); 62 return CCTiledLayerImpl::create(this, id());
64 } 63 }
65 64
66 void TiledLayerChromium::cleanupResources() 65 void TiledLayerChromium::cleanupResources()
67 { 66 {
68 m_tiler.clear(); 67 m_tiler.clear();
69 LayerChromium::cleanupResources(); 68 LayerChromium::cleanupResources();
70 } 69 }
71 70
72 void TiledLayerChromium::setLayerRenderer(LayerRendererChromium* layerRenderer) 71 void TiledLayerChromium::setLayerRenderer(LayerRendererChromium* layerRenderer)
73 { 72 {
74 LayerChromium::setLayerRenderer(layerRenderer); 73 LayerChromium::setLayerRenderer(layerRenderer);
75 createTilerIfNeeded(); 74 createTilerIfNeeded();
76 } 75 }
77 76
78 void TiledLayerChromium::updateTileSizeAndTilingOption() 77 void TiledLayerChromium::updateTileSizeAndTilingOption()
79 { 78 {
80 if (!m_tiler) 79 if (!m_tiler)
81 return; 80 return;
82 81
83 const IntSize tileSize(defaultTileSize, defaultTileSize); 82 const IntSize tileSize(min(defaultTileSize, contentBounds().width()), min(de faultTileSize, contentBounds().height()));
84 83
85 // Tile if both dimensions large, or any one dimension large and the other 84 // Tile if both dimensions large, or any one dimension large and the other
86 // extends into a second tile. This heuristic allows for long skinny layers 85 // extends into a second tile. This heuristic allows for long skinny layers
87 // (e.g. scrollbars) that are Nx1 tiles to minimize wasted texture space. 86 // (e.g. scrollbars) that are Nx1 tiles to minimize wasted texture space.
88 const bool anyDimensionLarge = contentBounds().width() > maxUntiledSize || c ontentBounds().height() > maxUntiledSize; 87 const bool anyDimensionLarge = contentBounds().width() > maxUntiledSize || c ontentBounds().height() > maxUntiledSize;
89 const bool anyDimensionOneTile = contentBounds().width() <= defaultTileSize || contentBounds().height() <= defaultTileSize; 88 const bool anyDimensionOneTile = contentBounds().width() <= defaultTileSize || contentBounds().height() <= defaultTileSize;
90 const bool autoTiled = anyDimensionLarge && !anyDimensionOneTile; 89 const bool autoTiled = anyDimensionLarge && !anyDimensionOneTile;
91 90
92 bool isTiled; 91 bool isTiled;
93 if (m_tilingOption == AlwaysTile) 92 if (m_tilingOption == AlwaysTile)
94 isTiled = true; 93 isTiled = true;
95 else if (m_tilingOption == NeverTile) 94 else if (m_tilingOption == NeverTile)
96 isTiled = false; 95 isTiled = false;
97 else 96 else
98 isTiled = autoTiled; 97 isTiled = autoTiled;
99 98
100 // Empty tile size tells the tiler to avoid tiling. 99 IntSize requestedSize = isTiled ? tileSize : contentBounds();
101 IntSize requestedSize = isTiled ? tileSize : IntSize();
102 const int maxSize = layerRenderer()->maxTextureSize(); 100 const int maxSize = layerRenderer()->maxTextureSize();
103 IntSize clampedSize = requestedSize.shrunkTo(IntSize(maxSize, maxSize)); 101 IntSize clampedSize = requestedSize.shrunkTo(IntSize(maxSize, maxSize));
104 m_tiler->setTileSize(clampedSize); 102 m_tiler->setTileSize(clampedSize);
105 } 103 }
106 104
107 bool TiledLayerChromium::drawsContent() const 105 bool TiledLayerChromium::drawsContent() const
108 { 106 {
109 if (!m_owner) 107 if (!m_owner)
110 return false; 108 return false;
111 109
112 if (!m_tiler) 110 if (!m_tiler)
113 return true; 111 return true;
114 112
115 if (m_tilingOption == NeverTile && m_tiler->numTiles() > 1) 113 if (m_tilingOption == NeverTile && m_tiler->numTiles() > 1)
116 return false; 114 return false;
117 115
118 return !m_tiler->skipsDraw(); 116 return !m_tiler->skipsDraw();
119 } 117 }
120 118
121 void TiledLayerChromium::createTilerIfNeeded() 119 void TiledLayerChromium::createTilerIfNeeded()
122 { 120 {
123 if (m_tiler) 121 if (m_tiler)
124 return; 122 return;
125 123
126 createTextureUpdaterIfNeeded(); 124 createTextureUpdaterIfNeeded();
127 125
128 m_tiler = LayerTilerChromium::create( 126 m_tiler = LayerTilerChromium::create(
129 layerRenderer(), 127 layerRenderer(),
130 IntSize(defaultTileSize, defaultTileSize), 128 IntSize(defaultTileSize, defaultTileSize),
131 m_borderTexels ? LayerTilerChromium::HasBorderTexels : LayerTilerChromiu m::NoBorderTexels); 129 LayerTilerChromium::HasBorderTexels);
132 } 130 }
133 131
134 void TiledLayerChromium::updateCompositorResources() 132 void TiledLayerChromium::updateCompositorResources()
135 { 133 {
136 m_tiler->updateRect(textureUpdater()); 134 m_tiler->updateRect(textureUpdater());
137 } 135 }
138 136
139 void TiledLayerChromium::setTilingOption(TilingOption tilingOption) 137 void TiledLayerChromium::setTilingOption(TilingOption tilingOption)
140 { 138 {
141 m_tilingOption = tilingOption; 139 m_tilingOption = tilingOption;
142 updateTileSizeAndTilingOption(); 140 updateTileSizeAndTilingOption();
143 } 141 }
144 142
145 void TiledLayerChromium::setIsMask(bool isMask) 143 void TiledLayerChromium::setIsMask(bool isMask)
146 { 144 {
147 m_borderTexels = !isMask;
148 setTilingOption(isMask ? NeverTile : AutoTile); 145 setTilingOption(isMask ? NeverTile : AutoTile);
149 } 146 }
150 147
151 TransformationMatrix TiledLayerChromium::tilingTransform() const 148 TransformationMatrix TiledLayerChromium::tilingTransform() const
152 { 149 {
153 TransformationMatrix transform = ccLayerImpl()->drawTransform(); 150 TransformationMatrix transform = ccLayerImpl()->drawTransform();
154 151
155 if (contentBounds().isEmpty()) 152 if (contentBounds().isEmpty())
156 return transform; 153 return transform;
157 154
(...skipping 23 matching lines...) Expand all
181 178
182 void TiledLayerChromium::dumpLayerProperties(TextStream& ts, int indent) const 179 void TiledLayerChromium::dumpLayerProperties(TextStream& ts, int indent) const
183 { 180 {
184 LayerChromium::dumpLayerProperties(ts, indent); 181 LayerChromium::dumpLayerProperties(ts, indent);
185 writeIndent(ts, indent); 182 writeIndent(ts, indent);
186 ts << "skipsDraw: " << (!m_tiler || m_tiler->skipsDraw()) << "\n"; 183 ts << "skipsDraw: " << (!m_tiler || m_tiler->skipsDraw()) << "\n";
187 } 184 }
188 185
189 } 186 }
190 #endif // USE(ACCELERATED_COMPOSITING) 187 #endif // USE(ACCELERATED_COMPOSITING)
OLDNEW
« no previous file with comments | « Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h ('k') | Source/WebCore/platform/graphics/gpu/TilingData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698