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

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

Issue 161733002: add peekPixels to SkCanvas and SkSurface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « samplecode/SampleLayers.cpp ('k') | src/core/SkCanvas.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b ool isOpaque, 47 SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b ool isOpaque,
48 const SkDeviceProperties& deviceProperties) 48 const SkDeviceProperties& deviceProperties)
49 : SkBaseDevice(deviceProperties) 49 : SkBaseDevice(deviceProperties)
50 { 50 {
51 this->init(config, width, height, isOpaque); 51 this->init(config, width, height, isOpaque);
52 } 52 }
53 53
54 SkBitmapDevice::~SkBitmapDevice() { 54 SkBitmapDevice::~SkBitmapDevice() {
55 } 55 }
56 56
57 SkImageInfo SkBitmapDevice::imageInfo() const {
58 return fBitmap.info();
59 }
60
57 void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) { 61 void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
58 SkASSERT(bm.width() == fBitmap.width()); 62 SkASSERT(bm.width() == fBitmap.width());
59 SkASSERT(bm.height() == fBitmap.height()); 63 SkASSERT(bm.height() == fBitmap.height());
60 fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config) 64 fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config)
61 fBitmap.lockPixels(); 65 fBitmap.lockPixels();
62 } 66 }
63 67
64 SkBaseDevice* SkBitmapDevice::onCreateCompatibleDevice(SkBitmap::Config config, 68 SkBaseDevice* SkBitmapDevice::onCreateCompatibleDevice(SkBitmap::Config config,
65 int width, int height, 69 int width, int height,
66 bool isOpaque, 70 bool isOpaque,
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 void SkBitmapDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, 383 void SkBitmapDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
380 int x, int y, const SkPaint& paint) { 384 int x, int y, const SkPaint& paint) {
381 const SkBitmap& src = device->accessBitmap(false); 385 const SkBitmap& src = device->accessBitmap(false);
382 draw.drawSprite(src, x, y, paint); 386 draw.drawSprite(src, x, y, paint);
383 } 387 }
384 388
385 SkSurface* SkBitmapDevice::newSurface(const SkImageInfo& info) { 389 SkSurface* SkBitmapDevice::newSurface(const SkImageInfo& info) {
386 return SkSurface::NewRaster(info); 390 return SkSurface::NewRaster(info);
387 } 391 }
388 392
393 const void* SkBitmapDevice::peekPixels(SkImageInfo* info, size_t* rowBytes) {
394 if (fBitmap.getPixels() && fBitmap.asImageInfo(info)) {
395 if (rowBytes) {
396 *rowBytes = fBitmap.rowBytes();
397 }
398 return fBitmap.getPixels();
399 }
400 return NULL;
401 }
402
389 /////////////////////////////////////////////////////////////////////////////// 403 ///////////////////////////////////////////////////////////////////////////////
390 404
391 bool SkBitmapDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) { 405 bool SkBitmapDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) {
392 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { 406 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) {
393 // we're cool with the paint as is 407 // we're cool with the paint as is
394 return false; 408 return false;
395 } 409 }
396 410
397 if (SkBitmap::kARGB_8888_Config != fBitmap.config() || 411 if (SkBitmap::kARGB_8888_Config != fBitmap.config() ||
398 paint.getRasterizer() || 412 paint.getRasterizer() ||
399 paint.getPathEffect() || 413 paint.getPathEffect() ||
400 paint.isFakeBoldText() || 414 paint.isFakeBoldText() ||
401 paint.getStyle() != SkPaint::kFill_Style || 415 paint.getStyle() != SkPaint::kFill_Style ||
402 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) { 416 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) {
403 // turn off lcd 417 // turn off lcd
404 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; 418 flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag;
405 flags->fHinting = paint.getHinting(); 419 flags->fHinting = paint.getHinting();
406 return true; 420 return true;
407 } 421 }
408 // we're cool with the paint as is 422 // we're cool with the paint as is
409 return false; 423 return false;
410 } 424 }
OLDNEW
« no previous file with comments | « samplecode/SampleLayers.cpp ('k') | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698