OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/gfx/canvas.h" | 5 #include "ui/gfx/canvas.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 // static | 114 // static |
115 int Canvas::DefaultCanvasTextAlignment() { | 115 int Canvas::DefaultCanvasTextAlignment() { |
116 return base::i18n::IsRTL() ? TEXT_ALIGN_RIGHT : TEXT_ALIGN_LEFT; | 116 return base::i18n::IsRTL() ? TEXT_ALIGN_RIGHT : TEXT_ALIGN_LEFT; |
117 } | 117 } |
118 | 118 |
119 ImageSkiaRep Canvas::ExtractImageRep() const { | 119 ImageSkiaRep Canvas::ExtractImageRep() const { |
120 // Make a bitmap to return, and a canvas to draw into it. We don't just want | 120 // Make a bitmap to return, and a canvas to draw into it. We don't just want |
121 // to call extractSubset or the copy constructor, since we want an actual copy | 121 // to call extractSubset or the copy constructor, since we want an actual copy |
122 // of the bitmap. | 122 // of the bitmap. |
123 const SkISize size = canvas_->getDeviceSize(); | 123 const SkISize size = canvas_->getBaseLayerSize(); |
124 SkBitmap result; | 124 SkBitmap result; |
125 result.allocN32Pixels(size.width(), size.height()); | 125 result.allocN32Pixels(size.width(), size.height()); |
126 | 126 |
127 canvas_->readPixels(&result, 0, 0); | 127 canvas_->readPixels(&result, 0, 0); |
128 return ImageSkiaRep(result, image_scale_); | 128 return ImageSkiaRep(result, image_scale_); |
129 } | 129 } |
130 | 130 |
131 void Canvas::DrawDashedRect(const Rect& rect, SkColor color) { | 131 void Canvas::DrawDashedRect(const Rect& rect, SkColor color) { |
132 if (rect.IsEmpty()) | 132 if (rect.IsEmpty()) |
133 return; | 133 return; |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 // by the paint). | 584 // by the paint). |
585 SkPaint p(paint); | 585 SkPaint p(paint); |
586 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); | 586 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); |
587 p.setShader(shader.get()); | 587 p.setShader(shader.get()); |
588 | 588 |
589 // The rect will be filled by the bitmap. | 589 // The rect will be filled by the bitmap. |
590 canvas_->drawRect(dest_rect, p); | 590 canvas_->drawRect(dest_rect, p); |
591 } | 591 } |
592 | 592 |
593 } // namespace gfx | 593 } // namespace gfx |
OLD | NEW |