Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/raster/tile_task_worker_pool.h" | 5 #include "cc/raster/tile_task_worker_pool.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "cc/playback/raster_source.h" | 10 #include "cc/playback/raster_source.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 case ETC1: | 149 case ETC1: |
| 150 case RED_8: | 150 case RED_8: |
| 151 return false; | 151 return false; |
| 152 } | 152 } |
| 153 NOTREACHED(); | 153 NOTREACHED(); |
| 154 return false; | 154 return false; |
| 155 } | 155 } |
| 156 | 156 |
| 157 class SkipImageFilter : public SkDrawFilter { | 157 class SkipImageFilter : public SkDrawFilter { |
| 158 public: | 158 public: |
| 159 bool PaintHasBitmap(const SkPaint& paint) { | 159 bool PaintHasBitmap(const SkPaint& paint) { |
|
vmpstr
2015/08/10 21:27:29
Remove?
danakj
2015/08/10 21:31:10
Oops ya removed.
| |
| 160 SkShader* shader = paint.getShader(); | |
| 161 if (!shader) | |
| 162 return false; | |
| 163 if (shader->asAGradient(nullptr) == SkShader::kNone_GradientType) | |
| 164 return false; | |
| 165 if (shader->asABitmap(nullptr, nullptr, nullptr) != | |
| 166 SkShader::kNone_BitmapType) | |
| 167 return true; | |
| 168 return false; | |
| 169 } | 160 } |
| 170 | 161 |
| 171 bool filter(SkPaint* paint, Type type) override { | 162 bool filter(SkPaint* paint, Type type) override { |
| 172 if (type == kBitmap_Type) | 163 if (type == kBitmap_Type) |
| 173 return false; | 164 return false; |
| 174 if (PaintHasBitmap(*paint)) | 165 |
| 175 return false; | 166 SkShader* shader = paint->getShader(); |
| 176 return true; | 167 if (!shader) |
| 168 return true; | |
| 169 SkShader::BitmapType type = shader->asABitmap(nullptr, nullptr, nullptr); | |
| 170 // The kDefault_BitmapType is returned for images. Other bitmap types are | |
| 171 // simply bitmap representations of colors such as gradients. So, we can | |
| 172 // return true and draw for any case except kDefault_BitmapType. | |
| 173 return type != SkShader::kDefault_BitmapType; | |
| 177 } | 174 } |
| 178 }; | 175 }; |
| 179 | 176 |
| 180 // static | 177 // static |
| 181 void TileTaskWorkerPool::PlaybackToMemory(void* memory, | 178 void TileTaskWorkerPool::PlaybackToMemory(void* memory, |
| 182 ResourceFormat format, | 179 ResourceFormat format, |
| 183 const gfx::Size& size, | 180 const gfx::Size& size, |
| 184 size_t stride, | 181 size_t stride, |
| 185 const RasterSource* raster_source, | 182 const RasterSource* raster_source, |
| 186 const gfx::Rect& canvas_bitmap_rect, | 183 const gfx::Rect& canvas_bitmap_rect, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the | 230 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the |
| 234 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 | 231 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 |
| 235 // is fixed. | 232 // is fixed. |
| 236 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); | 233 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); |
| 237 DCHECK_EQ(0u, dst_row_bytes % 4); | 234 DCHECK_EQ(0u, dst_row_bytes % 4); |
| 238 bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0); | 235 bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0); |
| 239 DCHECK_EQ(true, success); | 236 DCHECK_EQ(true, success); |
| 240 } | 237 } |
| 241 | 238 |
| 242 } // namespace cc | 239 } // namespace cc |
| OLD | NEW |