Ejemplo n.º 1
0
TabContents::~TabContents()
{
    is_being_destroyed_ = true;

    NotifyDisconnected();

    // OnCloseStarted isn't called in unit tests.
    if(!tab_close_start_time_.is_null())
    {
        UMA_HISTOGRAM_TIMES("Tab.Close",
            base::TimeTicks::Now() - tab_close_start_time_);
    }

    //FOR_EACH_OBSERVER(TabContentsObserver, observers_, TabContentsDestroyed());

    set_delegate(NULL);
}
Ejemplo n.º 2
0
    // static
    SkBitmap ImageOperations::ResizeBasic(const SkBitmap& source,
        ResizeMethod method,
        int dest_width, int dest_height,
        const SkIRect& dest_subset)
    {
        // 确保枚举值合法.
        SkASSERT(((RESIZE_FIRST_QUALITY_METHOD<=method) &&
            (method<=RESIZE_LAST_QUALITY_METHOD)) ||
            ((RESIZE_FIRST_ALGORITHM_METHOD<=method) &&
            (method<=RESIZE_LAST_ALGORITHM_METHOD)));

        // 用于计算函数执行时间, 方便查看是否有问题.
        base::TimeTicks resize_start = base::TimeTicks::Now();

        SkIRect dest = { 0, 0, dest_width, dest_height };
        DCHECK(dest.contains(dest_subset)) <<
            "The supplied subset does not fall within the destination image.";

        // 如果源和目的大小都是0(0*0 0*N N*0), 返回一个空位图.
        if(source.width()<1 || source.height()<1 ||
            dest_width<1 || dest_height<1)
        {
            return SkBitmap();
        }

        method = ResizeMethodToAlgorithmMethod(method);
        // Check that we deal with an "algorithm methods" from this point onward.
        SkASSERT((ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD<=method) &&
            (method<=ImageOperations::RESIZE_LAST_ALGORITHM_METHOD));

        SkAutoLockPixels locker(source);

        ResizeFilter filter(method, source.width(), source.height(),
            dest_width, dest_height, dest_subset);

        // Get a source bitmap encompassing this touched area. We construct the
        // offsets and row strides such that it looks like a new bitmap, while
        // referring to the old data.
        const uint8* source_subset =
            reinterpret_cast<const uint8*>(source.getPixels());

        // Convolve into the result.
        base::CPU cpu;
        SkBitmap result;
        result.setConfig(SkBitmap::kARGB_8888_Config,
            dest_subset.width(), dest_subset.height());
        result.allocPixels();
        BGRAConvolve2D(source_subset, static_cast<int>(source.rowBytes()),
            !source.isOpaque(), filter.x_filter(), filter.y_filter(),
            static_cast<int>(result.rowBytes()),
            static_cast<unsigned char*>(result.getPixels()),
            cpu.has_sse2());

        // Preserve the "opaque" flag for use as an optimization later.
        result.setIsOpaque(source.isOpaque());

        base::TimeDelta delta = base::TimeTicks::Now() - resize_start;
        UMA_HISTOGRAM_TIMES("Image.ResampleMS", delta);

        return result;
    }