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

Side by Side Diff: src/core/SkBitmapDevice.cpp

Issue 2309483002: WIP RasterCanvasLayerAllocator experiment 2
Patch Set: support initial data? Created 4 years, 3 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 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkConfig8888.h" 9 #include "SkConfig8888.h"
10 #include "SkDraw.h" 10 #include "SkDraw.h"
11 #include "SkImageFilter.h" 11 #include "SkImageFilter.h"
12 #include "SkImageFilterCache.h" 12 #include "SkImageFilterCache.h"
13 #include "SkMallocPixelRef.h" 13 #include "SkMallocPixelRef.h"
14 #include "SkMatrix.h" 14 #include "SkMatrix.h"
15 #include "SkPaint.h" 15 #include "SkPaint.h"
16 #include "SkPath.h" 16 #include "SkPath.h"
17 #include "SkPixelRef.h" 17 #include "SkPixelRef.h"
18 #include "SkPixmap.h" 18 #include "SkPixmap.h"
19 #include "SkRasterCanvasLayerAllocator.h"
19 #include "SkRasterClip.h" 20 #include "SkRasterClip.h"
20 #include "SkShader.h" 21 #include "SkShader.h"
21 #include "SkSpecialImage.h" 22 #include "SkSpecialImage.h"
22 #include "SkSurface.h" 23 #include "SkSurface.h"
23 #include "SkXfermode.h" 24 #include "SkXfermode.h"
24 25
25 class SkColorTable; 26 class SkColorTable;
26 27
27 static bool valid_for_bitmap_device(const SkImageInfo& info, 28 static bool valid_for_bitmap_device(const SkImageInfo& info,
28 SkAlphaType* newAlphaType) { 29 SkAlphaType* newAlphaType) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 128 }
128 129
129 void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) { 130 void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
130 SkASSERT(bm.width() == fBitmap.width()); 131 SkASSERT(bm.width() == fBitmap.width());
131 SkASSERT(bm.height() == fBitmap.height()); 132 SkASSERT(bm.height() == fBitmap.height());
132 fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config) 133 fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config)
133 fBitmap.lockPixels(); 134 fBitmap.lockPixels();
134 this->privateResize(fBitmap.info().width(), fBitmap.info().height()); 135 this->privateResize(fBitmap.info().width(), fBitmap.info().height());
135 } 136 }
136 137
137 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa int*) { 138 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa int*,
139 SkRasterCanvasLayerAllocator* alloc ator) {
140 SkDebugf("SkBitmapDevice::onCreateDevice(%lx)", allocator);
138 const SkSurfaceProps surfaceProps(this->surfaceProps().flags(), cinfo.fPixel Geometry); 141 const SkSurfaceProps surfaceProps(this->surfaceProps().flags(), cinfo.fPixel Geometry);
142 if (allocator) {
143 SkBitmap bitmap;
144 size_t rowBytes;
145 void* pixels = allocator->allocateLayer(cinfo.fInfo, &rowBytes);
146 bitmap.installPixels(cinfo.fInfo, pixels, rowBytes);
147 return new SkBitmapDevice(bitmap, surfaceProps);
148 }
139 return SkBitmapDevice::Create(cinfo.fInfo, surfaceProps); 149 return SkBitmapDevice::Create(cinfo.fInfo, surfaceProps);
140 } 150 }
141 151
142 const SkBitmap& SkBitmapDevice::onAccessBitmap() { 152 const SkBitmap& SkBitmapDevice::onAccessBitmap() {
143 return fBitmap; 153 return fBitmap;
144 } 154 }
145 155
146 bool SkBitmapDevice::onAccessPixels(SkPixmap* pmap) { 156 bool SkBitmapDevice::onAccessPixels(SkPixmap* pmap) {
147 if (this->onPeekPixels(pmap)) { 157 if (this->onPeekPixels(pmap)) {
148 fBitmap.notifyPixelsChanged(); 158 fBitmap.notifyPixelsChanged();
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 paint.getRasterizer() || 454 paint.getRasterizer() ||
445 paint.getPathEffect() || 455 paint.getPathEffect() ||
446 paint.isFakeBoldText() || 456 paint.isFakeBoldText() ||
447 paint.getStyle() != SkPaint::kFill_Style || 457 paint.getStyle() != SkPaint::kFill_Style ||
448 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) 458 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode))
449 { 459 {
450 return true; 460 return true;
451 } 461 }
452 return false; 462 return false;
453 } 463 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698