OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/accelerated_widget_mac/ca_renderer_layer_tree.h" | 5 #include "ui/accelerated_widget_mac/ca_renderer_layer_tree.h" |
6 | 6 |
7 #import <AVFoundation/AVFoundation.h> | 7 #import <AVFoundation/AVFoundation.h> |
8 #include <CoreMedia/CoreMedia.h> | 8 #include <CoreMedia/CoreMedia.h> |
9 #include <CoreVideo/CoreVideo.h> | 9 #include <CoreVideo/CoreVideo.h> |
10 #include <GLES2/gl2extchromium.h> | 10 #include <GLES2/gl2extchromium.h> |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 SkColor color_ = 0; | 148 SkColor color_ = 0; |
149 base::ScopedCFTypeRef<IOSurfaceRef> io_surface_; | 149 base::ScopedCFTypeRef<IOSurfaceRef> io_surface_; |
150 }; | 150 }; |
151 | 151 |
152 // static | 152 // static |
153 scoped_refptr<CARendererLayerTree::SolidColorContents> | 153 scoped_refptr<CARendererLayerTree::SolidColorContents> |
154 CARendererLayerTree::SolidColorContents::Get(SkColor color) { | 154 CARendererLayerTree::SolidColorContents::Get(SkColor color) { |
155 const int kSolidColorContentsSize = 16; | 155 const int kSolidColorContentsSize = 16; |
156 | 156 |
157 auto map = GetMap(); | 157 auto* map = GetMap(); |
158 auto found = map->find(color); | 158 auto found = map->find(color); |
159 if (found != map->end()) | 159 if (found != map->end()) |
160 return found->second; | 160 return found->second; |
161 | 161 |
162 IOSurfaceRef io_surface = CreateIOSurface( | 162 IOSurfaceRef io_surface = CreateIOSurface( |
163 gfx::Size(kSolidColorContentsSize, kSolidColorContentsSize), | 163 gfx::Size(kSolidColorContentsSize, kSolidColorContentsSize), |
164 gfx::BufferFormat::BGRA_8888); | 164 gfx::BufferFormat::BGRA_8888); |
165 if (!io_surface) | 165 if (!io_surface) |
166 return nullptr; | 166 return nullptr; |
167 | 167 |
(...skipping 13 matching lines...) Expand all Loading... |
181 } | 181 } |
182 | 182 |
183 id CARendererLayerTree::SolidColorContents::GetContents() const { | 183 id CARendererLayerTree::SolidColorContents::GetContents() const { |
184 return static_cast<id>(io_surface_.get()); | 184 return static_cast<id>(io_surface_.get()); |
185 } | 185 } |
186 | 186 |
187 CARendererLayerTree::SolidColorContents::SolidColorContents( | 187 CARendererLayerTree::SolidColorContents::SolidColorContents( |
188 SkColor color, | 188 SkColor color, |
189 IOSurfaceRef io_surface) | 189 IOSurfaceRef io_surface) |
190 : color_(color), io_surface_(io_surface) { | 190 : color_(color), io_surface_(io_surface) { |
191 auto map = GetMap(); | 191 auto* map = GetMap(); |
192 DCHECK(map->find(color_) == map->end()); | 192 DCHECK(map->find(color_) == map->end()); |
193 map->insert(std::make_pair(color_, this)); | 193 map->insert(std::make_pair(color_, this)); |
194 } | 194 } |
195 | 195 |
196 CARendererLayerTree::SolidColorContents::~SolidColorContents() { | 196 CARendererLayerTree::SolidColorContents::~SolidColorContents() { |
197 auto map = GetMap(); | 197 auto* map = GetMap(); |
198 auto found = map->find(color_); | 198 auto found = map->find(color_); |
199 DCHECK(found != map->end()); | 199 DCHECK(found != map->end()); |
200 DCHECK(found->second == this); | 200 DCHECK(found->second == this); |
201 map->erase(color_); | 201 map->erase(color_); |
202 } | 202 } |
203 | 203 |
204 // static | 204 // static |
205 std::map<SkColor, CARendererLayerTree::SolidColorContents*>* | 205 std::map<SkColor, CARendererLayerTree::SolidColorContents*>* |
206 CARendererLayerTree::SolidColorContents::GetMap() { | 206 CARendererLayerTree::SolidColorContents::GetMap() { |
207 static auto map = new std::map<SkColor, SolidColorContents*>(); | 207 static auto* map = new std::map<SkColor, SolidColorContents*>(); |
208 return map; | 208 return map; |
209 } | 209 } |
210 | 210 |
211 CARendererLayerTree::CARendererLayerTree( | 211 CARendererLayerTree::CARendererLayerTree( |
212 bool allow_av_sample_buffer_display_layer, | 212 bool allow_av_sample_buffer_display_layer, |
213 bool allow_solid_color_layers) | 213 bool allow_solid_color_layers) |
214 : allow_av_sample_buffer_display_layer_( | 214 : allow_av_sample_buffer_display_layer_( |
215 allow_av_sample_buffer_display_layer), | 215 allow_av_sample_buffer_display_layer), |
216 allow_solid_color_layers_(allow_solid_color_layers) {} | 216 allow_solid_color_layers_(allow_solid_color_layers) {} |
217 CARendererLayerTree::~CARendererLayerTree() {} | 217 CARendererLayerTree::~CARendererLayerTree() {} |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 } else { | 742 } else { |
743 // Grey represents a CALayer that has not changed. | 743 // Grey represents a CALayer that has not changed. |
744 color.reset(CGColorCreateGenericRGB(0.5, 0.5, 0.5, 1)); | 744 color.reset(CGColorCreateGenericRGB(0.5, 0.5, 0.5, 1)); |
745 } | 745 } |
746 [ca_layer setBorderWidth:1]; | 746 [ca_layer setBorderWidth:1]; |
747 [ca_layer setBorderColor:color]; | 747 [ca_layer setBorderColor:color]; |
748 } | 748 } |
749 } | 749 } |
750 | 750 |
751 } // namespace ui | 751 } // namespace ui |
OLD | NEW |