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

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

Issue 1763143002: WIP RasterCanvasLayerAllocator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: test and some further work Created 4 years, 6 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 "SkImageFilterCache.h" 11 #include "SkImageFilterCache.h"
12 #include "SkMallocPixelRef.h" 12 #include "SkMallocPixelRef.h"
13 #include "SkMatrix.h" 13 #include "SkMatrix.h"
14 #include "SkPaint.h" 14 #include "SkPaint.h"
15 #include "SkPath.h" 15 #include "SkPath.h"
16 #include "SkPixelRef.h" 16 #include "SkPixelRef.h"
17 #include "SkPixmap.h" 17 #include "SkPixmap.h"
18 #include "SkRasterCanvasLayerAllocator.h"
18 #include "SkShader.h" 19 #include "SkShader.h"
19 #include "SkSurface.h" 20 #include "SkSurface.h"
20 #include "SkXfermode.h" 21 #include "SkXfermode.h"
21 22
22 class SkColorTable; 23 class SkColorTable;
23 24
24 static bool valid_for_bitmap_device(const SkImageInfo& info, 25 static bool valid_for_bitmap_device(const SkImageInfo& info,
25 SkAlphaType* newAlphaType) { 26 SkAlphaType* newAlphaType) {
26 if (info.width() < 0 || info.height() < 0) { 27 if (info.width() < 0 || info.height() < 0) {
27 return false; 28 return false;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 fBitmap.setInfo(fBitmap.info().makeWH(size.fWidth, size.fHeight)); 123 fBitmap.setInfo(fBitmap.info().makeWH(size.fWidth, size.fHeight));
123 } 124 }
124 125
125 void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) { 126 void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
126 SkASSERT(bm.width() == fBitmap.width()); 127 SkASSERT(bm.width() == fBitmap.width());
127 SkASSERT(bm.height() == fBitmap.height()); 128 SkASSERT(bm.height() == fBitmap.height());
128 fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config) 129 fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config)
129 fBitmap.lockPixels(); 130 fBitmap.lockPixels();
130 } 131 }
131 132
132 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa int*) { 133 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa int*,
134 SkRasterCanvasLayerAllocator* alloc ) {
133 const SkSurfaceProps surfaceProps(this->surfaceProps().flags(), cinfo.fPixel Geometry); 135 const SkSurfaceProps surfaceProps(this->surfaceProps().flags(), cinfo.fPixel Geometry);
134 return SkBitmapDevice::Create(cinfo.fInfo, surfaceProps); 136 SkBitmapDevice* dev = nullptr;
137 if (alloc) {
138 SkBitmap bitmap;
139 size_t rowBytes;
140 void* layer = alloc->allocateLayer(cinfo.fInfo, &rowBytes);
141 if (layer &&
142 bitmap.installPixels(cinfo.fInfo, layer, rowBytes)) {
143 dev = new SkBitmapDevice(bitmap);
144 }
145 } else {
146 dev = SkBitmapDevice::Create(cinfo.fInfo, surfaceProps);
147 }
148 return dev;
135 } 149 }
136 150
137 const SkBitmap& SkBitmapDevice::onAccessBitmap() { 151 const SkBitmap& SkBitmapDevice::onAccessBitmap() {
138 return fBitmap; 152 return fBitmap;
139 } 153 }
140 154
141 bool SkBitmapDevice::onAccessPixels(SkPixmap* pmap) { 155 bool SkBitmapDevice::onAccessPixels(SkPixmap* pmap) {
142 if (fBitmap.lockPixelsAreWritable() && this->onPeekPixels(pmap)) { 156 if (fBitmap.lockPixelsAreWritable() && this->onPeekPixels(pmap)) {
143 fBitmap.notifyPixelsChanged(); 157 fBitmap.notifyPixelsChanged();
144 return true; 158 return true;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 paint.getRasterizer() || 395 paint.getRasterizer() ||
382 paint.getPathEffect() || 396 paint.getPathEffect() ||
383 paint.isFakeBoldText() || 397 paint.isFakeBoldText() ||
384 paint.getStyle() != SkPaint::kFill_Style || 398 paint.getStyle() != SkPaint::kFill_Style ||
385 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) 399 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode))
386 { 400 {
387 return true; 401 return true;
388 } 402 }
389 return false; 403 return false;
390 } 404 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698