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

Side by Side Diff: cc/resources/picture.cc

Issue 93663004: [#2] Pass gfx structs by const ref (gfx::Rect, gfx::RectF) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to ToT, fix builds on non-linux platforms! Created 6 years, 11 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
« no previous file with comments | « cc/resources/picture.h ('k') | cc/resources/picture_layer_tiling.h » ('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/resources/picture.h" 5 #include "cc/resources/picture.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 scoped_ptr<SkBitmap> decoded_jpeg(gfx::JPEGCodec::Decode(data, size)); 74 scoped_ptr<SkBitmap> decoded_jpeg(gfx::JPEGCodec::Decode(data, size));
75 if (decoded_jpeg) { 75 if (decoded_jpeg) {
76 *bm = *decoded_jpeg; 76 *bm = *decoded_jpeg;
77 return true; 77 return true;
78 } 78 }
79 return false; 79 return false;
80 } 80 }
81 81
82 } // namespace 82 } // namespace
83 83
84 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { 84 scoped_refptr<Picture> Picture::Create(const gfx::Rect& layer_rect) {
85 return make_scoped_refptr(new Picture(layer_rect)); 85 return make_scoped_refptr(new Picture(layer_rect));
86 } 86 }
87 87
88 Picture::Picture(gfx::Rect layer_rect) 88 Picture::Picture(const gfx::Rect& layer_rect)
89 : layer_rect_(layer_rect), 89 : layer_rect_(layer_rect),
90 cell_size_(layer_rect.size()) { 90 cell_size_(layer_rect.size()) {
91 // Instead of recording a trace event for object creation here, we wait for 91 // Instead of recording a trace event for object creation here, we wait for
92 // the picture to be recorded in Picture::Record. 92 // the picture to be recorded in Picture::Record.
93 } 93 }
94 94
95 scoped_refptr<Picture> Picture::CreateFromSkpValue(const base::Value* value) { 95 scoped_refptr<Picture> Picture::CreateFromSkpValue(const base::Value* value) {
96 // Decode the picture from base64. 96 // Decode the picture from base64.
97 std::string encoded; 97 std::string encoded;
98 if (!value->GetAsString(&encoded)) 98 if (!value->GetAsString(&encoded))
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 // Read the picture. This creates an empty picture on failure. 146 // Read the picture. This creates an empty picture on failure.
147 SkPicture* skpicture = SkPicture::CreateFromStream(&stream, &DecodeBitmap); 147 SkPicture* skpicture = SkPicture::CreateFromStream(&stream, &DecodeBitmap);
148 if (skpicture == NULL) 148 if (skpicture == NULL)
149 return NULL; 149 return NULL;
150 150
151 return make_scoped_refptr(new Picture(skpicture, layer_rect, opaque_rect)); 151 return make_scoped_refptr(new Picture(skpicture, layer_rect, opaque_rect));
152 } 152 }
153 153
154 Picture::Picture(SkPicture* picture, 154 Picture::Picture(SkPicture* picture,
155 gfx::Rect layer_rect, 155 const gfx::Rect& layer_rect,
156 gfx::Rect opaque_rect) : 156 const gfx::Rect& opaque_rect) :
157 layer_rect_(layer_rect), 157 layer_rect_(layer_rect),
158 opaque_rect_(opaque_rect), 158 opaque_rect_(opaque_rect),
159 picture_(skia::AdoptRef(picture)), 159 picture_(skia::AdoptRef(picture)),
160 cell_size_(layer_rect.size()) { 160 cell_size_(layer_rect.size()) {
161 } 161 }
162 162
163 Picture::Picture(const skia::RefPtr<SkPicture>& picture, 163 Picture::Picture(const skia::RefPtr<SkPicture>& picture,
164 gfx::Rect layer_rect, 164 const gfx::Rect& layer_rect,
165 gfx::Rect opaque_rect, 165 const gfx::Rect& opaque_rect,
166 const PixelRefMap& pixel_refs) : 166 const PixelRefMap& pixel_refs) :
167 layer_rect_(layer_rect), 167 layer_rect_(layer_rect),
168 opaque_rect_(opaque_rect), 168 opaque_rect_(opaque_rect),
169 picture_(picture), 169 picture_(picture),
170 pixel_refs_(pixel_refs), 170 pixel_refs_(pixel_refs),
171 cell_size_(layer_rect.size()) { 171 cell_size_(layer_rect.size()) {
172 } 172 }
173 173
174 Picture::~Picture() { 174 Picture::~Picture() {
175 TRACE_EVENT_OBJECT_DELETED_WITH_ID( 175 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 : picture_(NULL), 378 : picture_(NULL),
379 current_pixel_refs_(empty_pixel_refs_.Pointer()), 379 current_pixel_refs_(empty_pixel_refs_.Pointer()),
380 current_index_(0), 380 current_index_(0),
381 min_point_(-1, -1), 381 min_point_(-1, -1),
382 max_point_(-1, -1), 382 max_point_(-1, -1),
383 current_x_(0), 383 current_x_(0),
384 current_y_(0) { 384 current_y_(0) {
385 } 385 }
386 386
387 Picture::PixelRefIterator::PixelRefIterator( 387 Picture::PixelRefIterator::PixelRefIterator(
388 gfx::Rect query_rect, 388 const gfx::Rect& rect,
389 const Picture* picture) 389 const Picture* picture)
390 : picture_(picture), 390 : picture_(picture),
391 current_pixel_refs_(empty_pixel_refs_.Pointer()), 391 current_pixel_refs_(empty_pixel_refs_.Pointer()),
392 current_index_(0) { 392 current_index_(0) {
393 gfx::Rect layer_rect = picture->layer_rect_; 393 gfx::Rect layer_rect = picture->layer_rect_;
394 gfx::Size cell_size = picture->cell_size_; 394 gfx::Size cell_size = picture->cell_size_;
395 DCHECK(!cell_size.IsEmpty()); 395 DCHECK(!cell_size.IsEmpty());
396 396
397 gfx::Rect query_rect(rect);
397 // Early out if the query rect doesn't intersect this picture. 398 // Early out if the query rect doesn't intersect this picture.
398 if (!query_rect.Intersects(layer_rect)) { 399 if (!query_rect.Intersects(layer_rect)) {
399 min_point_ = gfx::Point(0, 0); 400 min_point_ = gfx::Point(0, 0);
400 max_point_ = gfx::Point(0, 0); 401 max_point_ = gfx::Point(0, 0);
401 current_x_ = 1; 402 current_x_ = 1;
402 current_y_ = 1; 403 current_y_ = 1;
403 return; 404 return;
404 } 405 }
405 406
406 // First, subtract the layer origin as cells are stored in layer space. 407 // First, subtract the layer origin as cells are stored in layer space.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 scoped_refptr<base::debug::ConvertableToTraceFormat> 482 scoped_refptr<base::debug::ConvertableToTraceFormat>
482 Picture::AsTraceableRecordData() const { 483 Picture::AsTraceableRecordData() const {
483 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue()); 484 scoped_ptr<base::DictionaryValue> record_data(new base::DictionaryValue());
484 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release()); 485 record_data->Set("picture_id", TracedValue::CreateIDRef(this).release());
485 record_data->SetInteger("width", layer_rect_.width()); 486 record_data->SetInteger("width", layer_rect_.width());
486 record_data->SetInteger("height", layer_rect_.height()); 487 record_data->SetInteger("height", layer_rect_.height());
487 return TracedValue::FromValue(record_data.release()); 488 return TracedValue::FromValue(record_data.release());
488 } 489 }
489 490
490 } // namespace cc 491 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture.h ('k') | cc/resources/picture_layer_tiling.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698